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

Proposed by Markos Zaharioudakis
Status: Merged
Approved by: Markos Zaharioudakis
Approved revision: 11035
Merged at revision: 11038
Proposed branch: lp:~zorba-coders/zorba/bug-1047538
Merge into: lp:zorba
Diff against target: 489 lines (+196/-89)
10 files modified
ChangeLog (+3/-0)
src/api/serialization/serializer.cpp (+24/-11)
src/compiler/rewriter/tools/dataflow_annotations.cpp (+12/-1)
src/diagnostics/diagnostic_en.xml (+4/-0)
src/diagnostics/pregenerated/dict_en.cpp (+1/-0)
src/functions/func_jsoniq_functions_impl.cpp (+0/-19)
src/functions/pregenerated/func_jsoniq_functions.h (+1/-1)
src/runtime/function_item/dynamic_fncall_iterator.cpp (+146/-53)
src/runtime/function_item/dynamic_fncall_iterator.h (+4/-3)
src/runtime/spec/json/jsoniq_functions.xml (+1/-1)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug-1047538
Reviewer Review Type Date Requested Status
Markos Zaharioudakis Approve
Review via email: mp+124076@code.launchpad.net

Commit message

Fixed bug #1047538 (jsoniq: SourceFinder::findLocalNodeSources missing json expressions)
Fixed bug #1043976 (compiler warning in serialiser code)

Description of the change

Fixed bug #1047538 (jsoniq: SourceFinder::findLocalNodeSources missing json expressions)
Fixed bug #1043976 (compiler warning in serialiser code)

To post a comment you must log in.
lp:~zorba-coders/zorba/bug-1047538 updated
11035. 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-1047538-2012-09-12T22-53-38.078Z 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-12 08:06:26 +0000
3+++ ChangeLog 2012-09-12 22:39:18 +0000
4@@ -35,8 +35,11 @@
5 * Fixed bug #1039488 (inserting more than one pair at once in a JSON object)
6 * Fixed bug #1042840 (qname pool free-list corruption)
7 * Fixed bug #866984 (better error message for an eval error)
8+ * Fixed bug #1047538 (jsoniq: SourceFinder::findLocalNodeSources missing
9+ json expressions)
10 * Fixed bug #932884 (HTML and XHTML serialization of empty elements)
11 * Fixed bug #1045902 (file:last-modified returns current date time)
12+ * Fixed bug #1043976 (compiler warning in serialiser code)
13
14
15 version 2.6
16
17=== modified file 'src/api/serialization/serializer.cpp'
18--- src/api/serialization/serializer.cpp 2012-09-12 08:06:26 +0000
19+++ src/api/serialization/serializer.cpp 2012-09-12 22:39:18 +0000
20@@ -587,8 +587,8 @@
21 }
22 default:
23 {
24- ZORBA_ASSERT(false);
25- tr << "node of type: " << item->getNodeKind();
26+ int k = static_cast<int>(item->getNodeKind());
27+ ZORBA_ASSERT_WITH_MSG(false, BUILD_STRING("node of type: ", k));
28 }
29 }
30 }
31@@ -1475,11 +1475,16 @@
32 {
33 const store::Item* element_parent = item->getParent();
34
35- if( item->getNodeKind() == store::StoreConsts::documentNode)
36+ store::NodeKind kind = item->getNodeKind();
37+
38+ switch (kind)
39+ {
40+ case store::StoreConsts::documentNode:
41 {
42 emit_node_children(item, depth);
43+ break;
44 }
45- else if (item->getNodeKind() == store::StoreConsts::elementNode)
46+ case store::StoreConsts::elementNode:
47 {
48 store::Item* qnameItem = item->getNodeName();
49
50@@ -1568,8 +1573,10 @@
51 }
52
53 previous_item = PREVIOUS_ITEM_WAS_NODE;
54+
55+ break;
56 }
57- else if (item->getNodeKind() == store::StoreConsts::attributeNode)
58+ case store::StoreConsts::attributeNode:
59 {
60 // The HTML output method MUST output boolean attributes (that is attributes
61 // with only a single allowed value that is equal to the name of the
62@@ -1593,8 +1600,10 @@
63 }
64
65 previous_item = PREVIOUS_ITEM_WAS_NODE;
66+
67+ break;
68 }
69- else if (item->getNodeKind() == store::StoreConsts::textNode)
70+ case store::StoreConsts::textNode:
71 {
72 bool expand = true;
73
74@@ -1623,23 +1632,27 @@
75 }
76
77 previous_item = PREVIOUS_ITEM_WAS_TEXT;
78+ break;
79 }
80- else if (item->getNodeKind() == store::StoreConsts::commentNode)
81+ case store::StoreConsts::commentNode:
82 {
83 tr << "<!--" << item->getStringValue() << "-->";
84
85 previous_item = PREVIOUS_ITEM_WAS_NODE;
86+ break;
87 }
88- else if (item->getNodeKind() == store::StoreConsts::piNode )
89+ case store::StoreConsts::piNode:
90 {
91 tr << "<?" << item->getTarget() << " " << item->getStringValue() << "?>";
92
93 previous_item = PREVIOUS_ITEM_WAS_NODE;
94+ break;
95 }
96- else
97+ default:
98 {
99- tr << "node of type: " << item->getNodeKind();
100- assert(0);
101+ int k = static_cast<int>(kind);
102+ ZORBA_ASSERT_WITH_MSG(false, BUILD_STRING("node of type: ", k));
103+ }
104 }
105 }
106
107
108=== modified file 'src/compiler/rewriter/tools/dataflow_annotations.cpp'
109--- src/compiler/rewriter/tools/dataflow_annotations.cpp 2012-09-10 22:53:04 +0000
110+++ src/compiler/rewriter/tools/dataflow_annotations.cpp 2012-09-12 22:39:18 +0000
111@@ -1311,7 +1311,7 @@
112
113
114 /*******************************************************************************
115-
116+ This method is called when we serialize a udf, if the query has an eval expr.
117 ********************************************************************************/
118 void SourceFinder::findLocalNodeSources(
119 expr* node,
120@@ -1494,6 +1494,17 @@
121 return;
122 }
123
124+#ifdef ZORBA_WITH_JSON
125+ case json_direct_object_expr_kind:
126+ case json_object_expr_kind:
127+ case json_array_expr_kind:
128+ {
129+ // TODO? We need to drill inside a json pair or array constructor only
130+ // if we are coming from an unbox or flatten call ????
131+ break;
132+ }
133+#endif
134+
135 case relpath_expr_kind:
136 {
137 relpath_expr* e = static_cast<relpath_expr *>(node);
138
139=== modified file 'src/diagnostics/diagnostic_en.xml'
140--- src/diagnostics/diagnostic_en.xml 2012-09-12 13:32:10 +0000
141+++ src/diagnostics/diagnostic_en.xml 2012-09-12 22:39:18 +0000
142@@ -180,6 +180,10 @@
143 <value>the first parameter to the format-number() function is of type $2, which is not allowed</value>
144 </entry>
145
146+ <entry key="JSONIQ_SELECTOR">
147+ <value>Cannot atomize and/or cast value of type $2 to a string.</value>
148+ </entry>
149+
150 </diagnostic>
151
152 <diagnostic code="XPTY0018">
153
154=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
155--- src/diagnostics/pregenerated/dict_en.cpp 2012-09-12 13:32:10 +0000
156+++ src/diagnostics/pregenerated/dict_en.cpp 2012-09-12 22:39:18 +0000
157@@ -872,6 +872,7 @@
158 { "~XPTY0004_FormatNumber_2", "the first parameter to the format-number() function is of type $2, which is not allowed" },
159 { "~XPTY0004_FuncParam", "$2 can not be promoted to parameter type $3 of function $4()" },
160 { "~XPTY0004_FuncReturn", "$2 can not be promoted to return type $3 of function $4()" },
161+ { "~XPTY0004_JSONIQ_SELECTOR", "Cannot atomize and/or cast value of type $2 to a string." },
162 { "~XPTY0004_NoMultiSeqTypePromotion", "sequence of more than one item can not be promoted to type $2" },
163 { "~XPTY0004_TypeMatch", "$2 can not be treated as type $3" },
164 { "~XPTY0004_TypePromotion", "$2 can not be promoted to type $3" },
165
166=== modified file 'src/functions/func_jsoniq_functions_impl.cpp'
167--- src/functions/func_jsoniq_functions_impl.cpp 2012-09-11 15:53:52 +0000
168+++ src/functions/func_jsoniq_functions_impl.cpp 2012-09-12 22:39:18 +0000
169@@ -134,24 +134,6 @@
170 }
171
172
173-#if 1
174-/*******************************************************************************
175-
176-********************************************************************************/
177-bool op_zorba_json_box::mustCopyInputNodes(expr* fo, csize producer) const
178-{
179- static_context* sctx = fo->get_sctx();
180-
181- if (sctx->preserve_mode() != StaticContextConsts::no_preserve_ns ||
182- sctx->construction_mode() != StaticContextConsts::cons_preserve)
183- {
184- return true;
185- }
186-
187- return false;
188-}
189-
190-
191 /*******************************************************************************
192
193 ********************************************************************************/
194@@ -167,7 +149,6 @@
195
196 return theSignature.returnType();
197 }
198-#endif
199
200
201 /*******************************************************************************
202
203=== modified file 'src/functions/pregenerated/func_jsoniq_functions.h'
204--- src/functions/pregenerated/func_jsoniq_functions.h 2012-09-11 15:53:52 +0000
205+++ src/functions/pregenerated/func_jsoniq_functions.h 2012-09-12 22:39:18 +0000
206@@ -357,7 +357,7 @@
207
208 bool propagatesInputNodes(expr* fo, csize producer) const { return true; }
209
210- bool mustCopyInputNodes(expr* fo, csize producer) const;
211+ bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
212
213 CODEGEN_DECL();
214 };
215
216=== modified file 'src/runtime/function_item/dynamic_fncall_iterator.cpp'
217--- src/runtime/function_item/dynamic_fncall_iterator.cpp 2012-09-10 22:53:04 +0000
218+++ src/runtime/function_item/dynamic_fncall_iterator.cpp 2012-09-12 22:39:18 +0000
219@@ -29,6 +29,7 @@
220 #include "store/api/item_factory.h"
221
222 #include "types/root_typemanager.h"
223+#include "types/casting.h"
224
225 #include "system/globalenv.h"
226
227@@ -141,20 +142,29 @@
228 PlanState& planState) const
229 {
230 store::Item_t item;
231- store::Item_t funcItem;
232+ store::Item_t targetItem;
233+#if 0
234+ store::Item_t selectorItem1;
235+ store::Item_t selectorItem2;
236+ store::Item_t selectorItem3;
237+ bool isObjectNav;
238+ bool selectorError;
239+#endif
240 FunctionItem* fnItem;
241 std::vector<PlanIter_t> argIters;
242 std::vector<PlanIter_t>::iterator ite;
243 std::vector<PlanIter_t>::const_iterator ite2;
244 std::vector<PlanIter_t>::const_iterator end2;
245
246+ TypeManager* tm = theSctx->get_typemanager();
247+
248 DynamicFnCallIteratorState* state;
249
250 DEFAULT_STACK_INIT(DynamicFnCallIteratorState, state, planState);
251
252 // first child must return exactly one item which is a function item
253 // otherwise XPTY0004 is raised
254- if (!consumeNext(funcItem, theChildren[0], planState))
255+ if (!consumeNext(targetItem, theChildren[0], planState))
256 {
257 RAISE_ERROR(err::XPTY0004, loc,
258 ERROR_PARAMS(ZED(XPTY0004_TypePromotion),
259@@ -162,17 +172,140 @@
260 GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_ONE->toSchemaString()));
261 }
262
263- if (consumeNext(item, theChildren[0], planState))
264- {
265- RAISE_ERROR(err::XPTY0004, loc,
266- ERROR_PARAMS(ZED(XPTY0004_NoMultiSeqTypePromotion),
267- GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_ONE->toSchemaString()));
268- }
269-
270- if (!funcItem->isFunction())
271- {
272- const TypeManager* tm = theSctx->get_typemanager();
273- xqtref_t type = tm->create_value_type(funcItem);
274+ if (targetItem->isFunction())
275+ {
276+ if (consumeNext(item, theChildren[0], planState))
277+ {
278+ RAISE_ERROR(err::XPTY0004, loc,
279+ ERROR_PARAMS(ZED(XPTY0004_NoMultiSeqTypePromotion),
280+ GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_ONE->toSchemaString()));
281+ }
282+
283+ fnItem = static_cast<FunctionItem*>(targetItem.getp());
284+
285+ argIters.resize(theChildren.size() - 1 + fnItem->getVariables().size());
286+
287+ ite = argIters.begin();
288+
289+ ite2 = theChildren.begin();
290+ end2 = theChildren.end();
291+ ++ite2;
292+
293+ for (; ite2 != end2; ++ite2, ++ite)
294+ {
295+ *ite = *ite2;
296+ }
297+
298+ ite2 = fnItem->getVariables().begin();
299+ end2 = fnItem->getVariables().end();
300+
301+ for(; ite2 != end2; ++ite2, ++ite)
302+ {
303+ *ite = *ite2;
304+ }
305+
306+ state->thePlan = fnItem->getImplementation(argIters);
307+
308+ // must be opened after vars and params are set
309+ state->thePlan->open(planState, state->theUDFStateOffset);
310+ state->theIsOpen = true;
311+
312+ while(consumeNext(result, state->thePlan, planState))
313+ {
314+ STACK_PUSH(true, state);
315+ }
316+
317+ // need to close here early in case the plan is completely
318+ // consumed. Otherwise, the plan would still be opened
319+ // if destroyed from the state's destructor.
320+ state->thePlan->close(planState);
321+ state->theIsOpen = false;
322+ }
323+#if 0 //def ZORBA_WITH_JSON
324+ else if (targetItem->isJSONObject() || targetItem->isJSONArray())
325+ {
326+ if (theChildren.size() != 2)
327+ {
328+ RAISE_ERROR_NO_PARAMS(jerr::JNTY0018, loc);
329+ }
330+
331+ isObjectNav = targetItem->isJSONObject();
332+ selectorError = false;
333+
334+ if (!consumeNext(selectorItem1, theChildren[1], planState))
335+ {
336+ selectorError = true;
337+ }
338+ else
339+ {
340+ try
341+ {
342+ if (selectorItem1->isNode())
343+ {
344+ store::Iterator_t iter;
345+
346+ selectorItem1->getTypedValue(selectorItem2, iter);
347+
348+ if (iter != NULL)
349+ {
350+ if (!iter->next(selectorItem2) || iter->next(item))
351+ {
352+ selectorError = true;
353+ }
354+ }
355+ }
356+ else
357+ {
358+ selectorItem2.transfer(selectorItem1);
359+ }
360+
361+ if (!selectorError)
362+ {
363+ if (!selectorItem2->isAtomic())
364+ {
365+ selectorError = true;
366+ }
367+ else
368+ {
369+ store::SchemaTypeCode selectorType =
370+ (isObjectNav ? store::XS_STRING : store::XS_INTEGER);
371+
372+ selectorError = ! GenericCast::castToAtomic(selectorItem3,
373+ selectorItem2,
374+ selectorType,
375+ tm,
376+ NULL,
377+ loc);
378+ }
379+ }
380+ }
381+ catch (...)
382+ {
383+ selectorError = true;
384+ }
385+ }
386+
387+ if (selectorError)
388+ {
389+ item = (selectorItem1 == NULL ? selectorItem2 : selectorItem1);
390+
391+ zstring selectorType = tm->create_value_type(item)->toSchemaString();
392+
393+ RAISE_ERROR(err::XPTY0004, loc,
394+ ERROR_PARAMS(ZED(XPTY0004_JSONIQ_SELECTOR), selectorType));
395+ }
396+
397+ if (isObjectNav)
398+ result = targetItem->getObjectValue(selectorItem3);
399+ else
400+ result = targetItem->getArrayValue(selectorItem3->getIntegerValue());
401+
402+ STACK_PUSH(true, state);
403+ }
404+#endif
405+ else
406+ {
407+ xqtref_t type = tm->create_value_type(targetItem);
408
409 RAISE_ERROR(err::XPTY0004, loc,
410 ERROR_PARAMS(ZED(XPTY0004_TypePromotion),
411@@ -180,46 +313,6 @@
412 GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_ONE->toSchemaString()));
413 }
414
415- fnItem = static_cast<FunctionItem*>(funcItem.getp());
416-
417- argIters.resize(theChildren.size() - 1 + fnItem->getVariables().size());
418-
419- ite = argIters.begin();
420-
421- ite2 = theChildren.begin();
422- end2 = theChildren.end();
423- ++ite2;
424-
425- for (; ite2 != end2; ++ite2, ++ite)
426- {
427- *ite = *ite2;
428- }
429-
430- ite2 = fnItem->getVariables().begin();
431- end2 = fnItem->getVariables().end();
432-
433- for(; ite2 != end2; ++ite2, ++ite)
434- {
435- *ite = *ite2;
436- }
437-
438- state->thePlan = fnItem->getImplementation(argIters);
439-
440- // must be opened after vars and params are set
441- state->thePlan->open(planState, state->theUDFStateOffset);
442- state->theIsOpen = true;
443-
444- while(consumeNext(result, state->thePlan, planState))
445- {
446- STACK_PUSH(true, state);
447- }
448-
449- // need to close here early in case the plan is completely
450- // consumed. Otherwise, the plan would still be opened
451- // if destroyed from the state's destructor.
452- state->thePlan->close(planState);
453- state->theIsOpen = false;
454-
455 STACK_END(state);
456 };
457
458
459=== modified file 'src/runtime/function_item/dynamic_fncall_iterator.h'
460--- src/runtime/function_item/dynamic_fncall_iterator.h 2012-09-10 22:53:04 +0000
461+++ src/runtime/function_item/dynamic_fncall_iterator.h 2012-09-12 22:39:18 +0000
462@@ -65,10 +65,11 @@
463 (NaryBaseIterator<DynamicFnCallIterator, DynamicFnCallIteratorState>*)this);
464 }
465
466+public:
467 DynamicFnCallIterator(
468- static_context* sctx,
469- const QueryLoc& loc,
470- std::vector<PlanIter_t>& args)
471+ static_context* sctx,
472+ const QueryLoc& loc,
473+ std::vector<PlanIter_t>& args)
474 :
475 NaryBaseIterator<DynamicFnCallIterator, DynamicFnCallIteratorState>(sctx, loc, args)
476 {
477
478=== modified file 'src/runtime/spec/json/jsoniq_functions.xml'
479--- src/runtime/spec/json/jsoniq_functions.xml 2012-09-11 16:33:21 +0000
480+++ src/runtime/spec/json/jsoniq_functions.xml 2012-09-12 22:39:18 +0000
481@@ -503,7 +503,7 @@
482 <zorba:getReturnType/>
483 <zorba:accessesDynCtx returnValue="true"/>
484 <zorba:propagatesInputNodes value="true"/>
485- <zorba:mustCopyInputNodes/>
486+ <zorba:mustCopyInputNodes value="false"/>
487 </zorba:methods>
488
489 </zorba:function>

Subscribers

People subscribed via source and target branches