Merge lp:~zorba-coders/zorba/bug-1006960 into lp:zorba

Proposed by Markos Zaharioudakis
Status: Merged
Approved by: Markos Zaharioudakis
Approved revision: 10870
Merged at revision: 11075
Proposed branch: lp:~zorba-coders/zorba/bug-1006960
Merge into: lp:zorba
Diff against target: 248 lines (+122/-10)
11 files modified
ChangeLog (+10/-6)
src/compiler/rewriter/rules/nodeid_rules.cpp (+17/-2)
src/functions/CMakeLists.txt (+1/-0)
src/functions/func_schema_impl.cpp (+36/-0)
src/functions/pregenerated/func_schema.h (+1/-1)
src/runtime/spec/schema/schema.xml (+1/-1)
test/rbkt/ExpQueryResults/zorba/no-copy/test2.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/test3.xml.res (+1/-0)
test/rbkt/Queries/zorba/no-copy/simple.xsd (+27/-0)
test/rbkt/Queries/zorba/no-copy/test2.xq (+14/-0)
test/rbkt/Queries/zorba/no-copy/test3.xq (+12/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug-1006960
Reviewer Review Type Date Requested Status
Markos Zaharioudakis Approve
Review via email: mp+109330@code.launchpad.net

Commit message

Fixed bug #1006960 (taking construction mode into account during no-copy rule)

Description of the change

Fixed bug #1006960 (taking construction mode into account during no-copy rule)

To post a comment you must log in.
lp:~zorba-coders/zorba/bug-1006960 updated
10869. By Markos Zaharioudakis

fixed schema-type function

10870. By Markos Zaharioudakis

merge from trunk

Revision history for this message
Markos Zaharioudakis (markos-za) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-1006960-2012-10-01T08-28-50.906Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2012-09-28 07:56:07 +0000
3+++ ChangeLog 2012-10-01 08:20:29 +0000
4@@ -15,12 +15,13 @@
5 * Best-effort serialization of atomic values in JSON items.
6 * Positional pagination support for index probes
7 * Recognize the {http://www.zorba-xquery.com/extensions}no-copy pragma to avoid
8- copying nodes before insertion into a collection.
9- * Recognize the no-copy pragma to avoid copying nodes before insertion into a collection.
10- * Added createUntypedAtomic to API's ItemFactory.
11+ copying nodes before insertion into a collection.
12+ * Recognize the no-copy pragma to avoid copying nodes before insertion into
13+ a collection.
14+ * Added createUntypedAtomic to API's ItemFactory.
15 * new xqDoc feature; reporting collections and indexes
16- * new xqDoc function parameter to enable/disable xqDoc generation of
17- certain components
18+ * new xqDoc function parameter to enable/disable xqDoc generation of certain
19+ components
20
21 Optimizations:
22 * Improved memory management for compiler expressions (no more ref counting)
23@@ -36,7 +37,9 @@
24 * Optimized runtime group iterator based on latest group-by semantics.
25
26 Bug Fixes/Other Changes:
27- * Fixed bug #950621 (Removed two-arg version of fn:parse-xml(); use XML module function xml:parse() instead)
28+ * Fixed bug #1006960 (taking construction mode into account during no-copy rule)
29+ * Fixed bug #950621 (Removed two-arg version of fn:parse-xml(); use XML module
30+ function xml:parse() instead)
31 * Fixed bug #867227 (Improved error message for missing commas)
32 * Fixed bug #1024033 and #1023170 (segfaults in parse-xml:parse())
33 * Fixed bug #898792 (Dynamically computed strings can now be cast to xs:QName)
34@@ -129,6 +132,7 @@
35 * The XML plan serialization format is not supported anymore
36
37
38+>>>>>>> MERGE-SOURCE
39 version 2.5
40
41 New Features:
42
43=== modified file 'src/compiler/rewriter/rules/nodeid_rules.cpp'
44--- src/compiler/rewriter/rules/nodeid_rules.cpp 2012-09-28 19:16:51 +0000
45+++ src/compiler/rewriter/rules/nodeid_rules.cpp 2012-10-01 08:20:29 +0000
46@@ -587,7 +587,9 @@
47 {
48 if (rCtx.theCCB->theConfig.for_serialization_only)
49 {
50+ // Serialization may or may not be a "node-id-sesitive" op.
51 static_context* sctx = node->get_sctx();
52+
53 if (sctx->preserve_mode() == StaticContextConsts::preserve_ns &&
54 sctx->inherit_mode() == StaticContextConsts::inherit_ns)
55 {
56@@ -603,6 +605,8 @@
57 }
58 else
59 {
60+ // We have to assume that the result of the "node" expr will be used in a
61+ // "node-id-sesitive" op, so it must consist of standalone trees.
62 std::vector<expr*> sources;
63 UDFCallChain dummyUdfCaller;
64 theSourceFinder->findNodeSources(rCtx.theRoot, &dummyUdfCaller, sources);
65@@ -801,10 +805,21 @@
66
67 case castable_expr_kind:
68 case cast_expr_kind:
69+ case promote_expr_kind:
70 case instanceof_expr_kind:
71+ case treat_expr_kind:
72+ {
73+ if (node->get_sctx()->construction_mode() == StaticContextConsts::cons_strip)
74+ {
75+ cast_or_castable_base_expr* e = static_cast<cast_or_castable_base_expr*>(node);
76+
77+ markForSerialization(e->get_input());
78+ }
79+
80+ break;
81+ }
82+
83 case name_cast_expr_kind:
84- case promote_expr_kind:
85- case treat_expr_kind:
86 case order_expr_kind:
87 case wrapper_expr_kind:
88 case function_trace_expr_kind:
89
90=== modified file 'src/functions/CMakeLists.txt'
91--- src/functions/CMakeLists.txt 2012-09-17 00:36:37 +0000
92+++ src/functions/CMakeLists.txt 2012-10-01 08:20:29 +0000
93@@ -85,6 +85,7 @@
94 func_apply.cpp
95 func_serialize_impl.cpp
96 func_parse_fragment_impl.cpp
97+ func_schema_impl.cpp
98 )
99
100 IF (ZORBA_WITH_JSON)
101
102=== added file 'src/functions/func_schema_impl.cpp'
103--- src/functions/func_schema_impl.cpp 1970-01-01 00:00:00 +0000
104+++ src/functions/func_schema_impl.cpp 2012-10-01 08:20:29 +0000
105@@ -0,0 +1,36 @@
106+/*
107+ * Copyright 2006-2008 The FLWOR Foundation.
108+ *
109+ * Licensed under the Apache License, Version 2.0 (the "License");
110+ * you may not use this file except in compliance with the License.
111+ * You may obtain a copy of the License at
112+ *
113+ * http://www.apache.org/licenses/LICENSE-2.0
114+ *
115+ * Unless required by applicable law or agreed to in writing, software
116+ * distributed under the License is distributed on an "AS IS" BASIS,
117+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
118+ * See the License for the specific language governing permissions and
119+ * limitations under the License.
120+ */
121+
122+#include "functions/func_schema.h"
123+
124+#include "compiler/expression/expr_base.h"
125+
126+#include "context/static_context.h"
127+
128+namespace zorba
129+{
130+
131+
132+/*******************************************************************************
133+
134+********************************************************************************/
135+bool fn_zorba_schema_schema_type::mustCopyInputNodes(expr* fo, csize producer) const
136+{
137+ return (fo->get_sctx()->construction_mode() == StaticContextConsts::cons_strip);
138+}
139+
140+
141+}
142
143=== modified file 'src/functions/pregenerated/func_schema.h'
144--- src/functions/pregenerated/func_schema.h 2012-09-24 09:17:44 +0000
145+++ src/functions/pregenerated/func_schema.h 2012-10-01 08:20:29 +0000
146@@ -87,7 +87,7 @@
147
148 }
149
150- bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
151+ bool mustCopyInputNodes(expr* fo, csize producer) const;
152
153 CODEGEN_DECL();
154 };
155
156=== modified file 'src/runtime/spec/schema/schema.xml'
157--- src/runtime/spec/schema/schema.xml 2012-09-17 00:36:37 +0000
158+++ src/runtime/spec/schema/schema.xml 2012-10-01 08:20:29 +0000
159@@ -99,7 +99,7 @@
160 </zorba:signature>
161
162 <zorba:methods>
163- <zorba:mustCopyInputNodes value="false"/>
164+ <zorba:mustCopyInputNodes/>
165 </zorba:methods>
166
167 </zorba:function>
168
169=== added file 'test/rbkt/ExpQueryResults/zorba/no-copy/test2.xml.res'
170--- test/rbkt/ExpQueryResults/zorba/no-copy/test2.xml.res 1970-01-01 00:00:00 +0000
171+++ test/rbkt/ExpQueryResults/zorba/no-copy/test2.xml.res 2012-10-01 08:20:29 +0000
172@@ -0,0 +1,2 @@
173+<?xml version="1.0" encoding="UTF-8"?>
174+false
175
176=== added file 'test/rbkt/ExpQueryResults/zorba/no-copy/test3.xml.res'
177--- test/rbkt/ExpQueryResults/zorba/no-copy/test3.xml.res 1970-01-01 00:00:00 +0000
178+++ test/rbkt/ExpQueryResults/zorba/no-copy/test3.xml.res 2012-10-01 08:20:29 +0000
179@@ -0,0 +1,1 @@
180+xs:untypedAtomic
181
182=== added file 'test/rbkt/Queries/zorba/no-copy/simple.xsd'
183--- test/rbkt/Queries/zorba/no-copy/simple.xsd 1970-01-01 00:00:00 +0000
184+++ test/rbkt/Queries/zorba/no-copy/simple.xsd 2012-10-01 08:20:29 +0000
185@@ -0,0 +1,27 @@
186+<xs:schema
187+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
188+ targetNamespace="http://www.zorba-xquery.org/simple"
189+ xmlns="http://www.zorba-xquery.org/simple"
190+ elementFormDefault="qualified"
191+ attributeFormDefault="qualified">
192+
193+<xs:element name="person" type="PersonType"/>
194+
195+<xs:complexType name="PersonType">
196+ <xs:sequence>
197+ <xs:element name="name" type="xs:string"/>
198+ <xs:element name="age" type="xs:integer" minOccurs="0" maxOccurs="1"/>
199+ </xs:sequence>
200+</xs:complexType>
201+
202+
203+<xs:element name="person2" type="PersonType2"/>
204+
205+<xs:complexType name="PersonType2">
206+ <xs:sequence>
207+ <xs:element name="name" type="xs:string"/>
208+ </xs:sequence>
209+ <xs:attribute name="age" type="xs:string"/>
210+</xs:complexType>
211+
212+</xs:schema>
213
214=== added file 'test/rbkt/Queries/zorba/no-copy/test2.xq'
215--- test/rbkt/Queries/zorba/no-copy/test2.xq 1970-01-01 00:00:00 +0000
216+++ test/rbkt/Queries/zorba/no-copy/test2.xq 2012-10-01 08:20:29 +0000
217@@ -0,0 +1,14 @@
218+
219+declare namespace opt = "http://www.zorba-xquery.com/options/optimizer";
220+
221+declare construction strip;
222+
223+import schema namespace s="http://www.zorba-xquery.org/simple" at "simple.xsd";
224+
225+declare option opt:enable "for-serialization-only";
226+
227+declare variable $doc := <s:person><s:name>foo</s:name><s:age>25</s:age></s:person>;
228+
229+let $vdoc := validate { $doc }
230+let $copy := <root>{$vdoc/s:name}</root>
231+return $copy/s:name instance of element(*, xs:string)
232
233=== added file 'test/rbkt/Queries/zorba/no-copy/test3.xq'
234--- test/rbkt/Queries/zorba/no-copy/test3.xq 1970-01-01 00:00:00 +0000
235+++ test/rbkt/Queries/zorba/no-copy/test3.xq 2012-10-01 08:20:29 +0000
236@@ -0,0 +1,12 @@
237+declare construction strip;
238+
239+import schema namespace ft = "http://www.zorba-xquery.com/modules/full-text";
240+import module namespace schema = "http://www.zorba-xquery.com/modules/schema";
241+
242+let $x := validate {<ft:compare-options
243+ case="case sensitive"
244+ diacritics="diacritics sensitive"
245+ stemming="stemming"/>}
246+let $y:= (<a> { $x } </a>)/*
247+return
248+ schema:schema-type($y/@case)

Subscribers

People subscribed via source and target branches