zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #23546
[Merge] lp:~zorba-coders/zorba/markos-scratch into lp:zorba
Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/markos-scratch into lp:zorba.
Commit message:
fixed bug in casting to xs:NCName + fixed bug in computed PI constructor
Requested reviews:
Markos Zaharioudakis (markos-za)
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/170429
fixed bug in casting to xs:NCName + fixed bug in computed PI constructor
--
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/170429
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog 2013-06-18 09:10:28 +0000
+++ ChangeLog 2013-06-19 19:28:28 +0000
@@ -30,6 +30,8 @@
* Fixed bug #1180220 (Consolidate redundant path/file public APIs)
* Fixed bug #1103115 (Timezone units as hours are wrong)
* Fixed bug #1188280 (casting xs:id to xs:ncname)
+ * Fixed bug in casting to xs:NCName
+ * Fixed bug in error conditions for computed PI constructor
* Fixed implementation of fn:deep-equal according to latest W3C spec.
* Must apply document ordering on the domain expression of a FOR clause, if
the FOR clause is followed by a sequential clause.
=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp 2013-06-19 09:54:46 +0000
+++ src/compiler/translator/translator.cpp 2013-06-19 19:28:28 +0000
@@ -1744,9 +1744,7 @@
{
e = wrap_in_atomization(e);
- return CREATE(promote)(theRootSctx,
- theUDF,
- e->get_loc(),
+ return CREATE(promote)(theRootSctx, theUDF, e->get_loc(),
e,
type,
errorKind,
@@ -1774,14 +1772,12 @@
}
else
{
- return theExprManager->create_treat_expr(theRootSctx,
- theUDF,
- e->get_loc(),
- e,
- type,
- errorKind,
- true,
- qname);
+ return CREATE(treat)(theRootSctx, theUDF, e->get_loc(),
+ e,
+ type,
+ errorKind,
+ true,
+ qname);
}
}
@@ -1791,11 +1787,9 @@
********************************************************************************/
fo_expr* wrap_in_enclosed_expr(expr* contentExpr, const QueryLoc& loc)
{
- return theExprManager->create_fo_expr(theRootSctx,
- theUDF,
- loc,
- BUILTIN_FUNC(OP_ENCLOSED_1),
- contentExpr);
+ return CREATE(fo)(theRootSctx, theUDF, loc,
+ BUILTIN_FUNC(OP_ENCLOSED_1),
+ contentExpr);
}
@@ -1804,12 +1798,9 @@
********************************************************************************/
expr* wrap_in_bev(expr * e)
{
- fo_expr* fo = theExprManager->create_fo_expr(theRootSctx,
- theUDF,
- e->get_loc(),
- BUILTIN_FUNC(FN_BOOLEAN_1),
- e);
- return fo;
+ return CREATE(fo)(theRootSctx, theUDF, e->get_loc(),
+ BUILTIN_FUNC(FN_BOOLEAN_1),
+ e);
}
@@ -14269,10 +14260,9 @@
{
target = pop_nodestack();
- expr* castExpr =
- create_cast_expr(loc, target, theRTM.NCNAME_TYPE_ONE, false, true);
-
- target = wrap_in_enclosed_expr(castExpr, loc);
+ target = wrap_in_type_promotion(target,
+ theRTM.ANY_ATOMIC_TYPE_ONE,
+ PROMOTE_TYPE_PROMOTION);
}
expr* e;
=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml 2013-06-18 14:29:16 +0000
+++ src/diagnostics/diagnostic_en.xml 2013-06-19 19:28:28 +0000
@@ -304,6 +304,9 @@
<value>atomization of grouping variable produces more than one item</value>
</entry>
+ <entry key="PiTarget_3">
+ <value>$3: type of processing instruction target is not xs:NCName, or xs:string, or xs:untypedAtomic</value>
+ </entry>
</diagnostic>
<diagnostic code="XPTY0018">
=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp 2013-06-18 14:29:16 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp 2013-06-19 19:28:28 +0000
@@ -922,6 +922,7 @@
{ "~XPTY0004_NoReturnTypePromote_234", "$2 can not be promoted to return type $3 of function $4()" },
{ "~XPTY0004_NoTreatAs_23", "$2 can not be treated as type $3" },
{ "~XPTY0004_NoTypePromote_23", "$2 can not be promoted to type $3" },
+ { "~XPTY0004_PiTarget_3", "$3: type of processing instruction target is not xs:NCName, or xs:string, or xs:untypedAtomic" },
{ "~XPTY0117_NodeCast", "Cannot cast node to xs:QName" },
{ "~XPTY0117_NotationParam_23", "$2 can not be promoted to parameter type xs:NOTATION of function $3()" },
{ "~XQDY0027_InvalidValue", "\"$2\": invalid value for type${: 3}${: 4}" },
=== modified file 'src/diagnostics/pregenerated/dict_zed_keys.h'
--- src/diagnostics/pregenerated/dict_zed_keys.h 2013-06-18 14:29:16 +0000
+++ src/diagnostics/pregenerated/dict_zed_keys.h 2013-06-19 19:28:28 +0000
@@ -48,6 +48,7 @@
#define ZED_XPTY0004_NoTreatAs_23 "~XPTY0004_NoTreatAs_23"
#define ZED_XPTY0004_JSONIQ_SELECTOR "~XPTY0004_JSONIQ_SELECTOR"
#define ZED_XPTY0004_MultiValuedGroupingKey "~XPTY0004_MultiValuedGroupingKey"
+#define ZED_XPTY0004_PiTarget_3 "~XPTY0004_PiTarget_3"
#define ZED_XPTY0117_NodeCast "~XPTY0117_NodeCast"
#define ZED_XPTY0117_NotationParam_23 "~XPTY0117_NotationParam_23"
#define ZED_XQST0046_BadHexDigit_3 "~XQST0046_BadHexDigit_3"
=== modified file 'src/runtime/core/constructors.cpp'
--- src/runtime/core/constructors.cpp 2013-06-05 00:37:35 +0000
+++ src/runtime/core/constructors.cpp 2013-06-19 19:28:28 +0000
@@ -856,8 +856,10 @@
bool PiIterator::nextImpl(store::Item_t& result, PlanState& planState) const
{
- store::Item_t lItem;
+ store::Item_t targetItem;
+ store::SchemaTypeCode targetType;
store::Item_t temp;
+ store::Item_t contentItem;
zstring content;
zstring target;
zstring baseUri;
@@ -870,29 +872,38 @@
DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
// Compute the target of the pi node.
- try
- {
- if (!consumeNext(lItem, theChild0, planState))
- {
- // translator places a cast to xs:NCName op
- ZORBA_ASSERT(false);
- }
- }
- catch (ZorbaException const& e)
- {
- if (e.diagnostic() == err::FORG0001)
- throw XQUERY_EXCEPTION(err::XQDY0041, ERROR_LOC(loc));
- else
- throw;
- }
-
- if (consumeNext(temp, theChild0, planState))
- {
- // translator places a cast to xs:NCName op
- ZORBA_ASSERT(false);
- }
-
- lItem->getStringValue2(target);
+ // translator places a promote to xs:anyAtomicType op
+ ZORBA_ASSERT(consumeNext(targetItem, theChild0, planState));
+
+ targetType = targetItem->getTypeCode();
+
+ if (targetType != store::XS_NCNAME &&
+ targetType != store::XS_STRING &&
+ targetType != store::XS_UNTYPED_ATOMIC)
+ {
+ TypeManager* tm = theSctx->get_typemanager();
+ xqtref_t type = tm->create_value_type(targetItem);
+ RAISE_ERROR(err::XPTY0004, loc,
+ ERROR_PARAMS(ZED(XPTY0004_PiTarget_3), type->toSchemaString()));
+ }
+
+ if (targetType != store::XS_NCNAME)
+ {
+ try
+ {
+ GenericCast::
+ castToBuiltinAtomic(targetItem, targetItem, store::XS_NCNAME, NULL, loc);
+ }
+ catch (ZorbaException& e)
+ {
+ if (e.diagnostic() == err::FORG0001)
+ throw XQUERY_EXCEPTION(err::XQDY0041, ERROR_LOC(loc));
+ else
+ throw;
+ }
+ }
+
+ targetItem->getStringValue2(target);
if (target.empty())
{
@@ -909,14 +920,14 @@
// Compute the content of the pi node
for (lFirst = true;
- consumeNext(lItem, theChild1.getp(), planState);
+ consumeNext(contentItem, theChild1.getp(), planState);
lFirst = false)
{
if (! lFirst)
content += " ";
zstring strvalue;
- lItem->getStringValue2(strvalue);
+ contentItem->getStringValue2(strvalue);
if (strvalue.find("?>", 0, 2) != zstring::npos)
throw XQUERY_EXCEPTION(err::XQDY0026, ERROR_LOC(loc));
@@ -934,7 +945,7 @@
GENV_ITEMFACTORY->createPiNode(result, parent, target, content, baseUri);
STACK_PUSH(true, state);
- STACK_END (state);
+ STACK_END(state);
}
=== modified file 'src/types/casting.cpp'
--- src/types/casting.cpp 2013-06-18 09:10:28 +0000
+++ src/types/casting.cpp 2013-06-19 19:28:28 +0000
@@ -2431,6 +2431,18 @@
for (csize i = 0; i < memberTypes.size(); ++i)
{
+ if (TypeOps::is_subtype(tm, item.getp(), *memberTypes[i], loc))
+ {
+ store::Item_t tmp = item;
+ resultList.clear();
+
+ ZORBA_ASSERT(castToSimple(tmp, memberTypes[i], nsCtx, resultList, tm, loc));
+ return true;
+ }
+ }
+
+ for (csize i = 0; i < memberTypes.size(); ++i)
+ {
try
{
store::Item_t tmp = item;
@@ -2658,15 +2670,6 @@
throwXPTY0004Exception(errInfo);
}
- if (targetTypeCode == store::XS_NCNAME &&
- !TypeOps::is_subtype(sourceTypeCode, store::XS_NCNAME) &&
- sourceTypeCode != store::XS_STRING &&
- sourceTypeCode != store::XS_NCNAME &&
- sourceTypeCode != store::XS_UNTYPED_ATOMIC)
- {
- throwXPTY0004Exception(errInfo);
- }
-
CastFunc castFunc = theCastMatrix[theMapping[sourceTypeCode]]
[theMapping[targetTypeCode]];
if (castFunc == 0)
Follow ups