Merge lp:~zorba-coders/zorba/markos-scratch into lp:zorba

Proposed by Markos Zaharioudakis
Status: Merged
Approved by: Markos Zaharioudakis
Approved revision: 10972
Merged at revision: 11102
Proposed branch: lp:~zorba-coders/zorba/markos-scratch
Merge into: lp:zorba
Diff against target: 818 lines (+376/-136)
21 files modified
ChangeLog (+1/-0)
src/compiler/expression/var_expr.cpp (+0/-2)
src/compiler/rewriter/framework/rule_driver.cpp (+23/-1)
src/compiler/rewriter/framework/rule_driver.h (+3/-1)
src/compiler/rewriter/rewriters/default_optimizer.cpp (+7/-0)
src/compiler/rewriter/rules/fold_rules.cpp (+55/-35)
src/compiler/rewriter/rules/ruleset.h (+11/-1)
src/compiler/rewriter/tools/udf_graph.cpp (+2/-2)
src/compiler/rewriter/tools/udf_graph.h (+2/-2)
src/context/dynamic_context.h (+13/-6)
src/functions/udf.cpp (+7/-2)
src/runtime/core/fncall_iterator.cpp (+28/-25)
test/rbkt/ExpCompilerResults/IterPlan/zorba/udf/udf-fib-rec.iter (+0/-42)
test/rbkt/ExpCompilerResults/IterPlan/zorba/udf/udf-fib-rec2.iter (+45/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/udf/udf-recursive-1.iter (+68/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/udf/udf-recursive-2.iter (+49/-0)
test/rbkt/ExpQueryResults/zorba/optim/no_folding_01.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/udf/udf-fib-rec2.xml.res (+1/-0)
test/rbkt/Queries/zorba/optim/no_folding_01.xq (+22/-0)
test/rbkt/Queries/zorba/reference/reference_5.xq (+30/-17)
test/rbkt/Queries/zorba/udf/udf-fib-rec2.xq (+8/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/markos-scratch
Reviewer Review Type Date Requested Status
Markos Zaharioudakis Approve
Review via email: mp+130495@code.launchpad.net

Commit message

Fixed bug #1067706 (wrong const folding in mutually recursive udfs)

Description of the change

Fixed bug #1067706 (wrong const folding in mutually recursive udfs)

To post a comment you must log in.
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 :

The attempt to merge lp:~zorba-coders/zorba/markos-scratch into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job markos-scratch-2012-10-19T20-51-12.253Z is finished.
  The final status was:

  2 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

10972. By Markos Zaharioudakis

Fixed bug #1067706 (wrong const folding in mutually recursive udfs)

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 markos-scratch-2012-10-20T07-37-00.683Z 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-10-16 13:08:12 +0000
3+++ ChangeLog 2012-10-20 07:27:24 +0000
4@@ -14,6 +14,7 @@
5 * Fixed bug #1061222 (bad message for errors in index key type declaration)
6 * Fixed bug #1065175 (preceding::node()[1] returns wrong results)
7 * Fixed bug #1065321 (following:text() doesn't return results in doc order)
8+ * Fixed bug #1067706 (wrong const folding in mutually recursive udfs)
9 * Fixed bug #1021492 (while computeing the "sources" of a prolog var, skip
10 any var-setting exprs that appear in non-used (and non-optimized) functions).
11
12
13=== modified file 'src/compiler/expression/var_expr.cpp'
14--- src/compiler/expression/var_expr.cpp 2012-10-09 14:06:08 +0000
15+++ src/compiler/expression/var_expr.cpp 2012-10-20 07:27:24 +0000
16@@ -90,8 +90,6 @@
17 theHasInitializer(false)
18 {
19 compute_scripting_kind();
20-
21- setUnfoldable(ANNOTATION_TRUE_FIXED);
22 }
23
24
25
26=== modified file 'src/compiler/rewriter/framework/rule_driver.cpp'
27--- src/compiler/rewriter/framework/rule_driver.cpp 2012-09-19 21:16:15 +0000
28+++ src/compiler/rewriter/framework/rule_driver.cpp 2012-10-20 07:27:24 +0000
29@@ -20,6 +20,8 @@
30 #include "compiler/rewriter/rules/rule_base.h"
31 #include "compiler/rewriter/framework/rewriter_context.h"
32
33+#include "functions/udf.h"
34+
35 #include "system/properties.h"
36
37
38@@ -60,9 +62,14 @@
39 bool rule_modified = false;
40 expr* newRoot = (*i)->apply(rCtx, &*rCtx.getRoot(), rule_modified);
41
42- if (newRoot != NULL)
43+ if (newRoot != NULL && newRoot != rCtx.theRoot)
44 {
45 rCtx.setRoot(newRoot);
46+ if (rCtx.theUDF != NULL)
47+ {
48+ rCtx.theUDF->setBody(newRoot);
49+ rCtx.theUDF->invalidatePlan();
50+ }
51 }
52
53 if (rule_modified)
54@@ -70,6 +77,11 @@
55 modified = true;
56 totalModified = true;
57
58+ if (rCtx.theUDF != NULL)
59+ {
60+ rCtx.theUDF->invalidatePlan();
61+ }
62+
63 if (Properties::instance()->printIntermediateOpt())
64 {
65 std::cout << rCtx.theMessage << std::endl
66@@ -99,10 +111,20 @@
67 if (newRoot != NULL)
68 {
69 rCtx.setRoot(newRoot);
70+ if (rCtx.theUDF != NULL)
71+ {
72+ rCtx.theUDF->setBody(newRoot);
73+ rCtx.theUDF->invalidatePlan();
74+ }
75 }
76
77 if (modified && Properties::instance()->printIntermediateOpt())
78 {
79+ if (rCtx.theUDF != NULL)
80+ {
81+ rCtx.theUDF->invalidatePlan();
82+ }
83+
84 std::cout << rCtx.theMessage << std::endl
85 << "After " << theRule->getRuleName() << " :" << std::endl;
86 rCtx.getRoot()->put(std::cout) << std::endl;
87
88=== modified file 'src/compiler/rewriter/framework/rule_driver.h'
89--- src/compiler/rewriter/framework/rule_driver.h 2012-09-19 21:16:15 +0000
90+++ src/compiler/rewriter/framework/rule_driver.h 2012-10-20 07:27:24 +0000
91@@ -84,7 +84,7 @@
92 ********************************************************************************/
93 class RuleOnceDriverBase : public Rewriter
94 {
95-private:
96+protected:
97 rule_ptr_t theRule;
98
99 public:
100@@ -99,6 +99,8 @@
101 {
102 public:
103 RuleOnceDriver() : RuleOnceDriverBase(rule_ptr_t(new R)) {}
104+
105+ R* getRule() const { return static_cast<R*>(theRule.getp()); }
106 };
107
108
109
110=== modified file 'src/compiler/rewriter/rewriters/default_optimizer.cpp'
111--- src/compiler/rewriter/rewriters/default_optimizer.cpp 2012-10-08 12:09:36 +0000
112+++ src/compiler/rewriter/rewriters/default_optimizer.cpp 2012-10-20 07:27:24 +0000
113@@ -88,6 +88,13 @@
114 if (driverPathSimplify.rewrite(rCtx))
115 modified = true;
116
117+ if (rCtx.theUDF != NULL)
118+ {
119+ RuleOnceDriver<MarkExprs> driverMarkLocalExprs;
120+ driverMarkLocalExprs.getRule()->setLocal(true);
121+ driverMarkLocalExprs.rewrite(rCtx);
122+ }
123+
124 repeat1:
125
126 // TypeRules
127
128=== modified file 'src/compiler/rewriter/rules/fold_rules.cpp'
129--- src/compiler/rewriter/rules/fold_rules.cpp 2012-10-10 13:05:50 +0000
130+++ src/compiler/rewriter/rules/fold_rules.cpp 2012-10-20 07:27:24 +0000
131@@ -171,8 +171,8 @@
132 BoolAnnotationValue saveUnfoldable = node->getUnfoldable();
133 BoolAnnotationValue saveContainsRecursiveCall = node->getContainsRecursiveCall();
134
135- // By default, an expr is discardable, foldable, and does not contain
136- // recursive calls
137+ // By default, an expr is discardable, foldable, does not contain recursive
138+ // calls, and returns constructed nodes.
139 BoolAnnotationValue curNonDiscardable = ANNOTATION_FALSE;
140 BoolAnnotationValue curUnfoldable = ANNOTATION_FALSE;
141 BoolAnnotationValue curContainsRecursiveCall = ANNOTATION_FALSE;
142@@ -185,12 +185,14 @@
143 fo_expr* fo = static_cast<fo_expr *>(node);
144 function* f = fo->get_func();
145
146- if (f->isUdf())
147+ if (f->isUdf() && !theIsLocal)
148 {
149 user_function* udf = static_cast<user_function*>(f);
150
151 if (!udf->isOptimized())
152 {
153+ // we can be here in case of mutually recursive udfs or during plan
154+ // serialization and udf was not callable by the main program
155 udf->optimize();
156 }
157
158@@ -283,17 +285,24 @@
159 fo_expr* fo = static_cast<fo_expr *>(node);
160 function* f = fo->get_func();
161
162- bool isErrorFunc = (dynamic_cast<const fn_error*>(f) != NULL);
163+ if (f->isUdf() && theIsLocal)
164+ {
165+ curUnfoldable = saveUnfoldable;
166+ }
167+ else
168+ {
169+ bool isErrorFunc = (dynamic_cast<const fn_error*>(f) != NULL);
170
171- // Do not fold functions that always require access to the dynamic context,
172- // or may need to access the implicit timezone (which is also in the dynamic
173- // constext).
174- if (isErrorFunc ||
175- f->accessesDynCtx() ||
176- maybe_needs_implicit_timezone(fo) ||
177- !f->isDeterministic())
178- {
179- curUnfoldable = ANNOTATION_TRUE_FIXED;
180+ // Do not fold functions that always require access to the dynamic context,
181+ // or may need to access the implicit timezone (which is also in the dynamic
182+ // constext).
183+ if (isErrorFunc ||
184+ f->accessesDynCtx() ||
185+ maybe_needs_implicit_timezone(fo) ||
186+ !f->isDeterministic())
187+ {
188+ curUnfoldable = ANNOTATION_TRUE_FIXED;
189+ }
190 }
191
192 break;
193@@ -560,6 +569,7 @@
194 return NULL;
195 }
196
197+
198 RULE_REWRITE_POST(FoldConst)
199 {
200 return NULL;
201@@ -647,28 +657,38 @@
202 xqtref_t argType = arg->get_return_type();
203 xqtref_t targetType = cbe->get_target_type();
204
205- if (TypeOps::is_subtype(tm, *argType, *targetType, node->get_loc()))
206- {
207- return rCtx.theEM->create_const_expr(sctx, udf, LOC(node), true);
208- }
209- else if (node->get_expr_kind() == instanceof_expr_kind)
210- {
211- instanceof_expr* ioExpr = static_cast<instanceof_expr*>(node);
212-
213- if (ioExpr->getCheckPrimeOnly())
214- {
215- argType = TypeOps::prime_type(tm, *argType);
216- targetType = TypeOps::prime_type(tm, *targetType);
217- }
218-
219- return (TypeOps::intersect_type(*argType, *targetType, tm) ==
220- GENV_TYPESYSTEM.NONE_TYPE ?
221- rCtx.theEM->create_const_expr(sctx, udf, LOC(node), false) :
222- NULL);
223- }
224- else
225- {
226- return NULL;
227+ try
228+ {
229+ if (TypeOps::is_subtype(tm, *argType, *targetType, node->get_loc()))
230+ {
231+ return rCtx.theEM->create_const_expr(sctx, udf, LOC(node), true);
232+ }
233+ else if (node->get_expr_kind() == instanceof_expr_kind)
234+ {
235+ instanceof_expr* ioExpr = static_cast<instanceof_expr*>(node);
236+
237+ if (ioExpr->getCheckPrimeOnly())
238+ {
239+ argType = TypeOps::prime_type(tm, *argType);
240+ targetType = TypeOps::prime_type(tm, *targetType);
241+ }
242+
243+ return (TypeOps::intersect_type(*argType, *targetType, tm) ==
244+ GENV_TYPESYSTEM.NONE_TYPE ?
245+ rCtx.theEM->create_const_expr(sctx, udf, LOC(node), false) :
246+ NULL);
247+ }
248+ else
249+ {
250+ return NULL;
251+ }
252+ }
253+ catch (XQueryException& e)
254+ {
255+ if (e.diagnostic() == err::XPTY0004)
256+ return NULL;
257+
258+ throw;
259 }
260 }
261
262
263=== modified file 'src/compiler/rewriter/rules/ruleset.h'
264--- src/compiler/rewriter/rules/ruleset.h 2012-10-12 09:05:54 +0000
265+++ src/compiler/rewriter/rules/ruleset.h 2012-10-20 07:27:24 +0000
266@@ -84,8 +84,18 @@
267 ********************************************************************************/
268 class MarkExprs : public RewriteRule
269 {
270+protected:
271+ bool theIsLocal;
272+
273 public:
274- MarkExprs() : RewriteRule(RewriteRule::MarkExprs, "MarkExprs") {}
275+ MarkExprs(bool local = false)
276+ :
277+ RewriteRule(RewriteRule::MarkExprs, "MarkExprs"),
278+ theIsLocal(local)
279+ {
280+ }
281+
282+ void setLocal(bool v) { theIsLocal = v; }
283
284 expr* apply(RewriterContext& rCtx, expr* node, bool& modified);
285 };
286
287=== modified file 'src/compiler/rewriter/tools/udf_graph.cpp'
288--- src/compiler/rewriter/tools/udf_graph.cpp 2012-09-19 21:16:15 +0000
289+++ src/compiler/rewriter/tools/udf_graph.cpp 2012-10-20 07:27:24 +0000
290@@ -274,7 +274,7 @@
291
292 bool deterministic = true;
293
294- for (ulong i = 0; i < node->theChildren.size(); ++i)
295+ for (csize i = 0; i < node->theChildren.size(); ++i)
296 {
297 if (inferDeterminism(node->theChildren[i], visit) == false)
298 deterministic = false;
299@@ -330,7 +330,7 @@
300
301 o << inc_indent;
302
303- for (ulong i = 0; i < node->theChildren.size(); ++i)
304+ for (csize i = 0; i < node->theChildren.size(); ++i)
305 {
306 display(o, node->theChildren[i]);
307 }
308
309=== modified file 'src/compiler/rewriter/tools/udf_graph.h'
310--- src/compiler/rewriter/tools/udf_graph.h 2012-09-19 21:16:15 +0000
311+++ src/compiler/rewriter/tools/udf_graph.h 2012-10-20 07:27:24 +0000
312@@ -116,8 +116,6 @@
313
314 ~UDFGraph();
315
316- void build(const expr* e);
317-
318 void optimizeUDFs(CompilerCB* ccb);
319
320 void inferDeterminism();
321@@ -125,6 +123,8 @@
322 void display(std::ostream& o);
323
324 protected:
325+ void build(const expr* e);
326+
327 void build(const expr* curExpr, std::vector<user_function*>& callChain);
328
329 void addEdge(user_function* caller, user_function* callee);
330
331=== modified file 'src/context/dynamic_context.h'
332--- src/context/dynamic_context.h 2012-10-08 12:09:36 +0000
333+++ src/context/dynamic_context.h 2012-10-20 07:27:24 +0000
334@@ -55,7 +55,13 @@
335
336 public:
337
338- static enum ID_VARS { IDVAR_CONTEXT_ITEM=1, IDVAR_CONTEXT_ITEM_POSITION, IDVAR_CONTEXT_ITEM_SIZE, MAX_IDVARS_RESERVED } IDVARS_RESERVED;
339+ static enum ID_VARS
340+ {
341+ IDVAR_CONTEXT_ITEM=1,
342+ IDVAR_CONTEXT_ITEM_POSITION,
343+ IDVAR_CONTEXT_ITEM_SIZE,
344+ MAX_IDVARS_RESERVED
345+ } IDVARS_RESERVED;
346
347 struct VarValue
348 {
349@@ -69,8 +75,8 @@
350
351 union
352 {
353- store::Item* item;
354- store::TempSeq* temp_seq;
355+ store::Item * item;
356+ store::TempSeq * temp_seq;
357 } theValue;
358
359 ValueState theState;
360@@ -102,8 +108,8 @@
361 ext_func_param_typed
362 } val_type_t;
363
364- val_type_t type;
365- void* func_param;
366+ val_type_t type;
367+ void * func_param;
368 };
369
370 ZSTRING_HASH_MAP(dctx_value_t, ValueMap);
371@@ -116,6 +122,7 @@
372 dynamic_context * theParent;
373
374 store::Item_t theCurrentDateTime;
375+
376 long theTimezone;
377
378 store::Item_t theDefaultCollectionUri;
379@@ -128,7 +135,7 @@
380
381 IndexMap * theAvailableMaps;
382
383- //MODIFY
384+ //MODIFY
385 EnvVarMap * theEnvironmentVariables;
386
387 public:
388
389=== modified file 'src/functions/udf.cpp'
390--- src/functions/udf.cpp 2012-10-12 09:05:54 +0000
391+++ src/functions/udf.cpp 2012-10-20 07:27:24 +0000
392@@ -297,7 +297,8 @@
393 ********************************************************************************/
394 bool user_function::isRecursive() const
395 {
396- assert(isOptimized());
397+ // recursiveness is established before any optimization is done
398+ // assert(isOptimized());
399 assert(theBodyExpr != NULL);
400 return !theMutuallyRecursiveUDFs.empty();
401 }
402@@ -308,7 +309,8 @@
403 ********************************************************************************/
404 bool user_function::isMutuallyRecursiveWith(const user_function* udf)
405 {
406- assert(isOptimized());
407+ // recursiveness is established before any optimization is done
408+ // assert(isOptimized());
409 assert(theBodyExpr != NULL);
410
411 if (std::find(theMutuallyRecursiveUDFs.begin(),
412@@ -332,6 +334,9 @@
413 assert(isOptimized());
414 }
415
416+ if (theBodyExpr != NULL)
417+ return theBodyExpr->isUnfoldable();
418+
419 return testFlag(FunctionConsts::AccessesDynCtx);
420 }
421
422
423=== modified file 'src/runtime/core/fncall_iterator.cpp'
424--- src/runtime/core/fncall_iterator.cpp 2012-09-19 21:16:15 +0000
425+++ src/runtime/core/fncall_iterator.cpp 2012-10-20 07:27:24 +0000
426@@ -448,31 +448,34 @@
427
428 for (size_t i = 0; i < argsRefs.size(); ++i)
429 {
430- const ArgVarRefs& argVarRefs = argsRefs[i];
431- store::Iterator_t argWrapper;
432- if (state->theCache)
433- {
434- std::vector<store::Item_t> lParam(1, lKey[i]);
435- state->theArgValues.push_back(GENV_STORE.createTempSeq(lParam));
436- argWrapper = state->theArgValues.back()->getIterator();
437- argWrapper->open();
438- }
439- else
440- {
441- argWrapper = argWraps[i];
442- }
443-
444- ArgVarRefs::const_iterator argVarRefsIte = argVarRefs.begin();
445- ArgVarRefs::const_iterator argVarRefsEnd = argVarRefs.end();
446-
447- for (; argVarRefsIte != argVarRefsEnd; ++argVarRefsIte)
448- {
449- const LetVarIter_t& argRef = (*argVarRefsIte);
450- assert(argRef != NULL);
451-
452- if (argRef != NULL)
453- {
454- argRef->bind(argWrapper, *state->thePlanState);
455+ if (argWraps[i] != NULL)
456+ {
457+ const ArgVarRefs& argVarRefs = argsRefs[i];
458+ store::Iterator_t argWrapper;
459+ if (state->theCache)
460+ {
461+ std::vector<store::Item_t> lParam(1, lKey[i]);
462+ state->theArgValues.push_back(GENV_STORE.createTempSeq(lParam));
463+ argWrapper = state->theArgValues.back()->getIterator();
464+ argWrapper->open();
465+ }
466+ else
467+ {
468+ argWrapper = argWraps[i];
469+ }
470+
471+ ArgVarRefs::const_iterator argVarRefsIte = argVarRefs.begin();
472+ ArgVarRefs::const_iterator argVarRefsEnd = argVarRefs.end();
473+
474+ for (; argVarRefsIte != argVarRefsEnd; ++argVarRefsIte)
475+ {
476+ const LetVarIter_t& argRef = (*argVarRefsIte);
477+ assert(argRef != NULL);
478+
479+ if (argRef != NULL)
480+ {
481+ argRef->bind(argWrapper, *state->thePlanState);
482+ }
483 }
484 }
485 }
486
487=== removed file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/udf/udf-fib-rec.iter'
488--- test/rbkt/ExpCompilerResults/IterPlan/zorba/udf/udf-fib-rec.iter 2012-09-19 21:16:15 +0000
489+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/udf/udf-fib-rec.iter 1970-01-01 00:00:00 +0000
490@@ -1,42 +0,0 @@
491-Iterator tree for main query:
492-<UDFunctionCallIterator cached="true">
493- <SingletonIterator value="xs:integer(100)"/>
494-</UDFunctionCallIterator>
495-
496-Iterator tree for local:fib:
497-<flwor::FLWORIterator>
498- <ForVariable name="n">
499- <LetVarIterator varname="n"/>
500- </ForVariable>
501- <ReturnClause>
502- <IfThenElseIterator>
503- <TypedValueCompareIterator_INTEGER>
504- <ForVarIterator varname="n"/>
505- <SingletonIterator value="xs:integer(0)"/>
506- </TypedValueCompareIterator_INTEGER>
507- <SingletonIterator value="xs:integer(0)"/>
508- <IfThenElseIterator>
509- <TypedValueCompareIterator_INTEGER>
510- <ForVarIterator varname="n"/>
511- <SingletonIterator value="xs:integer(1)"/>
512- </TypedValueCompareIterator_INTEGER>
513- <SingletonIterator value="xs:integer(1)"/>
514- <SpecificNumArithIterator_AddOperation_INTEGER>
515- <UDFunctionCallIterator cached="true">
516- <SpecificNumArithIterator_SubtractOperation_INTEGER>
517- <ForVarIterator varname="n"/>
518- <SingletonIterator value="xs:integer(1)"/>
519- </SpecificNumArithIterator_SubtractOperation_INTEGER>
520- </UDFunctionCallIterator>
521- <UDFunctionCallIterator cached="true">
522- <SpecificNumArithIterator_SubtractOperation_INTEGER>
523- <ForVarIterator varname="n"/>
524- <SingletonIterator value="xs:integer(2)"/>
525- </SpecificNumArithIterator_SubtractOperation_INTEGER>
526- </UDFunctionCallIterator>
527- </SpecificNumArithIterator_AddOperation_INTEGER>
528- </IfThenElseIterator>
529- </IfThenElseIterator>
530- </ReturnClause>
531-</flwor::FLWORIterator>
532-
533
534=== added file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/udf/udf-fib-rec2.iter'
535--- test/rbkt/ExpCompilerResults/IterPlan/zorba/udf/udf-fib-rec2.iter 1970-01-01 00:00:00 +0000
536+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/udf/udf-fib-rec2.iter 2012-10-20 07:27:24 +0000
537@@ -0,0 +1,45 @@
538+Iterator tree for const-folded expr:
539+<UDFunctionCallIterator cached="true">
540+ <SingletonIterator value="xs:integer(10)"/>
541+</UDFunctionCallIterator>
542+
543+Iterator tree for local:fib:
544+<flwor::FLWORIterator>
545+ <ForVariable name="n">
546+ <LetVarIterator varname="n"/>
547+ </ForVariable>
548+ <ReturnClause>
549+ <IfThenElseIterator>
550+ <TypedValueCompareIterator_INTEGER>
551+ <ForVarIterator varname="n"/>
552+ <SingletonIterator value="xs:integer(0)"/>
553+ </TypedValueCompareIterator_INTEGER>
554+ <SingletonIterator value="xs:integer(0)"/>
555+ <IfThenElseIterator>
556+ <TypedValueCompareIterator_INTEGER>
557+ <ForVarIterator varname="n"/>
558+ <SingletonIterator value="xs:integer(1)"/>
559+ </TypedValueCompareIterator_INTEGER>
560+ <SingletonIterator value="xs:integer(1)"/>
561+ <SpecificNumArithIterator_AddOperation_INTEGER>
562+ <UDFunctionCallIterator cached="true">
563+ <SpecificNumArithIterator_SubtractOperation_INTEGER>
564+ <ForVarIterator varname="n"/>
565+ <SingletonIterator value="xs:integer(1)"/>
566+ </SpecificNumArithIterator_SubtractOperation_INTEGER>
567+ </UDFunctionCallIterator>
568+ <UDFunctionCallIterator cached="true">
569+ <SpecificNumArithIterator_SubtractOperation_INTEGER>
570+ <ForVarIterator varname="n"/>
571+ <SingletonIterator value="xs:integer(2)"/>
572+ </SpecificNumArithIterator_SubtractOperation_INTEGER>
573+ </UDFunctionCallIterator>
574+ </SpecificNumArithIterator_AddOperation_INTEGER>
575+ </IfThenElseIterator>
576+ </IfThenElseIterator>
577+ </ReturnClause>
578+</flwor::FLWORIterator>
579+
580+Iterator tree for main query:
581+<SingletonIterator value="xs:integer(55)"/>
582+
583
584=== added file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/udf/udf-recursive-1.iter'
585--- test/rbkt/ExpCompilerResults/IterPlan/zorba/udf/udf-recursive-1.iter 1970-01-01 00:00:00 +0000
586+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/udf/udf-recursive-1.iter 2012-10-20 07:27:24 +0000
587@@ -0,0 +1,68 @@
588+Iterator tree for const-folded expr:
589+<UDFunctionCallIterator cached="true">
590+ <SingletonIterator value="xs:integer(4)"/>
591+</UDFunctionCallIterator>
592+
593+Iterator tree for local:get-request-id2:
594+<flwor::FLWORIterator>
595+ <LetVariable name="p" materialize="true">
596+ <LetVarIterator varname="p"/>
597+ </LetVariable>
598+ <ReturnClause>
599+ <UDFunctionCallIterator cached="true">
600+ <SingletonIterator value="xs:integer(4)"/>
601+ </UDFunctionCallIterator>
602+ </ReturnClause>
603+</flwor::FLWORIterator>
604+
605+Iterator tree for local:get-request-id1:
606+<PromoteIterator type="xs:string">
607+ <flwor::FLWORIterator>
608+ <LetVariable name="p" materialize="true">
609+ <LetVarIterator varname="p"/>
610+ </LetVariable>
611+ <ReturnClause>
612+ <flwor::FLWORIterator>
613+ <ForVariable name="i">
614+ <OpToIterator>
615+ <SingletonIterator value="xs:integer(1)"/>
616+ <SingletonIterator value="xs:integer(3)"/>
617+ </OpToIterator>
618+ </ForVariable>
619+ <ReturnClause>
620+ <UDFunctionCallIterator cached="true">
621+ <SingletonIterator value="xs:integer(4)"/>
622+ </UDFunctionCallIterator>
623+ </ReturnClause>
624+ </flwor::FLWORIterator>
625+ </ReturnClause>
626+ </flwor::FLWORIterator>
627+</PromoteIterator>
628+
629+Iterator tree for main query:
630+<UDFunctionCallIterator cached="true">
631+ <SingletonIterator value="xs:integer(1)"/>
632+</UDFunctionCallIterator>
633+
634+Iterator tree for local:get-request-id1:
635+<PromoteIterator type="xs:string">
636+ <flwor::FLWORIterator>
637+ <ForVariable name="i">
638+ <OpToIterator>
639+ <SingletonIterator value="xs:integer(1)"/>
640+ <SingletonIterator value="xs:integer(3)"/>
641+ </OpToIterator>
642+ </ForVariable>
643+ <ReturnClause>
644+ <UDFunctionCallIterator cached="true">
645+ <SingletonIterator value="xs:integer(4)"/>
646+ </UDFunctionCallIterator>
647+ </ReturnClause>
648+ </flwor::FLWORIterator>
649+</PromoteIterator>
650+
651+Iterator tree for local:get-request-id2:
652+<UDFunctionCallIterator cached="true">
653+ <SingletonIterator value="xs:integer(4)"/>
654+</UDFunctionCallIterator>
655+
656
657=== added file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/udf/udf-recursive-2.iter'
658--- test/rbkt/ExpCompilerResults/IterPlan/zorba/udf/udf-recursive-2.iter 1970-01-01 00:00:00 +0000
659+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/udf/udf-recursive-2.iter 2012-10-20 07:27:24 +0000
660@@ -0,0 +1,49 @@
661+Iterator tree for const-folded expr:
662+<UDFunctionCallIterator>
663+ <FnConcatIterator/>
664+</UDFunctionCallIterator>
665+
666+Iterator tree for local:recursion:
667+<flwor::FLWORIterator>
668+ <LetVariable name="param" materialize="true">
669+ <LetVarIterator varname="param"/>
670+ </LetVariable>
671+ <ReturnClause>
672+ <IfThenElseIterator>
673+ <FnBooleanIterator>
674+ <LetVarIterator varname="param"/>
675+ </FnBooleanIterator>
676+ <UDFunctionCallIterator>
677+ <FnConcatIterator/>
678+ </UDFunctionCallIterator>
679+ <SingletonIterator value="xs:boolean(false)"/>
680+ </IfThenElseIterator>
681+ </ReturnClause>
682+</flwor::FLWORIterator>
683+
684+Iterator tree for const-folded expr:
685+<SingletonIterator value="xs:boolean(false)"/>
686+
687+Iterator tree for main query:
688+<UDFunctionCallIterator>
689+ <TreatIterator type="[NodeXQType elementNode content=[UserDefinedXQType Content@http://foo.com/schemas/schema isComplex emptyContent base:[XQType ANY_TYPE_KIND*] ]]" quant="?">
690+ <ValidateIterator>
691+ <ElementIterator>
692+ <SingletonIterator value="xs:QName(http://foo.com/schemas/schema,d,Content)"/>
693+ <AttributeIterator qname="xs:QName(,,id)">
694+ <SingletonIterator value="xs:string(foo)"/>
695+ </AttributeIterator>
696+ </ElementIterator>
697+ </ValidateIterator>
698+ </TreatIterator>
699+</UDFunctionCallIterator>
700+
701+Iterator tree for local:recursion:
702+<IfThenElseIterator>
703+ <FnBooleanIterator>
704+ <LetVarIterator varname="param"/>
705+ </FnBooleanIterator>
706+ <SingletonIterator value="xs:boolean(false)"/>
707+ <SingletonIterator value="xs:boolean(false)"/>
708+</IfThenElseIterator>
709+
710
711=== added file 'test/rbkt/ExpQueryResults/zorba/optim/no_folding_01.xml.res'
712--- test/rbkt/ExpQueryResults/zorba/optim/no_folding_01.xml.res 1970-01-01 00:00:00 +0000
713+++ test/rbkt/ExpQueryResults/zorba/optim/no_folding_01.xml.res 2012-10-20 07:27:24 +0000
714@@ -0,0 +1,1 @@
715+1
716
717=== added file 'test/rbkt/ExpQueryResults/zorba/udf/udf-fib-rec2.xml.res'
718--- test/rbkt/ExpQueryResults/zorba/udf/udf-fib-rec2.xml.res 1970-01-01 00:00:00 +0000
719+++ test/rbkt/ExpQueryResults/zorba/udf/udf-fib-rec2.xml.res 2012-10-20 07:27:24 +0000
720@@ -0,0 +1,1 @@
721+55
722
723=== added file 'test/rbkt/Queries/zorba/optim/no_folding_01.xq'
724--- test/rbkt/Queries/zorba/optim/no_folding_01.xq 1970-01-01 00:00:00 +0000
725+++ test/rbkt/Queries/zorba/optim/no_folding_01.xq 2012-10-20 07:27:24 +0000
726@@ -0,0 +1,22 @@
727+
728+
729+declare variable $g := 1;
730+
731+
732+declare function local:boo()
733+{
734+ local:foo(0)
735+};
736+
737+
738+declare function local:foo($x) as xs:integer
739+{
740+ if ($x > 0)
741+ then
742+ local:boo()
743+ else
744+ $g
745+};
746+
747+
748+local:boo()
749
750=== modified file 'test/rbkt/Queries/zorba/reference/reference_5.xq'
751--- test/rbkt/Queries/zorba/reference/reference_5.xq 2012-09-19 21:16:15 +0000
752+++ test/rbkt/Queries/zorba/reference/reference_5.xq 2012-10-20 07:27:24 +0000
753@@ -8,22 +8,35 @@
754
755
756 <result>
757-<temporary-variable-in-scope>{let $temp:=<root>temp</root> return id:node-by-reference(id:node-reference($temp))}</temporary-variable-in-scope>
758-<temporary-variable-in-scope>{
759-let $temp:=<root>temp</root>
760-return
761-let $ref:=id:node-reference($temp)
762-return
763-id:node-by-reference($ref)
764-}</temporary-variable-in-scope>
765-<temporary-variable-in-scope>{
766-for $i in (1 to 3)
767-let $temp:=<root>temp</root>
768-let $ref:=id:node-reference($temp)
769-return
770-id:node-by-reference($ref)
771-}</temporary-variable-in-scope>
772-
773-<temporary-variable-in-scope>{let $temp:=<root>temp</root> return id:node-by-reference(id:node-reference($temp))}</temporary-variable-in-scope>
774+
775+<temporary-variable-in-scope>
776+{
777+ let $temp:=<root>temp</root> return id:node-by-reference(id:node-reference($temp))
778+}
779+</temporary-variable-in-scope>
780+
781+<temporary-variable-in-scope>
782+{
783+ let $temp:=<root>temp</root>
784+ return
785+ let $ref:=id:node-reference($temp)
786+ return id:node-by-reference($ref)
787+}
788+</temporary-variable-in-scope>
789+
790+<temporary-variable-in-scope>
791+{
792+ for $i in (1 to 3)
793+ let $temp := <root>temp</root>
794+ let $ref := id:node-reference($temp)
795+ return id:node-by-reference($ref)
796+}
797+</temporary-variable-in-scope>
798+
799+<temporary-variable-in-scope>
800+{
801+ let $temp:=<root>temp</root> return id:node-by-reference(id:node-reference($temp))
802+}
803+</temporary-variable-in-scope>
804
805 </result>
806
807=== added file 'test/rbkt/Queries/zorba/udf/udf-fib-rec2.xq'
808--- test/rbkt/Queries/zorba/udf/udf-fib-rec2.xq 1970-01-01 00:00:00 +0000
809+++ test/rbkt/Queries/zorba/udf/udf-fib-rec2.xq 2012-10-20 07:27:24 +0000
810@@ -0,0 +1,8 @@
811+declare function local:fib($n as xs:integer) as xs:integer
812+{
813+ if ($n eq 0) then 0
814+ else if ($n eq 1) then 1
815+ else local:fib($n - 1) + local:fib($n - 2)
816+};
817+
818+local:fib(10)

Subscribers

People subscribed via source and target branches