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

Proposed by Markos Zaharioudakis
Status: Merged
Approved by: Markos Zaharioudakis
Approved revision: 10868
Merged at revision: 10871
Proposed branch: lp:~zorba-coders/zorba/bug-1006166
Merge into: lp:zorba
Diff against target: 360 lines (+213/-18)
5 files modified
ChangeLog (+4/-0)
src/compiler/translator/translator.cpp (+4/-2)
src/context/static_context.cpp (+31/-12)
src/context/static_context.h (+8/-2)
test/unit/static_context.cpp (+166/-2)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug-1006166
Reviewer Review Type Date Requested Status
Markos Zaharioudakis Approve
Review via email: mp+107988@code.launchpad.net

Commit message

Description of the change

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/bug-1006166 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-1006166-2012-06-14T08-29-03.844Z 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-1006166-2012-06-14T09-39-00.527Z 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-05-30 00:37:00 +0000
3+++ ChangeLog 2012-05-30 15:00:25 +0000
4@@ -1,5 +1,9 @@
5 Zorba - The XQuery Processor
6
7+version 2.x
8+
9+ * Fixed bug #1006166 (disabling 2 functions with the same qname)
10+
11 version 2.5
12
13 New Features:
14
15=== modified file 'src/compiler/translator/translator.cpp'
16--- src/compiler/translator/translator.cpp 2012-05-09 23:06:41 +0000
17+++ src/compiler/translator/translator.cpp 2012-05-30 15:00:25 +0000
18@@ -3280,7 +3280,7 @@
19 if (func_decl->is_external())
20 {
21 // 1. lookup if the function is a built-in function
22- f = theSctx->lookup_fn(qnameItem, numParams);
23+ f = theSctx->lookup_fn(qnameItem, numParams, false);
24
25 if (f.getp() != 0)
26 {
27@@ -3409,7 +3409,9 @@
28
29 // Get function obj out of function qname (will raise error if prefix in qname
30 // is not bound to a namespace).
31- function* f = lookup_fn(v.get_name(), v.get_param_count(), loc);
32+ store::Item_t qnameItem;
33+ expand_function_qname(qnameItem, v.get_name(), v.get_name()->get_location());
34+ function* f = theSctx->lookup_fn(qnameItem, v.get_param_count(), false);
35
36 assert(f);
37
38
39=== modified file 'src/context/static_context.cpp'
40--- src/context/static_context.cpp 2012-05-18 22:01:56 +0000
41+++ src/context/static_context.cpp 2012-05-30 15:00:25 +0000
42@@ -2408,8 +2408,8 @@
43
44 if (theFunctionArityMap->get(qname2, fv))
45 {
46- ulong numFunctions = (ulong)fv->size();
47- for (ulong i = 0; i < numFunctions; ++i)
48+ csize numFunctions = fv->size();
49+ for (csize i = 0; i < numFunctions; ++i)
50 {
51 if ((*fv)[i].theFunction.getp() == f)
52 {
53@@ -2421,6 +2421,7 @@
54
55 fv = new std::vector<FunctionInfo>(1);
56 fi.theIsDisabled = true;
57+ fi.theFunction = f;
58 (*fv)[0] = fi;
59 theFunctionArityMap->insert(qname2, fv);
60 }
61@@ -2440,7 +2441,8 @@
62 ********************************************************************************/
63 function* static_context::lookup_fn(
64 const store::Item* qname,
65- ulong arity)
66+ ulong arity,
67+ bool skipDisabled)
68 {
69 FunctionInfo fi;
70 store::Item* qname2 = const_cast<store::Item*>(qname);
71@@ -2455,7 +2457,10 @@
72
73 if (f->getArity() == arity || f->isVariadic())
74 {
75- return (fi.theIsDisabled ? NULL : f);
76+ if (fi.theIsDisabled && skipDisabled)
77+ return NULL;
78+
79+ return f;
80 }
81
82 std::vector<FunctionInfo>* fv = NULL;
83@@ -2463,11 +2468,16 @@
84 if (sctx->theFunctionArityMap != NULL &&
85 sctx->theFunctionArityMap->get(qname2, fv))
86 {
87- ulong numFunctions = (ulong)fv->size();
88- for (ulong i = 0; i < numFunctions; ++i)
89+ csize numFunctions = fv->size();
90+ for (csize i = 0; i < numFunctions; ++i)
91 {
92 if ((*fv)[i].theFunction->getArity() == arity)
93- return ((*fv)[i].theIsDisabled ? NULL : (*fv)[i].theFunction.getp());
94+ {
95+ if ((*fv)[i].theIsDisabled && skipDisabled)
96+ return NULL;
97+
98+ return (*fv)[i].theFunction.getp();
99+ }
100 }
101 }
102 }
103@@ -2486,7 +2496,8 @@
104 ********************************************************************************/
105 function* static_context::lookup_local_fn(
106 const store::Item* qname,
107- ulong arity)
108+ ulong arity,
109+ bool skipDisabled)
110 {
111 FunctionInfo fi;
112 store::Item* qname2 = const_cast<store::Item*>(qname);
113@@ -2497,18 +2508,26 @@
114
115 if (f->getArity() == arity || f->isVariadic())
116 {
117- return (fi.theIsDisabled ? NULL : f);
118+ if (fi.theIsDisabled && skipDisabled)
119+ return NULL;
120+
121+ return f;
122 }
123
124 std::vector<FunctionInfo>* fv = NULL;
125
126 if (theFunctionArityMap != NULL && theFunctionArityMap->get(qname2, fv))
127 {
128- ulong numFunctions = (ulong)fv->size();
129- for (ulong i = 0; i < numFunctions; ++i)
130+ csize numFunctions = fv->size();
131+ for (csize i = 0; i < numFunctions; ++i)
132 {
133 if ((*fv)[i].theFunction->getArity() == arity)
134- return ((*fv)[i].theIsDisabled ? NULL : (*fv)[i].theFunction.getp());
135+ {
136+ if ((*fv)[i].theIsDisabled && skipDisabled)
137+ return NULL;
138+
139+ return (*fv)[i].theFunction.getp();
140+ }
141 }
142 }
143 }
144
145=== modified file 'src/context/static_context.h'
146--- src/context/static_context.h 2012-05-07 17:42:55 +0000
147+++ src/context/static_context.h 2012-05-30 15:00:25 +0000
148@@ -826,9 +826,15 @@
149
150 void unbind_fn(const store::Item* qname, ulong arity);
151
152- function* lookup_fn(const store::Item* qname, ulong arity);
153+ function* lookup_fn(
154+ const store::Item* qname,
155+ ulong arity,
156+ bool skipDisabled = true);
157
158- function* lookup_local_fn(const store::Item* qname, ulong arity);
159+ function* lookup_local_fn(
160+ const store::Item* qname,
161+ ulong arity,
162+ bool skipDisabled = true);
163
164 void get_functions(std::vector<function*>& functions) const;
165
166
167=== modified file 'test/unit/static_context.cpp'
168--- test/unit/static_context.cpp 2012-05-18 02:52:21 +0000
169+++ test/unit/static_context.cpp 2012-05-30 15:00:25 +0000
170@@ -23,6 +23,7 @@
171 #include <zorba/store_manager.h>
172 #include <zorba/zorba.h>
173 #include <zorba/zorba_exception.h>
174+#include <zorba/diagnostic_list.h>
175
176 using namespace std;
177 using namespace zorba;
178@@ -139,10 +140,170 @@
179 }
180
181
182+bool
183+sctx_test_5(Zorba* zorba)
184+{
185+ std::stringstream queryString1;
186+ std::stringstream queryString2;
187+
188+ queryString1
189+ << "import module namespace ddl = "
190+ << "\"http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl\";"
191+ << std::endl
192+ << "ddl:create(xs:QName(\"ddl:coll1\"));"
193+ << std::endl;
194+
195+ queryString2
196+ << "import module namespace ddl = "
197+ << "\"http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl\";"
198+ << std::endl
199+ << "ddl:create(xs:QName(\"ddl:coll1\"), <a/>);"
200+ << std::endl;
201+
202+ ItemFactory* factory = zorba->getItemFactory();
203+
204+ Item fname = factory->
205+ createQName("http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl",
206+ "create");
207+
208+ try
209+ {
210+ StaticContext_t sctx = zorba->createStaticContext();
211+ sctx->disableFunction(fname, 1);
212+ sctx->disableFunction(fname, 2);
213+
214+ XQuery_t query = zorba->compileQuery(queryString1, sctx);
215+ }
216+ catch (ZorbaException& e)
217+ {
218+ std::cerr << e << std::endl;
219+
220+ if (e.diagnostic() != err::XPST0017)
221+ return false;
222+ }
223+ catch (...)
224+ {
225+ return false;
226+ }
227+
228+ try
229+ {
230+ StaticContext_t sctx = zorba->createStaticContext();
231+ sctx->disableFunction(fname, 1);
232+ sctx->disableFunction(fname, 2);
233+
234+ queryString2.seekg(0, std::ios::beg);
235+
236+ XQuery_t query = zorba->compileQuery(queryString2, sctx);
237+ }
238+ catch (ZorbaException& e)
239+ {
240+ std::cerr << e << std::endl;
241+
242+ if (e.diagnostic() != err::XPST0017)
243+ return false;
244+ }
245+ catch (...)
246+ {
247+ return false;
248+ }
249+
250+ try
251+ {
252+ StaticContext_t sctx = zorba->createStaticContext();
253+ sctx->disableFunction(fname, 1);
254+
255+ queryString1.clear();
256+ queryString1.seekg(0, std::ios::beg);
257+
258+ XQuery_t query = zorba->compileQuery(queryString1, sctx);
259+ }
260+ catch (ZorbaException& e)
261+ {
262+ std::cerr << e << std::endl;
263+
264+ if (e.diagnostic() != err::XPST0017)
265+ return false;
266+ }
267+ catch (...)
268+ {
269+ return false;
270+ }
271+
272+ try
273+ {
274+ StaticContext_t sctx = zorba->createStaticContext();
275+ sctx->disableFunction(fname, 1);
276+
277+ queryString2.clear();
278+ queryString2.seekg(0, std::ios::beg);
279+
280+ XQuery_t query = zorba->compileQuery(queryString2, sctx);
281+ }
282+ catch (ZorbaException& e)
283+ {
284+ std::cerr << e << std::endl;
285+
286+ return false;
287+ }
288+ catch (...)
289+ {
290+ return false;
291+ }
292+
293+
294+ try
295+ {
296+ StaticContext_t sctx = zorba->createStaticContext();
297+ sctx->disableFunction(fname, 2);
298+
299+ queryString1.clear();
300+ queryString1.seekg(0, std::ios::beg);
301+
302+ XQuery_t query = zorba->compileQuery(queryString1, sctx);
303+ }
304+ catch (ZorbaException& e)
305+ {
306+ std::cerr << e << std::endl;
307+
308+ return false;
309+ }
310+ catch (...)
311+ {
312+ return false;
313+ }
314+
315+ try
316+ {
317+ StaticContext_t sctx = zorba->createStaticContext();
318+ sctx->disableFunction(fname, 2);
319+
320+ queryString2.clear();
321+ queryString2.seekg(0, std::ios::beg);
322+
323+ XQuery_t query = zorba->compileQuery(queryString2, sctx);
324+ }
325+ catch (ZorbaException& e)
326+ {
327+ std::cerr << e << std::endl;
328+
329+ if (e.diagnostic() != err::XPST0017)
330+ return false;
331+ }
332+ catch (...)
333+ {
334+ return false;
335+ }
336+
337+ return true;
338+}
339+
340+
341+
342 int static_context( int argc, char *argv[] )
343 {
344- void* const zstore = StoreManager::getStore();
345- Zorba* const zorba = Zorba::getInstance( zstore );
346+ void* zstore = StoreManager::getStore();
347+ Zorba* zorba = Zorba::getInstance(zstore);
348
349 if (!sctx_test_1(zorba))
350 return 1;
351@@ -156,6 +317,9 @@
352 if (!sctx_test_4(zorba))
353 return 4;
354
355+ if (!sctx_test_5(zorba))
356+ return 5;
357+
358 zorba->shutdown();
359 StoreManager::shutdownStore( zstore );
360 return 0;

Subscribers

People subscribed via source and target branches