Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/bug-1006960 into lp:zorba.
Requested reviews: Markos Zaharioudakis (markos-za) For more details, see: https://code.launchpad.net/~zorba-coders/zorba/bug-1006960/+merge/109330 Fixed bug #1006960 (taking construction mode into account during no-copy rule) -- https://code.launchpad.net/~zorba-coders/zorba/bug-1006960/+merge/109330 Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog' --- ChangeLog 2012-05-30 00:37:00 +0000 +++ ChangeLog 2012-06-08 11:02:21 +0000 @@ -1,5 +1,9 @@ Zorba - The XQuery Processor +version 2.7 + + * Fixed bug #1006960 (taking construction mode into account during no-copy rule) + version 2.5 New Features: === modified file 'src/api/serialization/serializer.cpp' --- src/api/serialization/serializer.cpp 2012-05-03 12:31:51 +0000 +++ src/api/serialization/serializer.cpp 2012-06-08 11:02:21 +0000 @@ -721,7 +721,6 @@ } else { - //item->getNamespaceBindings(nsBindings, store::StoreConsts::ONLY_LOCAL_NAMESPACES); item->getNamespaceBindings(nsBindings); store::Item* nodeName = item->getNodeName(); @@ -814,11 +813,11 @@ ********************************************************************************/ bool serializer::emitter::havePrefix(const zstring& pre) const { - for (unsigned long i = 0; i < theBindings.size(); ++i) + for (csize i = 0; i < theBindings.size(); ++i) { const store::NsBindings& nsBindings = theBindings[i]; - for (unsigned long j = 0; j < nsBindings.size(); ++j) + for (csize j = 0; j < nsBindings.size(); ++j) { if (nsBindings[j].first == pre) return true; === modified file 'src/compiler/rewriter/rules/nodeid_rules.cpp' --- src/compiler/rewriter/rules/nodeid_rules.cpp 2012-05-03 12:31:51 +0000 +++ src/compiler/rewriter/rules/nodeid_rules.cpp 2012-06-08 11:02:21 +0000 @@ -565,7 +565,9 @@ { if (rCtx.theCCB->theConfig.for_serialization_only) { + // Serialization may or may not be a "node-id-sesitive" op. static_context* sctx = node->get_sctx(); + if (sctx->preserve_mode() == StaticContextConsts::preserve_ns && sctx->inherit_mode() == StaticContextConsts::inherit_ns) { @@ -581,6 +583,8 @@ } else { + // We have to assume that the result of the "node" expr will be used in a + // "node-id-sesitive" op, so it must consist of standalone trees. std::vector<expr*> sources; UDFCallChain dummyUdfCaller; theSourceFinder->findNodeSources(rCtx.theRoot, &dummyUdfCaller, sources); @@ -734,10 +738,21 @@ case castable_expr_kind: case cast_expr_kind: + case promote_expr_kind: case instanceof_expr_kind: + case treat_expr_kind: + { + if (node->get_sctx()->construction_mode() == StaticContextConsts::cons_strip) + { + cast_or_castable_base_expr* e = static_cast<cast_or_castable_base_expr*>(node); + + markForSerialization(e->get_input()); + } + + break; + } + case name_cast_expr_kind: - case promote_expr_kind: - case treat_expr_kind: case order_expr_kind: case wrapper_expr_kind: case function_trace_expr_kind: === added file 'test/rbkt/ExpQueryResults/zorba/no-copy/test2.xml.res' --- test/rbkt/ExpQueryResults/zorba/no-copy/test2.xml.res 1970-01-01 00:00:00 +0000 +++ test/rbkt/ExpQueryResults/zorba/no-copy/test2.xml.res 2012-06-08 11:02:21 +0000 @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +false === added file 'test/rbkt/Queries/zorba/no-copy/simple.xsd' --- test/rbkt/Queries/zorba/no-copy/simple.xsd 1970-01-01 00:00:00 +0000 +++ test/rbkt/Queries/zorba/no-copy/simple.xsd 2012-06-08 11:02:21 +0000 @@ -0,0 +1,27 @@ +<xs:schema + xmlns:xs="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://www.zorba-xquery.org/simple" + xmlns="http://www.zorba-xquery.org/simple" + elementFormDefault="qualified" + attributeFormDefault="qualified"> + +<xs:element name="person" type="PersonType"/> + +<xs:complexType name="PersonType"> + <xs:sequence> + <xs:element name="name" type="xs:string"/> + <xs:element name="age" type="xs:integer" minOccurs="0" maxOccurs="1"/> + </xs:sequence> +</xs:complexType> + + +<xs:element name="person2" type="PersonType2"/> + +<xs:complexType name="PersonType2"> + <xs:sequence> + <xs:element name="name" type="xs:string"/> + </xs:sequence> + <xs:attribute name="age" type="xs:string"/> +</xs:complexType> + +</xs:schema> === added file 'test/rbkt/Queries/zorba/no-copy/test2.xq' --- test/rbkt/Queries/zorba/no-copy/test2.xq 1970-01-01 00:00:00 +0000 +++ test/rbkt/Queries/zorba/no-copy/test2.xq 2012-06-08 11:02:21 +0000 @@ -0,0 +1,14 @@ + +declare namespace opt = "http://www.zorba-xquery.com/options/optimizer"; + +declare construction strip; + +import schema namespace s="http://www.zorba-xquery.org/simple" at "simple.xsd"; + +declare option opt:enable "for-serialization-only"; + +declare variable $doc := <s:person><s:name>foo</s:name><s:age>25</s:age></s:person>; + +let $vdoc := validate { $doc } +let $copy := <root>{$vdoc/s:name}</root> +return $copy/s:name instance of element(*, xs:string)
-- Mailing list: https://launchpad.net/~zorba-coders Post to : zorba-coders@lists.launchpad.net Unsubscribe : https://launchpad.net/~zorba-coders More help : https://help.launchpad.net/ListHelp