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

Proposed by Markos Zaharioudakis
Status: Merged
Approved by: Markos Zaharioudakis
Approved revision: 10868
Merged at revision: 10872
Proposed branch: lp:~zorba-coders/zorba/bug-960083
Merge into: lp:zorba
Diff against target: 984 lines (+425/-410)
4 files modified
src/runtime/booleans/BooleanImpl.cpp (+36/-38)
src/runtime/indexing/index_ddl.cpp (+386/-372)
test/rbkt/ExpQueryResults/zorba/numerics/comp01.xml.res (+2/-0)
test/rbkt/Queries/zorba/numerics/comp01.xq (+1/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug-960083
Reviewer Review Type Date Requested Status
Markos Zaharioudakis Approve
Review via email: mp+108326@code.launchpad.net

Commit message

fixed bug 960083$ (improper error handling of NaN comparisons) + small optimization of comparison operations

Description of the change

fixed bug 960083$ (improper error handling of NaN comparisons) + small optimization of comparison operations

To post a comment you must log in.
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/bug-960083 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 bug-960083-2012-06-01T12-24-03.535Z is finished. The
  final status was:

  1 tests did not succeed - changes not commited.

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

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-960083-2012-06-01T13-46-04.963Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 2 Pending.

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-960083-2012-06-14T10-19-56.929Z 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 'src/runtime/booleans/BooleanImpl.cpp'
2--- src/runtime/booleans/BooleanImpl.cpp 2012-05-03 12:31:51 +0000
3+++ src/runtime/booleans/BooleanImpl.cpp 2012-06-01 12:05:28 +0000
4@@ -443,11 +443,8 @@
5 theCollation)),
6 state);
7
8- if (consumeNext(item0, theChild0.getp(), planState) ||
9- consumeNext(item1, theChild1.getp(), planState))
10- {
11- RAISE_ERROR(err::XPTY0004, loc, ERROR_PARAMS(ZED(NoSeqInValueComp)));
12- }
13+ assert(!consumeNext(item0, theChild0.getp(), planState) &&
14+ !consumeNext(item1, theChild1.getp(), planState));
15 }
16 }
17
18@@ -501,10 +498,11 @@
19 }
20 }
21 }
22- catch (ZorbaException const& e)
23+ catch (const ZorbaException& e)
24 {
25 if (e.diagnostic() == zerr::ZSTR0041_NAN_COMPARISON)
26 return false;
27+
28 throw;
29 }
30 }
31@@ -665,7 +663,7 @@
32 }
33 }
34 }
35- catch (ZorbaException const& e)
36+ catch (const ZorbaException& e)
37 {
38 if (e.diagnostic() == zerr::ZSTR0041_NAN_COMPARISON)
39 return false;
40@@ -943,7 +941,7 @@
41 }
42 }
43 }
44- catch(ZorbaException const& e)
45+ catch(const ZorbaException& e)
46 {
47 // For example, two QName items do not have an order relationship.
48 if (e.diagnostic() == zerr::ZSTR0040_TYPE_ERROR)
49@@ -954,6 +952,7 @@
50 RAISE_ERROR(err::XPTY0004, loc,
51 ERROR_PARAMS(ZED(BadType_23o), *type0, ZED(NoCompareWithType_4), *type1));
52 }
53+
54 throw;
55 }
56 }
57@@ -1001,7 +1000,6 @@
58 store::Item_t lItem0, lItem1;
59 bool bRes;
60 bool neq = false;
61- bool nonempty = false;
62 long cmp;
63
64 PlanIteratorState* state;
65@@ -1009,8 +1007,6 @@
66
67 if (CONSUME(lItem0, 0) && CONSUME(lItem1, 1))
68 {
69- nonempty = true;
70-
71 switch (theCompType)
72 {
73 case CompareConsts::VALUE_NOT_EQUAL:
74@@ -1027,39 +1023,41 @@
75
76 default:
77 {
78- cmp = lItem0->compare(lItem1, theTimezone, theCollation);
79+ try
80+ {
81+ cmp = lItem0->compare(lItem1, theTimezone, theCollation);
82
83- switch (theCompType)
84+ switch (theCompType)
85+ {
86+ case CompareConsts::VALUE_LESS:
87+ bRes = (cmp < 0);
88+ break;
89+ case CompareConsts::VALUE_GREATER:
90+ bRes = (cmp > 0);
91+ break;
92+ case CompareConsts::VALUE_LESS_EQUAL:
93+ bRes = (cmp <= 0);
94+ break;
95+ case CompareConsts::VALUE_GREATER_EQUAL:
96+ bRes = (cmp >= 0);
97+ break;
98+ default:
99+ ZORBA_ASSERT(false);
100+ } // switch (theCompType)
101+ }
102+ catch (const ZorbaException& e)
103 {
104- case CompareConsts::VALUE_LESS:
105- bRes = (cmp < 0);
106- break;
107- case CompareConsts::VALUE_GREATER:
108- bRes = (cmp > 0);
109- break;
110- case CompareConsts::VALUE_LESS_EQUAL:
111- bRes = (cmp <= 0);
112- break;
113- case CompareConsts::VALUE_GREATER_EQUAL:
114- bRes = (cmp >= 0);
115- break;
116- default:
117- ZORBA_ASSERT(false);
118- } // switch (theCompType)
119+ if (e.diagnostic() == zerr::ZSTR0041_NAN_COMPARISON)
120+ bRes = false;
121+ else
122+ throw;
123+ }
124 } // default
125 } // switch (theCompType)
126
127- if (nonempty)
128- STACK_PUSH(GENV_ITEMFACTORY->createBoolean(result, bRes), state);
129+ STACK_PUSH(GENV_ITEMFACTORY->createBoolean(result, bRes), state);
130
131- if (CONSUME(lItem0, 0) || CONSUME(lItem1, 1))
132- {
133- throw XQUERY_EXCEPTION(
134- err::XPTY0004,
135- ERROR_PARAMS( ZED( NoSeqInValueComp ) ),
136- ERROR_LOC( this->loc )
137- );
138- }
139+ assert(!CONSUME(lItem0, 0) && !CONSUME(lItem1, 1));
140 }
141
142 STACK_END(state);
143
144=== modified file 'src/runtime/indexing/index_ddl.cpp'
145--- src/runtime/indexing/index_ddl.cpp 2012-05-11 22:49:47 +0000
146+++ src/runtime/indexing/index_ddl.cpp 2012-06-01 12:05:28 +0000
147@@ -713,9 +713,9 @@
148
149 STACK_END(state);
150 }
151- catch (XQueryException& e)
152+ catch (ZorbaException& e)
153 {
154- set_source( e, loc, false );
155+ set_source(e, loc, false);
156 throw;
157 }
158 }
159@@ -822,12 +822,10 @@
160 numChildren != 2)
161 {
162 RAISE_ERROR(zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS, loc,
163- ERROR_PARAMS(
164- qnameItem->getStringValue(),
165- "index",
166- numChildren-1,
167- state->theIndexDecl->getKeyExpressions().size())
168- );
169+ ERROR_PARAMS(qnameItem->getStringValue(),
170+ "index",
171+ numChildren-1,
172+ state->theIndexDecl->getKeyExpressions().size()));
173 }
174
175 state->theIndex = (state->theIndexDecl->isTemp() ?
176@@ -877,9 +875,9 @@
177
178 STACK_END(state);
179 }
180- catch (XQueryException& e)
181+ catch (ZorbaException& e)
182 {
183- set_source( e, loc, false );
184+ set_source(e, loc, false);
185 throw;
186 }
187 }
188@@ -995,168 +993,176 @@
189 bool status;
190 TypeManager* tm = theSctx->get_typemanager();
191 RootTypeManager& rtm = GENV_TYPESYSTEM;
192-
193- ProbeIndexRangeValueIteratorState* state;
194- DEFAULT_STACK_INIT(ProbeIndexRangeValueIteratorState, state, planState);
195-
196- status = consumeNext(qname, theChildren[0], planState);
197- ZORBA_ASSERT(status);
198-
199- if (state->theQname == NULL || !state->theQname->equals(qname))
200- {
201- state->theQname = qname;
202-
203- if ((indexDecl = theSctx->lookup_index(qname)) == NULL)
204- {
205- RAISE_ERROR(zerr::ZDDY0021_INDEX_NOT_DECLARED, loc,
206- ERROR_PARAMS(qname->getStringValue()));
207- }
208-
209- if (indexDecl->getMethod() != IndexDecl::TREE)
210- {
211- RAISE_ERROR(zerr::ZDDY0026_INDEX_RANGE_PROBE_NOT_ALLOWED, loc,
212- ERROR_PARAMS(qname->getStringValue()));
213- }
214-
215- if (numChildren < 7 || (numChildren-1) % 6 != 0)
216- {
217- RAISE_ERROR(zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS, loc,
218- ERROR_PARAMS(qname->getStringValue(),
219- "index",
220- numChildren-1,
221- "multiple of 6"));
222- }
223-
224- if (indexDecl->getKeyExpressions().size() * 6 < numChildren-1)
225- {
226- RAISE_ERROR(zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS, loc,
227- ERROR_PARAMS(qname->getStringValue(),
228- "index",
229- numChildren-1,
230- indexDecl->getKeyExpressions().size() * 6));
231- }
232-
233- state->theIndex = (indexDecl->isTemp() ?
234- planState.theLocalDynCtx->getIndex(qname) :
235- GENV_STORE.getIndex(state->theQname));
236-
237- if (state->theIndex == NULL)
238- {
239- RAISE_ERROR(zerr::ZDDY0023_INDEX_DOES_NOT_EXIST, loc,
240- ERROR_PARAMS(qname->getStringValue()));
241- }
242-
243- state->theIterator = GENV_STORE.getIteratorFactory()->
244- createIndexProbeIterator(state->theIndex);
245- }
246-
247- cond = state->theIndex->createCondition(store::IndexCondition::BOX_VALUE);
248-
249- ulong keyNo;
250- ulong i;
251- for (i = 1, keyNo = 0; i < numChildren; i += 6, ++keyNo)
252- {
253- store::Item_t tempLeft;
254- store::Item_t tempRight;
255- store::Item_t tempHaveLeft;
256- store::Item_t tempHaveRight;
257- store::Item_t tempInclLeft;
258- store::Item_t tempInclRight;
259-
260- if (!consumeNext(tempLeft, theChildren[i], planState))
261- tempLeft = NULL;
262-
263- if (!consumeNext(tempRight, theChildren[i + 1], planState))
264- tempRight = NULL;
265-
266- if (!consumeNext(tempHaveLeft, theChildren[i + 2], planState))
267- ZORBA_ASSERT(false);
268-
269- if (!consumeNext(tempHaveRight, theChildren[i + 3], planState))
270- ZORBA_ASSERT(false);
271-
272- if (!consumeNext(tempInclLeft, theChildren[i + 4], planState))
273- ZORBA_ASSERT(false);
274-
275- if (!consumeNext(tempInclRight, theChildren[i + 5], planState))
276- ZORBA_ASSERT(false);
277-
278- bool haveLeft = tempHaveLeft->getBooleanValue();
279- bool haveRight = tempHaveRight->getBooleanValue();
280- bool inclLeft = tempInclLeft->getBooleanValue();
281- bool inclRight = tempInclRight->getBooleanValue();
282-
283- if (tempLeft != NULL && theCheckKeyType)
284- {
285- checkKeyType(loc, theSctx->get_typemanager(), indexDecl, keyNo, tempLeft);
286- }
287-
288- if (tempRight != NULL && theCheckKeyType)
289- {
290- checkKeyType(loc, theSctx->get_typemanager(), indexDecl, keyNo, tempRight);
291- }
292-
293- if (indexDecl->isGeneral() &&
294- (indexDecl->getKeyTypes())[keyNo] == NULL)
295- {
296- xqtref_t leftType;
297- xqtref_t rightType;
298-
299- if (tempLeft != NULL)
300- {
301- leftType = tm->create_value_type(tempLeft);
302-
303- if (TypeOps::is_equal(tm, *leftType, *rtm.UNTYPED_ATOMIC_TYPE_ONE))
304- {
305- zstring str = tempLeft->getStringValue();
306- GENV_ITEMFACTORY->createString(tempLeft, str);
307- leftType = rtm.STRING_TYPE_ONE;
308- }
309- }
310-
311- if (tempRight != NULL)
312- {
313- rightType = tm->create_value_type(tempRight);
314-
315- if (TypeOps::is_equal(tm, *rightType, *rtm.UNTYPED_ATOMIC_TYPE_ONE))
316- {
317- zstring str = tempRight->getStringValue();
318- GENV_ITEMFACTORY->createString(tempRight, str);
319- rightType = rtm.STRING_TYPE_ONE;
320- }
321- }
322-
323- if (leftType != NULL && rightType != NULL)
324- {
325- if (!TypeOps::is_subtype(tm, *leftType, *rightType) &&
326- !TypeOps::is_subtype(tm, *rightType, *leftType))
327- {
328- RAISE_ERROR(zerr::ZDDY0034_INDEX_RANGE_VALUE_PROBE_BAD_KEY_TYPES, loc,
329- ERROR_PARAMS(qname->getStringValue()));
330- }
331- }
332- }
333-
334- cond->pushRange(tempLeft, tempRight, haveLeft, haveRight, inclLeft, inclRight);
335- }
336-
337- state->theIterator->init(cond);
338- if (!theCountOnly)
339- {
340- state->theIterator->open();
341-
342- while(state->theIterator->next(result))
343- {
344+
345+ try
346+ {
347+ ProbeIndexRangeValueIteratorState* state;
348+ DEFAULT_STACK_INIT(ProbeIndexRangeValueIteratorState, state, planState);
349+
350+ status = consumeNext(qname, theChildren[0], planState);
351+ ZORBA_ASSERT(status);
352+
353+ if (state->theQname == NULL || !state->theQname->equals(qname))
354+ {
355+ state->theQname = qname;
356+
357+ if ((indexDecl = theSctx->lookup_index(qname)) == NULL)
358+ {
359+ RAISE_ERROR(zerr::ZDDY0021_INDEX_NOT_DECLARED, loc,
360+ ERROR_PARAMS(qname->getStringValue()));
361+ }
362+
363+ if (indexDecl->getMethod() != IndexDecl::TREE)
364+ {
365+ RAISE_ERROR(zerr::ZDDY0026_INDEX_RANGE_PROBE_NOT_ALLOWED, loc,
366+ ERROR_PARAMS(qname->getStringValue()));
367+ }
368+
369+ if (numChildren < 7 || (numChildren-1) % 6 != 0)
370+ {
371+ RAISE_ERROR(zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS, loc,
372+ ERROR_PARAMS(qname->getStringValue(),
373+ "index",
374+ numChildren-1,
375+ "multiple of 6"));
376+ }
377+
378+ if (indexDecl->getKeyExpressions().size() * 6 < numChildren-1)
379+ {
380+ RAISE_ERROR(zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS, loc,
381+ ERROR_PARAMS(qname->getStringValue(),
382+ "index",
383+ numChildren-1,
384+ indexDecl->getKeyExpressions().size() * 6));
385+ }
386+
387+ state->theIndex = (indexDecl->isTemp() ?
388+ planState.theLocalDynCtx->getIndex(qname) :
389+ GENV_STORE.getIndex(state->theQname));
390+
391+ if (state->theIndex == NULL)
392+ {
393+ RAISE_ERROR(zerr::ZDDY0023_INDEX_DOES_NOT_EXIST, loc,
394+ ERROR_PARAMS(qname->getStringValue()));
395+ }
396+
397+ state->theIterator = GENV_STORE.getIteratorFactory()->
398+ createIndexProbeIterator(state->theIndex);
399+ }
400+
401+ cond = state->theIndex->createCondition(store::IndexCondition::BOX_VALUE);
402+
403+ ulong keyNo;
404+ ulong i;
405+ for (i = 1, keyNo = 0; i < numChildren; i += 6, ++keyNo)
406+ {
407+ store::Item_t tempLeft;
408+ store::Item_t tempRight;
409+ store::Item_t tempHaveLeft;
410+ store::Item_t tempHaveRight;
411+ store::Item_t tempInclLeft;
412+ store::Item_t tempInclRight;
413+
414+ if (!consumeNext(tempLeft, theChildren[i], planState))
415+ tempLeft = NULL;
416+
417+ if (!consumeNext(tempRight, theChildren[i + 1], planState))
418+ tempRight = NULL;
419+
420+ if (!consumeNext(tempHaveLeft, theChildren[i + 2], planState))
421+ ZORBA_ASSERT(false);
422+
423+ if (!consumeNext(tempHaveRight, theChildren[i + 3], planState))
424+ ZORBA_ASSERT(false);
425+
426+ if (!consumeNext(tempInclLeft, theChildren[i + 4], planState))
427+ ZORBA_ASSERT(false);
428+
429+ if (!consumeNext(tempInclRight, theChildren[i + 5], planState))
430+ ZORBA_ASSERT(false);
431+
432+ bool haveLeft = tempHaveLeft->getBooleanValue();
433+ bool haveRight = tempHaveRight->getBooleanValue();
434+ bool inclLeft = tempInclLeft->getBooleanValue();
435+ bool inclRight = tempInclRight->getBooleanValue();
436+
437+ if (tempLeft != NULL && theCheckKeyType)
438+ {
439+ checkKeyType(loc, theSctx->get_typemanager(), indexDecl, keyNo, tempLeft);
440+ }
441+
442+ if (tempRight != NULL && theCheckKeyType)
443+ {
444+ checkKeyType(loc, theSctx->get_typemanager(), indexDecl, keyNo, tempRight);
445+ }
446+
447+ if (indexDecl->isGeneral() &&
448+ (indexDecl->getKeyTypes())[keyNo] == NULL)
449+ {
450+ xqtref_t leftType;
451+ xqtref_t rightType;
452+
453+ if (tempLeft != NULL)
454+ {
455+ leftType = tm->create_value_type(tempLeft);
456+
457+ if (TypeOps::is_equal(tm, *leftType, *rtm.UNTYPED_ATOMIC_TYPE_ONE))
458+ {
459+ zstring str = tempLeft->getStringValue();
460+ GENV_ITEMFACTORY->createString(tempLeft, str);
461+ leftType = rtm.STRING_TYPE_ONE;
462+ }
463+ }
464+
465+ if (tempRight != NULL)
466+ {
467+ rightType = tm->create_value_type(tempRight);
468+
469+ if (TypeOps::is_equal(tm, *rightType, *rtm.UNTYPED_ATOMIC_TYPE_ONE))
470+ {
471+ zstring str = tempRight->getStringValue();
472+ GENV_ITEMFACTORY->createString(tempRight, str);
473+ rightType = rtm.STRING_TYPE_ONE;
474+ }
475+ }
476+
477+ if (leftType != NULL && rightType != NULL)
478+ {
479+ if (!TypeOps::is_subtype(tm, *leftType, *rightType) &&
480+ !TypeOps::is_subtype(tm, *rightType, *leftType))
481+ {
482+ RAISE_ERROR(zerr::ZDDY0034_INDEX_RANGE_VALUE_PROBE_BAD_KEY_TYPES, loc,
483+ ERROR_PARAMS(qname->getStringValue()));
484+ }
485+ }
486+ }
487+
488+ cond->pushRange(tempLeft, tempRight, haveLeft, haveRight, inclLeft, inclRight);
489+ }
490+
491+ state->theIterator->init(cond);
492+ if (!theCountOnly)
493+ {
494+ state->theIterator->open();
495+
496+ while(state->theIterator->next(result))
497+ {
498+ STACK_PUSH(true, state);
499+ }
500+ }
501+ else
502+ {
503+ state->theIterator->count(result);
504 STACK_PUSH(true, state);
505 }
506+
507+ STACK_END(state);
508 }
509- else
510+ catch (ZorbaException& e)
511 {
512- state->theIterator->count(result);
513- STACK_PUSH(true, state);
514+ set_source(e, loc, false);
515+ throw;
516 }
517-
518- STACK_END(state);
519 }
520
521
522@@ -1267,202 +1273,228 @@
523
524 TypeManager* tm = theSctx->get_typemanager();
525
526- ProbeIndexRangeGeneralIteratorState* state;
527- DEFAULT_STACK_INIT(ProbeIndexRangeGeneralIteratorState, state, planState);
528-
529- status = consumeNext(qname, theChildren[0], planState);
530- ZORBA_ASSERT(status);
531-
532- if (state->theQname == NULL || !state->theQname->equals(qname))
533- {
534- state->theQname = qname;
535-
536- if ((indexDecl = theSctx->lookup_index(qname)) == NULL)
537- {
538- RAISE_ERROR(zerr::ZDDY0021_INDEX_NOT_DECLARED, loc,
539- ERROR_PARAMS(qname->getStringValue()));
540- }
541-
542- if (indexDecl->getMethod() != IndexDecl::TREE)
543- {
544- RAISE_ERROR(zerr::ZDDY0030_INDEX_RANGE_GENERAL_PROBE_NOT_ALLOWED, loc,
545- ERROR_PARAMS(qname->getStringValue()));
546- }
547-
548- if (!indexDecl->isGeneral())
549- {
550- RAISE_ERROR(zerr::ZDDY0030_INDEX_RANGE_GENERAL_PROBE_NOT_ALLOWED, loc,
551- ERROR_PARAMS(qname->getStringValue()));
552- }
553-
554- state->theIndex = (indexDecl->isTemp() ?
555- planState.theLocalDynCtx->getIndex(qname) :
556- GENV_STORE.getIndex(state->theQname));
557-
558- if (state->theIndex == NULL)
559- {
560- RAISE_ERROR(zerr::ZDDY0023_INDEX_DOES_NOT_EXIST, loc,
561- ERROR_PARAMS(qname->getStringValue()));
562- }
563-
564- state->theIterator = GENV_STORE.getIteratorFactory()->
565- createIndexProbeIterator(state->theIndex);
566-
567- state->theTimezone = state->theIndex->getSpecification().getTimezone();
568- state->theCollator = state->theIndex->getCollator(0);
569-
570- xqtref_t keyType = indexDecl->getKeyTypes()[0];
571-
572- assert(keyType == NULL ||
573- keyType->get_quantifier() == TypeConstants::QUANT_ONE);
574-
575- if (keyType != NULL &&
576- !TypeOps::is_subtype(tm, *keyType, *GENV_TYPESYSTEM.UNTYPED_ATOMIC_TYPE_ONE) &&
577- !TypeOps::is_equal(tm, *keyType, *GENV_TYPESYSTEM.ANY_ATOMIC_TYPE_ONE))
578- {
579- state->theKeyType = keyType;
580- }
581- }
582-
583- {
584- store::Item_t itemHaveLower;
585- store::Item_t itemHaveUpper;
586- store::Item_t itemInclLower;
587- store::Item_t itemInclUpper;
588-
589- // Get the values of $haveLowerBound, $haveUpperBound, $lowerBoundIncluded,
590- // and $upperBoundIncluded params
591- if (!consumeNext(itemHaveLower, theChildren[3], planState))
592- ZORBA_ASSERT(false);
593-
594- if (!consumeNext(itemHaveUpper, theChildren[4], planState))
595- ZORBA_ASSERT(false);
596-
597- if (!consumeNext(itemInclLower, theChildren[5], planState))
598- ZORBA_ASSERT(false);
599-
600- if (!consumeNext(itemInclUpper, theChildren[6], planState))
601- ZORBA_ASSERT(false);
602-
603- haveLower = itemHaveLower->getBooleanValue();
604- haveUpper = itemHaveUpper->getBooleanValue();
605- inclLower = itemInclLower->getBooleanValue();
606- inclUpper = itemInclUpper->getBooleanValue();
607- }
608-
609- cond = state->theIndex->createCondition(store::IndexCondition::BOX_GENERAL);
610-
611- if (haveLower && haveUpper)
612- {
613- //
614- // Build hashmap from the nodes satisfying the lower bound condition
615- //
616-
617- if (!getSearchItems(planState, state, true, false, inclLower, false))
618- goto done;
619-
620- assert(state->theSearchItems.size() >= 1);
621- assert(state->theKeyType == NULL || state->theSearchItems.size() == 1);
622-
623- state->theNodeHashSet = new ItemHandleHashSet(1024, false);
624-
625- state->theSearchItemsIte = state->theSearchItems.begin();
626- state->theSearchItemsEnd = state->theSearchItems.end();
627-
628- for (;
629- state->theSearchItemsIte != state->theSearchItemsEnd;
630- ++state->theSearchItemsIte)
631- {
632- cond->clear();
633- cond->pushBound(*state->theSearchItemsIte, true, inclLower);
634-
635- state->theIterator->init(cond);
636- state->theIterator->open();
637-
638- while(state->theIterator->next(result))
639- {
640- state->theNodeHashSet->insert(result.getp());
641- }
642-
643- state->theIterator->close();
644- }
645-
646- state->theSearchItems.clear();
647- cond->clear();
648-
649- //
650- // Compute the nodes satisfying the upper bound condition and probe the
651- // node hashmap.
652- //
653-
654- if (!getSearchItems(planState, state, false, true, false, inclUpper))
655- goto done;
656-
657- assert(state->theSearchItems.size() >= 1);
658- assert(state->theKeyType == NULL || state->theSearchItems.size() == 1);
659-
660- state->theSearchItemsIte = state->theSearchItems.begin();
661- state->theSearchItemsEnd = state->theSearchItems.end();
662-
663- for (;
664- state->theSearchItemsIte != state->theSearchItemsEnd;
665- ++state->theSearchItemsIte)
666- {
667- cond->clear();
668- cond->pushBound(*state->theSearchItemsIte, false, inclUpper);
669-
670- state->theIterator->init(cond);
671-
672- if (!theCountOnly)
673- {
674+ try
675+ {
676+ ProbeIndexRangeGeneralIteratorState* state;
677+ DEFAULT_STACK_INIT(ProbeIndexRangeGeneralIteratorState, state, planState);
678+
679+ status = consumeNext(qname, theChildren[0], planState);
680+ ZORBA_ASSERT(status);
681+
682+ if (state->theQname == NULL || !state->theQname->equals(qname))
683+ {
684+ state->theQname = qname;
685+
686+ if ((indexDecl = theSctx->lookup_index(qname)) == NULL)
687+ {
688+ RAISE_ERROR(zerr::ZDDY0021_INDEX_NOT_DECLARED, loc,
689+ ERROR_PARAMS(qname->getStringValue()));
690+ }
691+
692+ if (indexDecl->getMethod() != IndexDecl::TREE)
693+ {
694+ RAISE_ERROR(zerr::ZDDY0030_INDEX_RANGE_GENERAL_PROBE_NOT_ALLOWED, loc,
695+ ERROR_PARAMS(qname->getStringValue()));
696+ }
697+
698+ if (!indexDecl->isGeneral())
699+ {
700+ RAISE_ERROR(zerr::ZDDY0030_INDEX_RANGE_GENERAL_PROBE_NOT_ALLOWED, loc,
701+ ERROR_PARAMS(qname->getStringValue()));
702+ }
703+
704+ state->theIndex = (indexDecl->isTemp() ?
705+ planState.theLocalDynCtx->getIndex(qname) :
706+ GENV_STORE.getIndex(state->theQname));
707+
708+ if (state->theIndex == NULL)
709+ {
710+ RAISE_ERROR(zerr::ZDDY0023_INDEX_DOES_NOT_EXIST, loc,
711+ ERROR_PARAMS(qname->getStringValue()));
712+ }
713+
714+ state->theIterator = GENV_STORE.getIteratorFactory()->
715+ createIndexProbeIterator(state->theIndex);
716+
717+ state->theTimezone = state->theIndex->getSpecification().getTimezone();
718+ state->theCollator = state->theIndex->getCollator(0);
719+
720+ xqtref_t keyType = indexDecl->getKeyTypes()[0];
721+
722+ assert(keyType == NULL ||
723+ keyType->get_quantifier() == TypeConstants::QUANT_ONE);
724+
725+ if (keyType != NULL &&
726+ !TypeOps::is_subtype(tm, *keyType, *GENV_TYPESYSTEM.UNTYPED_ATOMIC_TYPE_ONE) &&
727+ !TypeOps::is_equal(tm, *keyType, *GENV_TYPESYSTEM.ANY_ATOMIC_TYPE_ONE))
728+ {
729+ state->theKeyType = keyType;
730+ }
731+ }
732+
733+ {
734+ store::Item_t itemHaveLower;
735+ store::Item_t itemHaveUpper;
736+ store::Item_t itemInclLower;
737+ store::Item_t itemInclUpper;
738+
739+ // Get the values of $haveLowerBound, $haveUpperBound, $lowerBoundIncluded,
740+ // and $upperBoundIncluded params
741+ if (!consumeNext(itemHaveLower, theChildren[3], planState))
742+ ZORBA_ASSERT(false);
743+
744+ if (!consumeNext(itemHaveUpper, theChildren[4], planState))
745+ ZORBA_ASSERT(false);
746+
747+ if (!consumeNext(itemInclLower, theChildren[5], planState))
748+ ZORBA_ASSERT(false);
749+
750+ if (!consumeNext(itemInclUpper, theChildren[6], planState))
751+ ZORBA_ASSERT(false);
752+
753+ haveLower = itemHaveLower->getBooleanValue();
754+ haveUpper = itemHaveUpper->getBooleanValue();
755+ inclLower = itemInclLower->getBooleanValue();
756+ inclUpper = itemInclUpper->getBooleanValue();
757+ }
758+
759+ cond = state->theIndex->createCondition(store::IndexCondition::BOX_GENERAL);
760+
761+ if (haveLower && haveUpper)
762+ {
763+ //
764+ // Build hashmap from the nodes satisfying the lower bound condition
765+ //
766+
767+ if (!getSearchItems(planState, state, true, false, inclLower, false))
768+ goto done;
769+
770+ assert(state->theSearchItems.size() >= 1);
771+ assert(state->theKeyType == NULL || state->theSearchItems.size() == 1);
772+
773+ state->theNodeHashSet = new ItemHandleHashSet(1024, false);
774+
775+ state->theSearchItemsIte = state->theSearchItems.begin();
776+ state->theSearchItemsEnd = state->theSearchItems.end();
777+
778+ for (;
779+ state->theSearchItemsIte != state->theSearchItemsEnd;
780+ ++state->theSearchItemsIte)
781+ {
782+ cond->clear();
783+ cond->pushBound(*state->theSearchItemsIte, true, inclLower);
784+
785+ state->theIterator->init(cond);
786 state->theIterator->open();
787-
788+
789 while(state->theIterator->next(result))
790 {
791- if (state->theNodeHashSet->exists(result))
792+ state->theNodeHashSet->insert(result.getp());
793+ }
794+
795+ state->theIterator->close();
796+ }
797+
798+ state->theSearchItems.clear();
799+ cond->clear();
800+
801+ //
802+ // Compute the nodes satisfying the upper bound condition and probe the
803+ // node hashmap.
804+ //
805+
806+ if (!getSearchItems(planState, state, false, true, false, inclUpper))
807+ goto done;
808+
809+ assert(state->theSearchItems.size() >= 1);
810+ assert(state->theKeyType == NULL || state->theSearchItems.size() == 1);
811+
812+ state->theSearchItemsIte = state->theSearchItems.begin();
813+ state->theSearchItemsEnd = state->theSearchItems.end();
814+
815+ for (;
816+ state->theSearchItemsIte != state->theSearchItemsEnd;
817+ ++state->theSearchItemsIte)
818+ {
819+ cond->clear();
820+ cond->pushBound(*state->theSearchItemsIte, false, inclUpper);
821+
822+ state->theIterator->init(cond);
823+
824+ if (!theCountOnly)
825+ {
826+ state->theIterator->open();
827+
828+ while(state->theIterator->next(result))
829+ {
830+ if (state->theNodeHashSet->exists(result))
831+ STACK_PUSH(true, state);
832+ }
833+
834+ state->theIterator->close();
835+ }
836+ else
837+ {
838+ state->theIterator->count(result);
839+ STACK_PUSH(true, state);
840+ }
841+ }
842+ }
843+
844+ else if (haveLower || haveUpper)
845+ {
846+ if (!getSearchItems(planState, state, haveLower, haveUpper, inclLower, inclUpper))
847+ goto done;
848+
849+ assert(state->theSearchItems.size() >= 1);
850+ assert(state->theKeyType == NULL || state->theSearchItems.size() == 1);
851+
852+ inclBound = (haveLower ? inclLower : inclUpper);
853+
854+ state->theSearchItemsIte = state->theSearchItems.begin();
855+ state->theSearchItemsEnd = state->theSearchItems.end();
856+
857+ for (;
858+ state->theSearchItemsIte != state->theSearchItemsEnd;
859+ ++state->theSearchItemsIte)
860+ {
861+ cond->clear();
862+ cond->pushBound(*state->theSearchItemsIte, haveLower, inclBound);
863+
864+ state->theIterator->init(cond);
865+ if (!theCountOnly)
866+ {
867+ state->theIterator->open();
868+
869+ while(state->theIterator->next(result))
870+ {
871 STACK_PUSH(true, state);
872- }
873-
874- state->theIterator->close();
875- }
876- else
877- {
878- state->theIterator->count(result);
879- STACK_PUSH(true, state);
880+ }
881+
882+ state->theIterator->close();
883+ }
884+ else
885+ {
886+ state->theIterator->count(result);
887+ STACK_PUSH(true, state);
888+ }
889 }
890 }
891- }
892-
893- else if (haveLower || haveUpper)
894- {
895- if (!getSearchItems(planState, state, haveLower, haveUpper, inclLower, inclUpper))
896- goto done;
897-
898- assert(state->theSearchItems.size() >= 1);
899- assert(state->theKeyType == NULL || state->theSearchItems.size() == 1);
900-
901- inclBound = (haveLower ? inclLower : inclUpper);
902-
903- state->theSearchItemsIte = state->theSearchItems.begin();
904- state->theSearchItemsEnd = state->theSearchItems.end();
905-
906- for (;
907- state->theSearchItemsIte != state->theSearchItemsEnd;
908- ++state->theSearchItemsIte)
909+
910+ else
911 {
912- cond->clear();
913- cond->pushBound(*state->theSearchItemsIte, haveLower, inclBound);
914-
915+ getSearchItems(planState, state, false, false, false, false);
916+
917 state->theIterator->init(cond);
918 if (!theCountOnly)
919 {
920 state->theIterator->open();
921-
922+
923 while(state->theIterator->next(result))
924 {
925 STACK_PUSH(true, state);
926 }
927-
928+
929 state->theIterator->close();
930 }
931 else
932@@ -1471,33 +1503,15 @@
933 STACK_PUSH(true, state);
934 }
935 }
936+
937+ done:
938+ STACK_END(state);
939 }
940-
941- else
942+ catch (ZorbaException& e)
943 {
944- getSearchItems(planState, state, false, false, false, false);
945-
946- state->theIterator->init(cond);
947- if (!theCountOnly)
948- {
949- state->theIterator->open();
950-
951- while(state->theIterator->next(result))
952- {
953- STACK_PUSH(true, state);
954- }
955-
956- state->theIterator->close();
957- }
958- else
959- {
960- state->theIterator->count(result);
961- STACK_PUSH(true, state);
962- }
963+ set_source(e, loc, false);
964+ throw;
965 }
966-
967- done:
968- STACK_END(state);
969 }
970
971
972
973=== added file 'test/rbkt/ExpQueryResults/zorba/numerics/comp01.xml.res'
974--- test/rbkt/ExpQueryResults/zorba/numerics/comp01.xml.res 1970-01-01 00:00:00 +0000
975+++ test/rbkt/ExpQueryResults/zorba/numerics/comp01.xml.res 2012-06-01 12:05:28 +0000
976@@ -0,0 +1,2 @@
977+<?xml version="1.0" encoding="UTF-8"?>
978+false
979
980=== added file 'test/rbkt/Queries/zorba/numerics/comp01.xq'
981--- test/rbkt/Queries/zorba/numerics/comp01.xq 1970-01-01 00:00:00 +0000
982+++ test/rbkt/Queries/zorba/numerics/comp01.xq 2012-06-01 12:05:28 +0000
983@@ -0,0 +1,1 @@
984+fn:number(<x/>) lt 100

Subscribers

People subscribed via source and target branches