Merge lp:~zorba-coders/zorba/947627 into lp:zorba

Proposed by Matthias Brantner on 2012-03-15
Status: Merged
Approved by: Markos Zaharioudakis on 2012-04-23
Approved revision: 10725
Merged at revision: 10788
Proposed branch: lp:~zorba-coders/zorba/947627
Merge into: lp:zorba
Diff against target: 312 lines (+89/-21)
14 files modified
ChangeLog (+2/-0)
include/zorba/pregenerated/diagnostic_list.h (+2/-0)
modules/w3c/pregenerated/xqt-errors.xq (+8/-0)
src/api/staticcontextimpl.cpp (+2/-2)
src/compiler/translator/translator.cpp (+1/-1)
src/context/root_static_context.cpp (+1/-2)
src/context/static_context.cpp (+11/-6)
src/context/static_context.h (+1/-1)
src/diagnostics/diagnostic_en.xml (+7/-0)
src/diagnostics/pregenerated/diagnostic_list.cpp (+3/-0)
src/diagnostics/pregenerated/dict_en.cpp (+1/-0)
test/rbkt/Queries/zorba/misc/context-item-decl01.spec (+1/-0)
test/rbkt/Queries/zorba/misc/context-item-decl01.xq (+5/-0)
test/unit/context_item.cpp (+44/-9)
To merge this branch: bzr merge lp:~zorba-coders/zorba/947627
Reviewer Review Type Date Requested Status
Markos Zaharioudakis 2012-03-15 Approve on 2012-04-23
Till Westmann 2012-03-15 Approve on 2012-03-20
Review via email: mp+97570@code.launchpad.net

Commit message

fixed bug #947627 (setting the static type of the context item is ignored)

Description of the change

fixed bug #947627 (setting the static type of the context item is ignored)
- raise an error if specified twice in the prolog
- if set using the C++ api and later in the prolog

To post a comment you must log in.
Zorba Build Bot (zorba-buildbot) wrote :
Zorba Build Bot (zorba-buildbot) wrote :
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job 947627-2012-03-15T05-06-12.174Z is finished. The final status was:

All tests succeeded!

Zorba Build Bot (zorba-buildbot) wrote :

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

Till Westmann (tillw) :
review: Approve
lp:~zorba-coders/zorba/947627 updated on 2012-04-23
10724. By Markos Zaharioudakis on 2012-04-23

inner context item declaration hides an outer one

10725. By Markos Zaharioudakis on 2012-04-23

merge from trunk

review: Approve
Zorba Build Bot (zorba-buildbot) wrote :
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job 947627-2012-04-23T11-08-23.457Z 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-04-19 23:46:41 +0000
3+++ ChangeLog 2012-04-23 10:53:23 +0000
4@@ -30,6 +30,8 @@
5 * Fixed bug #906494 (default compile with D_FILE_OFFSET_BITS=64)
6 * Fixed bug #912586, #912593 and #912722 (assertion failures with lax validation)
7 * Fixed bug #921458 (file:read-text-lines() blocking)
8+ * Fixed bug #947627 (throw XQST0099 if more than one declarations of context item
9+ type in same module)
10 * Fixed bug #980526 (no-copy rule bug due to global var being set in "distant" udf)
11 * Fixed bug #949910 (has-children may be invoked on all nodes). Internally, zorba::store::Item::getChildren() now returns NULL on node classes without offspring (instead of raising an error).
12 * Fixed Bug #933490: Error ItemFactoryImpl::createBase64Binary with istream
13
14=== modified file 'include/zorba/pregenerated/diagnostic_list.h'
15--- include/zorba/pregenerated/diagnostic_list.h 2012-04-19 21:40:27 +0000
16+++ include/zorba/pregenerated/diagnostic_list.h 2012-04-23 10:53:23 +0000
17@@ -172,6 +172,8 @@
18
19 extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0098;
20
21+extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0099;
22+
23 extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0106;
24
25 extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0111;
26
27=== modified file 'modules/w3c/pregenerated/xqt-errors.xq'
28--- modules/w3c/pregenerated/xqt-errors.xq 2012-04-19 21:40:27 +0000
29+++ modules/w3c/pregenerated/xqt-errors.xq 2012-04-23 10:53:23 +0000
30@@ -766,6 +766,14 @@
31
32 (:~
33 :
34+ : If a module contains more than one context item declaration, a static error is raised [err:XQST0099].
35+ :
36+ : @see http://www.w3.org/2005/xqt-errors
37+:)
38+declare variable $err:XQST0099 as xs:QName := fn:QName($err:NS, "err:XQST0099");
39+
40+(:~
41+ :
42 : It is a static error if a function's annotations contain more than one
43 : annotation named \c private or \c public. It is a static error if a
44 : function's annotations contain more than one annotation named \c
45
46=== modified file 'src/api/staticcontextimpl.cpp'
47--- src/api/staticcontextimpl.cpp 2012-04-19 21:40:27 +0000
48+++ src/api/staticcontextimpl.cpp 2012-04-23 10:53:23 +0000
49@@ -920,7 +920,7 @@
50
51 try
52 {
53- for (unsigned int i = 0; i < ann_list->size(); i++)
54+ for (csize i = 0; i < ann_list->size(); ++i)
55 aAnnotations.push_back(new AnnotationImpl(ann_list->get(i)));
56 }
57 catch (ZorbaException const& e)
58@@ -938,7 +938,7 @@
59 {
60 xqType = theCtx->get_typemanager()->create_type(*type);
61 }
62- theCtx->set_context_item_type(xqType);
63+ theCtx->set_context_item_type(xqType, QueryLoc::null);
64 }
65
66
67
68=== modified file 'src/compiler/translator/translator.cpp'
69--- src/compiler/translator/translator.cpp 2012-04-19 21:40:27 +0000
70+++ src/compiler/translator/translator.cpp 2012-04-23 10:53:23 +0000
71@@ -3935,7 +3935,7 @@
72 if (v.get_type() != NULL)
73 {
74 type = pop_tstack();
75- theSctx->set_context_item_type(type);
76+ theSctx->set_context_item_type(type, loc);
77 }
78 else
79 {
80
81=== modified file 'src/context/root_static_context.cpp'
82--- src/context/root_static_context.cpp 2012-04-19 21:40:27 +0000
83+++ src/context/root_static_context.cpp 2012-04-23 10:53:23 +0000
84@@ -93,8 +93,6 @@
85
86 set_default_function_ns(W3C_FN_NS, true, loc);
87
88- set_context_item_type(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
89-
90 add_collation(ZORBA_DEF_COLLATION_NS, QueryLoc::null);
91 add_collation(W3C_CODEPT_COLLATION_NS, QueryLoc::null);
92 set_default_collation(W3C_CODEPT_COLLATION_NS, QueryLoc::null);
93@@ -111,6 +109,7 @@
94
95 set_default_w3c_collection_type(GENV_TYPESYSTEM.ITEM_TYPE_STAR);
96
97+ set_context_item_type(GENV_TYPESYSTEM.ITEM_TYPE_ONE, QueryLoc::null);
98
99 // TODO move into globalenv? memory leaks?
100 add_url_resolver(new internal::FileURLResolver());
101
102=== modified file 'src/context/static_context.cpp'
103--- src/context/static_context.cpp 2012-04-19 21:40:27 +0000
104+++ src/context/static_context.cpp 2012-04-23 10:53:23 +0000
105@@ -556,7 +556,7 @@
106 theNamespaceBindings(NULL),
107 theHaveDefaultElementNamespace(false),
108 theHaveDefaultFunctionNamespace(false),
109- theContextItemType(GENV_TYPESYSTEM.ITEM_TYPE_ONE),
110+ theContextItemType(NULL),
111 theVariablesMap(NULL),
112 theImportedPrivateVariablesMap(NULL),
113 theFunctionMap(NULL),
114@@ -604,7 +604,7 @@
115 theNamespaceBindings(NULL),
116 theHaveDefaultElementNamespace(false),
117 theHaveDefaultFunctionNamespace(false),
118- theContextItemType(GENV_TYPESYSTEM.ITEM_TYPE_ONE),
119+ theContextItemType(NULL),
120 theVariablesMap(NULL),
121 theImportedPrivateVariablesMap(NULL),
122 theFunctionMap(NULL),
123@@ -657,7 +657,7 @@
124 theNamespaceBindings(NULL),
125 theHaveDefaultElementNamespace(false),
126 theHaveDefaultFunctionNamespace(false),
127- theContextItemType(GENV_TYPESYSTEM.ITEM_TYPE_ONE),
128+ theContextItemType(NULL),
129 theVariablesMap(NULL),
130 theImportedPrivateVariablesMap(NULL),
131 theFunctionMap(NULL),
132@@ -2229,8 +2229,13 @@
133 /***************************************************************************//**
134
135 ********************************************************************************/
136-void static_context::set_context_item_type(const xqtref_t& t)
137+void static_context::set_context_item_type(const xqtref_t& t, const QueryLoc& loc)
138 {
139+ if (theContextItemType != NULL)
140+ {
141+ RAISE_ERROR_NO_PARAMS(err::XQST0099, loc);
142+ }
143+
144 theContextItemType = t;
145 }
146
147@@ -2243,8 +2248,8 @@
148 const static_context* sctx = this;
149 while (sctx != NULL)
150 {
151- if (theContextItemType != NULL)
152- return theContextItemType.getp();
153+ if (sctx->theContextItemType != NULL)
154+ return sctx->theContextItemType.getp();
155
156 sctx = sctx->theParent;
157 }
158
159=== modified file 'src/context/static_context.h'
160--- src/context/static_context.h 2012-04-19 21:40:27 +0000
161+++ src/context/static_context.h 2012-04-23 10:53:23 +0000
162@@ -801,7 +801,7 @@
163 bool returnPrivateVars = false,
164 bool externalVarsOnly = false) const;
165
166- void set_context_item_type(const xqtref_t& t);
167+ void set_context_item_type(const xqtref_t& t, const QueryLoc& loc);
168
169 const XQType* get_context_item_type() const;
170
171
172=== modified file 'src/diagnostics/diagnostic_en.xml'
173--- src/diagnostics/diagnostic_en.xml 2012-04-19 21:40:27 +0000
174+++ src/diagnostics/diagnostic_en.xml 2012-04-23 10:53:23 +0000
175@@ -716,6 +716,13 @@
176 <value>properties "$1" and "$2", representing characters used in picture string, do not have distinct values</value>
177 </diagnostic>
178
179+ <diagnostic code="XQST0099">
180+ <comment>
181+ If a module contains more than one context item declaration, a static error is raised [err:XQST0099].
182+ </comment>
183+ <value>module contains more than one context item declaration</value>
184+ </diagnostic>
185+
186 <diagnostic code="XQST0106">
187 <comment>
188 It is a static error if a function's annotations contain more than one
189
190=== modified file 'src/diagnostics/pregenerated/diagnostic_list.cpp'
191--- src/diagnostics/pregenerated/diagnostic_list.cpp 2012-04-19 21:40:27 +0000
192+++ src/diagnostics/pregenerated/diagnostic_list.cpp 2012-04-23 10:53:23 +0000
193@@ -241,6 +241,9 @@
194 XQueryErrorCode XQST0098( "XQST0098" );
195
196
197+XQueryErrorCode XQST0099( "XQST0099" );
198+
199+
200 XQueryErrorCode XQST0106( "XQST0106" );
201
202
203
204=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
205--- src/diagnostics/pregenerated/dict_en.cpp 2012-04-19 21:40:27 +0000
206+++ src/diagnostics/pregenerated/dict_en.cpp 2012-04-23 10:53:23 +0000
207@@ -180,6 +180,7 @@
208 { "XQST0090", "\"$1\": invalid character reference in XML $2" },
209 { "XQST0093", "\"$1\": module must not depend on itself" },
210 { "XQST0098", "properties \"$1\" and \"$2\", representing characters used in picture string, do not have distinct values" },
211+ { "XQST0099", "module contains more than one context item declaration" },
212 { "XQST0106", "$1: multiple annotations with $2 names" },
213 { "XQST0111", "$1" },
214 { "XQTY0024", "element constructor content sequence must not have an attribute node following a non-attribute node" },
215
216=== added file 'test/rbkt/Queries/zorba/misc/context-item-decl01.spec'
217--- test/rbkt/Queries/zorba/misc/context-item-decl01.spec 1970-01-01 00:00:00 +0000
218+++ test/rbkt/Queries/zorba/misc/context-item-decl01.spec 2012-04-23 10:53:23 +0000
219@@ -0,0 +1,1 @@
220+Error: http://www.w3.org/2005/xqt-errors:XQST0099
221
222=== added file 'test/rbkt/Queries/zorba/misc/context-item-decl01.xq'
223--- test/rbkt/Queries/zorba/misc/context-item-decl01.xq 1970-01-01 00:00:00 +0000
224+++ test/rbkt/Queries/zorba/misc/context-item-decl01.xq 2012-04-23 10:53:23 +0000
225@@ -0,0 +1,5 @@
226+declare context item as item() := 2;
227+
228+declare context item as xs:string := "3";
229+
230+.
231
232=== modified file 'test/unit/context_item.cpp'
233--- test/unit/context_item.cpp 2012-04-19 21:40:27 +0000
234+++ test/unit/context_item.cpp 2012-04-23 10:53:23 +0000
235@@ -97,16 +97,9 @@
236 std::ostringstream resultStream;
237
238 {
239- zorba::TypeIdentifier_t type =
240- zorba::TypeIdentifier::createNamedType("http://www.w3.org/2001/XMLSchema",
241- "integer");
242-
243 zorba::Item ctxValue = zorba->getItemFactory()->createString("foo");
244
245- zorba::StaticContext_t sctx = zorba->createStaticContext();
246- sctx->setContextItemStaticType(type);
247-
248- zorba::XQuery_t query = zorba->compileQuery(queryStream, sctx);
249+ zorba::XQuery_t query = zorba->compileQuery(queryStream);
250
251 Zorba_SerializerOptions serOptions;
252 serOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
253@@ -138,6 +131,46 @@
254 return 0;
255 }
256
257+int test_3(zorba::Zorba* zorba)
258+{
259+ try
260+ {
261+ std::ifstream queryStream("context_item2.xq");
262+ assert(queryStream.good());
263+ std::ostringstream resultStream;
264+
265+ {
266+ zorba::TypeIdentifier_t type =
267+ zorba::TypeIdentifier::createNamedType("http://www.w3.org/2001/XMLSchema",
268+ "integer");
269+
270+ zorba::Item ctxValue = zorba->getItemFactory()->createInteger(10);
271+
272+ zorba::StaticContext_t sctx = zorba->createStaticContext();
273+ sctx->setContextItemStaticType(type);
274+
275+ zorba::XQuery_t query = zorba->compileQuery(queryStream, sctx);
276+
277+ zorba::DynamicContext* dctx = query->getDynamicContext();
278+ dctx->setContextItem(ctxValue);
279+
280+ query->execute(resultStream);
281+
282+ return 5;
283+ }
284+ }
285+ catch (zorba::XQueryException& qe)
286+ {
287+ std::cerr << qe << std::endl;
288+ if (qe.diagnostic() == zorba::err::XPTY0004)
289+ {
290+ return 0;
291+ }
292+ return 1;
293+ }
294+
295+ return 2;
296+}
297
298 int context_item(int argc, char* argv[])
299 {
300@@ -150,9 +183,11 @@
301
302 int result2 = test_2(zorba);
303
304+ int result3 = test_3(zorba);
305+
306 zorba->shutdown();
307 zorba::StoreManager::shutdownStore(store);
308- return result1 + result2;
309+ return result1 + result2 + result3;
310 }
311
312 /* vim:set et sw=2 ts=2: */

Subscribers

People subscribed via source and target branches