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

Proposed by Matthias Brantner
Status: Superseded
Proposed branch: lp:~zorba-coders/zorba/bug-945241
Merge into: lp:zorba
Diff against target: 194 lines (+87/-23)
5 files modified
ChangeLog (+1/-0)
src/runtime/collections/collections_impl.cpp (+11/-5)
test/unit/module1.xq (+1/-1)
test/unit/module2.xq (+11/-0)
test/unit/staticcollectionmanager.cpp (+63/-17)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug-945241
Reviewer Review Type Date Requested Status
Matthias Brantner Approve
Till Westmann Pending
Review via email: mp+95699@code.launchpad.net

This proposal has been superseded by a proposal from 2012-03-02.

Commit message

fix bug #945241 (StaticCollectionManager::declaredIndexes() and temporary indexes )

Description of the change

StaticCollectionManager::declaredIndexes() doesn't return temporary indexes anymore. Also isDeclaredIndex also doesn't return true if asked whether a temporary index is declared.

To post a comment you must log in.
Revision history for this message
Matthias Brantner (matthias-brantner) :
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/bug-945241 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-945241-2012-03-02T23-40-07.785Z is finished. The
  final status was:

  No tests were run - build or configure step must have failed.

  Not commiting changes.

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

lp:~zorba-coders/zorba/bug-945241 updated
10689. By Matthias Brantner

fixed comment syntax

10690. By Matthias Brantner

merge

10691. By Matthias Brantner

fixed bug that occurred during the merge

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2012-03-01 21:22:16 +0000
3+++ ChangeLog 2012-03-02 23:39:22 +0000
4@@ -24,6 +24,7 @@
5 case of early-out)
6 * More efficient implementation for base64Binary items
7 * Added index management function to the C++ api's StaticCollectionManager.
8+ * Fixed bug #945241 (StaticCollectionManager::declaredIndexes() and temporary indexes)
9 * Fixed bug #872288 (reset recursive flag during node rename)
10 * Fixed bug #905041 (allow for the default element and function namespaces to be
11 set multiple times via the c++ api).
12
13=== modified file 'src/runtime/collections/collections_impl.cpp'
14--- src/runtime/collections/collections_impl.cpp 2012-02-16 12:48:17 +0000
15+++ src/runtime/collections/collections_impl.cpp 2012-03-02 23:39:22 +0000
16@@ -30,6 +30,7 @@
17 #include "context/uri_resolver.h"
18 #include "context/static_context_consts.h"
19
20+#include "compiler/xqddf/value_index.h"
21 #include "compiler/xqddf/value_ic.h"
22
23 #include "runtime/collections/collections.h"
24@@ -2331,20 +2332,21 @@
25 PlanState& aPlanState) const
26 {
27 store::Item_t lName;
28+ zorba::IndexDecl* lDecl;
29
30 PlanIteratorState* lState;
31 DEFAULT_STACK_INIT(PlanIteratorState, lState, aPlanState);
32
33 consumeNext(lName, theChildren[0].getp(), aPlanState);
34
35- if (theSctx->lookup_index(lName.getp()) == 0)
36+ if ((lDecl = theSctx->lookup_index(lName.getp())) && !lDecl->isTemp())
37+ {
38+ STACK_PUSH(GENV_ITEMFACTORY->createBoolean(aResult, true), lState);
39+ }
40+ else
41 {
42 STACK_PUSH(GENV_ITEMFACTORY->createBoolean(aResult, false), lState);
43 }
44- else
45- {
46- STACK_PUSH(GENV_ITEMFACTORY->createBoolean(aResult, true), lState);
47- }
48
49 STACK_END(lState);
50 }
51@@ -2386,6 +2388,10 @@
52 for ((lState->nameItState = theSctx->index_names())->open();
53 lState->nameItState->next(lName); )
54 {
55+ if (theSctx->lookup_index(lName.getp())->isTemp())
56+ {
57+ continue;
58+ }
59 aResult = lName;
60 STACK_PUSH(true, lState);
61 }
62
63=== modified file 'test/unit/module1.xq'
64--- test/unit/module1.xq 2011-08-05 02:21:55 +0000
65+++ test/unit/module1.xq 2012-03-02 23:39:22 +0000
66@@ -18,4 +18,4 @@
67
68 import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl";
69
70-1+1
71+mod2:foo()
72
73=== modified file 'test/unit/module2.xq'
74--- test/unit/module2.xq 2011-12-21 14:40:33 +0000
75+++ test/unit/module2.xq 2012-03-02 23:39:22 +0000
76@@ -27,3 +27,14 @@
77 declare index mod2:index
78 on nodes ddl:collection(xs:QName("mod2:coll"))
79 by data(@id) as xs:string;
80+
81+
82+(: test that a temp index doesn't have impact on the indexes
83+ returned by the static collection mgr :)
84+declare function mod2:foo()
85+{
86+ for $i in 1 to 10
87+ for $j in 1 to 10
88+ where $i eq $j
89+ return $i
90+};
91
92=== modified file 'test/unit/staticcollectionmanager.cpp'
93--- test/unit/staticcollectionmanager.cpp 2012-01-11 17:30:25 +0000
94+++ test/unit/staticcollectionmanager.cpp 2012-03-02 23:39:22 +0000
95@@ -206,23 +206,26 @@
96 Item lCollName2 = lFac->createQName("http://www.mod2.com/", "coll");
97
98 lColMgr->createCollection(lCollName2);
99- Collection_t lColl = lColMgr->getCollection(lCollName2);
100-
101- std::vector<Annotation_t> lAnnotations;
102- lColl->getAnnotations(lAnnotations);
103- size_t num_annotations = 0;
104- for (std::vector<Annotation_t>::const_iterator lIter = lAnnotations.begin();
105- lIter != lAnnotations.end(); ++lIter)
106- {
107- std::cout << "Annotation QName " << (*lIter)->getQName().getStringValue() << std::endl;
108- ++num_annotations;
109- }
110-
111- if (num_annotations != 3)
112- {
113- return false;
114- }
115-
116+
117+ {
118+ Collection_t lColl = lColMgr->getCollection(lCollName2);
119+ std::vector<Annotation_t> lAnnotations;
120+ lColl->getAnnotations(lAnnotations);
121+ size_t num_annotations = 0;
122+ for (std::vector<Annotation_t>::const_iterator lIter = lAnnotations.begin();
123+ lIter != lAnnotations.end(); ++lIter)
124+ {
125+ std::cout << "Annotation QName " << (*lIter)->getQName().getStringValue() << std::endl;
126+ ++num_annotations;
127+ }
128+
129+ if (num_annotations != 3)
130+ {
131+ return false;
132+ }
133+ }
134+
135+ lColMgr->deleteCollection(lCollName2);
136
137 return true;
138 }
139@@ -259,6 +262,44 @@
140 return i == 1;
141 }
142
143+(: test that declaredIndexes doesn't return temporary indexes and crashes
144+ : if one tries to create one :)
145+bool
146+staticcollectionamanger5(zorba::Zorba* z)
147+{
148+ std::ifstream lIn("module1.xq");
149+
150+ zorba::XQuery_t lQuery = z->createQuery();
151+ Zorba_CompilerHints lHints;
152+ lQuery->compile(lIn, lHints);
153+
154+ StaticCollectionManager* lColMgr = lQuery->getStaticCollectionManager();
155+
156+ ItemFactory* lFac = z->getItemFactory();
157+ Item lCollName2 = lFac->createQName("http://www.mod2.com/", "coll");
158+ Item lIdxName = lFac->createQName("http://www.mod2.com/", "index");
159+ Item lCollName3 = lFac->createQName("http://www.mod3.com/", "coll");
160+
161+ ItemSequence_t lSeq = lColMgr->declaredCollections();
162+ Iterator_t lIter = lSeq->getIterator();
163+ lIter->open();
164+ Item lTmp;
165+ while (lIter->next(lTmp)) {
166+ std::cout << "name " << lTmp.getStringValue() << std::endl;
167+ lColMgr->createCollection(lTmp);
168+ }
169+
170+ lSeq = lColMgr->declaredIndexes();
171+ lIter = lSeq->getIterator();
172+ lIter->open();
173+ while (lIter->next(lTmp)) {
174+ std::cout << "name " << lTmp.getStringValue() << std::endl;
175+ lColMgr->createIndex(lTmp);
176+ }
177+
178+ return true;
179+}
180+
181 int
182 staticcollectionmanager(int argc, char* argv[])
183 {
184@@ -287,6 +328,11 @@
185 return 4;
186 std::cout << std::endl;
187
188+ std::cout << "executing example 5" << std::endl;
189+ if (!staticcollectionamanger5(z))
190+ return 5;
191+ std::cout << std::endl;
192+
193 return 0;
194 }
195

Subscribers

People subscribed via source and target branches