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

Proposed by Matthias Brantner
Status: Merged
Approved by: Markos Zaharioudakis
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 Approve
Till Westmann Approve
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.
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
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 947627-2012-03-15T05-06-12.174Z 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: 3 Pending.

Revision history for this message
Till Westmann (tillw) :
review: Approve
lp:~zorba-coders/zorba/947627 updated
10724. By Markos Zaharioudakis

inner context item declaration hides an outer one

10725. 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 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
=== modified file 'ChangeLog'
--- ChangeLog 2012-04-19 23:46:41 +0000
+++ ChangeLog 2012-04-23 10:53:23 +0000
@@ -30,6 +30,8 @@
30 * Fixed bug #906494 (default compile with D_FILE_OFFSET_BITS=64)30 * Fixed bug #906494 (default compile with D_FILE_OFFSET_BITS=64)
31 * Fixed bug #912586, #912593 and #912722 (assertion failures with lax validation)31 * Fixed bug #912586, #912593 and #912722 (assertion failures with lax validation)
32 * Fixed bug #921458 (file:read-text-lines() blocking)32 * Fixed bug #921458 (file:read-text-lines() blocking)
33 * Fixed bug #947627 (throw XQST0099 if more than one declarations of context item
34 type in same module)
33 * Fixed bug #980526 (no-copy rule bug due to global var being set in "distant" udf)35 * Fixed bug #980526 (no-copy rule bug due to global var being set in "distant" udf)
34 * 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).36 * 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).
35 * Fixed Bug #933490: Error ItemFactoryImpl::createBase64Binary with istream37 * Fixed Bug #933490: Error ItemFactoryImpl::createBase64Binary with istream
3638
=== modified file 'include/zorba/pregenerated/diagnostic_list.h'
--- include/zorba/pregenerated/diagnostic_list.h 2012-04-19 21:40:27 +0000
+++ include/zorba/pregenerated/diagnostic_list.h 2012-04-23 10:53:23 +0000
@@ -172,6 +172,8 @@
172172
173extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0098;173extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0098;
174174
175extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0099;
176
175extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0106;177extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0106;
176178
177extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0111;179extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0111;
178180
=== modified file 'modules/w3c/pregenerated/xqt-errors.xq'
--- modules/w3c/pregenerated/xqt-errors.xq 2012-04-19 21:40:27 +0000
+++ modules/w3c/pregenerated/xqt-errors.xq 2012-04-23 10:53:23 +0000
@@ -766,6 +766,14 @@
766766
767(:~767(:~
768 :768 :
769 : If a module contains more than one context item declaration, a static error is raised [err:XQST0099].
770 :
771 : @see http://www.w3.org/2005/xqt-errors
772:)
773declare variable $err:XQST0099 as xs:QName := fn:QName($err:NS, "err:XQST0099");
774
775(:~
776 :
769 : It is a static error if a function's annotations contain more than one777 : It is a static error if a function's annotations contain more than one
770 : annotation named \c private or \c public. It is a static error if a778 : annotation named \c private or \c public. It is a static error if a
771 : function's annotations contain more than one annotation named \c779 : function's annotations contain more than one annotation named \c
772780
=== modified file 'src/api/staticcontextimpl.cpp'
--- src/api/staticcontextimpl.cpp 2012-04-19 21:40:27 +0000
+++ src/api/staticcontextimpl.cpp 2012-04-23 10:53:23 +0000
@@ -920,7 +920,7 @@
920920
921 try921 try
922 {922 {
923 for (unsigned int i = 0; i < ann_list->size(); i++)923 for (csize i = 0; i < ann_list->size(); ++i)
924 aAnnotations.push_back(new AnnotationImpl(ann_list->get(i)));924 aAnnotations.push_back(new AnnotationImpl(ann_list->get(i)));
925 }925 }
926 catch (ZorbaException const& e)926 catch (ZorbaException const& e)
@@ -938,7 +938,7 @@
938 {938 {
939 xqType = theCtx->get_typemanager()->create_type(*type);939 xqType = theCtx->get_typemanager()->create_type(*type);
940 }940 }
941 theCtx->set_context_item_type(xqType);941 theCtx->set_context_item_type(xqType, QueryLoc::null);
942}942}
943943
944944
945945
=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp 2012-04-19 21:40:27 +0000
+++ src/compiler/translator/translator.cpp 2012-04-23 10:53:23 +0000
@@ -3935,7 +3935,7 @@
3935 if (v.get_type() != NULL)3935 if (v.get_type() != NULL)
3936 {3936 {
3937 type = pop_tstack();3937 type = pop_tstack();
3938 theSctx->set_context_item_type(type);3938 theSctx->set_context_item_type(type, loc);
3939 }3939 }
3940 else3940 else
3941 {3941 {
39423942
=== modified file 'src/context/root_static_context.cpp'
--- src/context/root_static_context.cpp 2012-04-19 21:40:27 +0000
+++ src/context/root_static_context.cpp 2012-04-23 10:53:23 +0000
@@ -93,8 +93,6 @@
9393
94 set_default_function_ns(W3C_FN_NS, true, loc);94 set_default_function_ns(W3C_FN_NS, true, loc);
9595
96 set_context_item_type(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
97
98 add_collation(ZORBA_DEF_COLLATION_NS, QueryLoc::null);96 add_collation(ZORBA_DEF_COLLATION_NS, QueryLoc::null);
99 add_collation(W3C_CODEPT_COLLATION_NS, QueryLoc::null);97 add_collation(W3C_CODEPT_COLLATION_NS, QueryLoc::null);
100 set_default_collation(W3C_CODEPT_COLLATION_NS, QueryLoc::null);98 set_default_collation(W3C_CODEPT_COLLATION_NS, QueryLoc::null);
@@ -111,6 +109,7 @@
111109
112 set_default_w3c_collection_type(GENV_TYPESYSTEM.ITEM_TYPE_STAR);110 set_default_w3c_collection_type(GENV_TYPESYSTEM.ITEM_TYPE_STAR);
113111
112 set_context_item_type(GENV_TYPESYSTEM.ITEM_TYPE_ONE, QueryLoc::null);
114113
115 // TODO move into globalenv? memory leaks?114 // TODO move into globalenv? memory leaks?
116 add_url_resolver(new internal::FileURLResolver());115 add_url_resolver(new internal::FileURLResolver());
117116
=== modified file 'src/context/static_context.cpp'
--- src/context/static_context.cpp 2012-04-19 21:40:27 +0000
+++ src/context/static_context.cpp 2012-04-23 10:53:23 +0000
@@ -556,7 +556,7 @@
556 theNamespaceBindings(NULL),556 theNamespaceBindings(NULL),
557 theHaveDefaultElementNamespace(false),557 theHaveDefaultElementNamespace(false),
558 theHaveDefaultFunctionNamespace(false),558 theHaveDefaultFunctionNamespace(false),
559 theContextItemType(GENV_TYPESYSTEM.ITEM_TYPE_ONE),559 theContextItemType(NULL),
560 theVariablesMap(NULL),560 theVariablesMap(NULL),
561 theImportedPrivateVariablesMap(NULL),561 theImportedPrivateVariablesMap(NULL),
562 theFunctionMap(NULL),562 theFunctionMap(NULL),
@@ -604,7 +604,7 @@
604 theNamespaceBindings(NULL),604 theNamespaceBindings(NULL),
605 theHaveDefaultElementNamespace(false),605 theHaveDefaultElementNamespace(false),
606 theHaveDefaultFunctionNamespace(false),606 theHaveDefaultFunctionNamespace(false),
607 theContextItemType(GENV_TYPESYSTEM.ITEM_TYPE_ONE),607 theContextItemType(NULL),
608 theVariablesMap(NULL),608 theVariablesMap(NULL),
609 theImportedPrivateVariablesMap(NULL),609 theImportedPrivateVariablesMap(NULL),
610 theFunctionMap(NULL),610 theFunctionMap(NULL),
@@ -657,7 +657,7 @@
657 theNamespaceBindings(NULL),657 theNamespaceBindings(NULL),
658 theHaveDefaultElementNamespace(false),658 theHaveDefaultElementNamespace(false),
659 theHaveDefaultFunctionNamespace(false),659 theHaveDefaultFunctionNamespace(false),
660 theContextItemType(GENV_TYPESYSTEM.ITEM_TYPE_ONE),660 theContextItemType(NULL),
661 theVariablesMap(NULL),661 theVariablesMap(NULL),
662 theImportedPrivateVariablesMap(NULL),662 theImportedPrivateVariablesMap(NULL),
663 theFunctionMap(NULL),663 theFunctionMap(NULL),
@@ -2229,8 +2229,13 @@
2229/***************************************************************************//**2229/***************************************************************************//**
22302230
2231********************************************************************************/2231********************************************************************************/
2232void static_context::set_context_item_type(const xqtref_t& t)2232void static_context::set_context_item_type(const xqtref_t& t, const QueryLoc& loc)
2233{2233{
2234 if (theContextItemType != NULL)
2235 {
2236 RAISE_ERROR_NO_PARAMS(err::XQST0099, loc);
2237 }
2238
2234 theContextItemType = t;2239 theContextItemType = t;
2235}2240}
22362241
@@ -2243,8 +2248,8 @@
2243 const static_context* sctx = this;2248 const static_context* sctx = this;
2244 while (sctx != NULL)2249 while (sctx != NULL)
2245 {2250 {
2246 if (theContextItemType != NULL)2251 if (sctx->theContextItemType != NULL)
2247 return theContextItemType.getp();2252 return sctx->theContextItemType.getp();
22482253
2249 sctx = sctx->theParent;2254 sctx = sctx->theParent;
2250 }2255 }
22512256
=== modified file 'src/context/static_context.h'
--- src/context/static_context.h 2012-04-19 21:40:27 +0000
+++ src/context/static_context.h 2012-04-23 10:53:23 +0000
@@ -801,7 +801,7 @@
801 bool returnPrivateVars = false,801 bool returnPrivateVars = false,
802 bool externalVarsOnly = false) const;802 bool externalVarsOnly = false) const;
803803
804 void set_context_item_type(const xqtref_t& t);804 void set_context_item_type(const xqtref_t& t, const QueryLoc& loc);
805805
806 const XQType* get_context_item_type() const;806 const XQType* get_context_item_type() const;
807807
808808
=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml 2012-04-19 21:40:27 +0000
+++ src/diagnostics/diagnostic_en.xml 2012-04-23 10:53:23 +0000
@@ -716,6 +716,13 @@
716 <value>properties "$1" and "$2", representing characters used in picture string, do not have distinct values</value>716 <value>properties "$1" and "$2", representing characters used in picture string, do not have distinct values</value>
717 </diagnostic>717 </diagnostic>
718718
719 <diagnostic code="XQST0099">
720 <comment>
721 If a module contains more than one context item declaration, a static error is raised [err:XQST0099].
722 </comment>
723 <value>module contains more than one context item declaration</value>
724 </diagnostic>
725
719 <diagnostic code="XQST0106">726 <diagnostic code="XQST0106">
720 <comment>727 <comment>
721 It is a static error if a function's annotations contain more than one728 It is a static error if a function's annotations contain more than one
722729
=== modified file 'src/diagnostics/pregenerated/diagnostic_list.cpp'
--- src/diagnostics/pregenerated/diagnostic_list.cpp 2012-04-19 21:40:27 +0000
+++ src/diagnostics/pregenerated/diagnostic_list.cpp 2012-04-23 10:53:23 +0000
@@ -241,6 +241,9 @@
241XQueryErrorCode XQST0098( "XQST0098" );241XQueryErrorCode XQST0098( "XQST0098" );
242242
243243
244XQueryErrorCode XQST0099( "XQST0099" );
245
246
244XQueryErrorCode XQST0106( "XQST0106" );247XQueryErrorCode XQST0106( "XQST0106" );
245248
246249
247250
=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp 2012-04-19 21:40:27 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp 2012-04-23 10:53:23 +0000
@@ -180,6 +180,7 @@
180 { "XQST0090", "\"$1\": invalid character reference in XML $2" },180 { "XQST0090", "\"$1\": invalid character reference in XML $2" },
181 { "XQST0093", "\"$1\": module must not depend on itself" },181 { "XQST0093", "\"$1\": module must not depend on itself" },
182 { "XQST0098", "properties \"$1\" and \"$2\", representing characters used in picture string, do not have distinct values" },182 { "XQST0098", "properties \"$1\" and \"$2\", representing characters used in picture string, do not have distinct values" },
183 { "XQST0099", "module contains more than one context item declaration" },
183 { "XQST0106", "$1: multiple annotations with $2 names" },184 { "XQST0106", "$1: multiple annotations with $2 names" },
184 { "XQST0111", "$1" },185 { "XQST0111", "$1" },
185 { "XQTY0024", "element constructor content sequence must not have an attribute node following a non-attribute node" },186 { "XQTY0024", "element constructor content sequence must not have an attribute node following a non-attribute node" },
186187
=== added file 'test/rbkt/Queries/zorba/misc/context-item-decl01.spec'
--- test/rbkt/Queries/zorba/misc/context-item-decl01.spec 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/misc/context-item-decl01.spec 2012-04-23 10:53:23 +0000
@@ -0,0 +1,1 @@
1Error: http://www.w3.org/2005/xqt-errors:XQST0099
02
=== added file 'test/rbkt/Queries/zorba/misc/context-item-decl01.xq'
--- test/rbkt/Queries/zorba/misc/context-item-decl01.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/misc/context-item-decl01.xq 2012-04-23 10:53:23 +0000
@@ -0,0 +1,5 @@
1declare context item as item() := 2;
2
3declare context item as xs:string := "3";
4
5.
06
=== modified file 'test/unit/context_item.cpp'
--- test/unit/context_item.cpp 2012-04-19 21:40:27 +0000
+++ test/unit/context_item.cpp 2012-04-23 10:53:23 +0000
@@ -97,16 +97,9 @@
97 std::ostringstream resultStream;97 std::ostringstream resultStream;
9898
99 {99 {
100 zorba::TypeIdentifier_t type =
101 zorba::TypeIdentifier::createNamedType("http://www.w3.org/2001/XMLSchema",
102 "integer");
103
104 zorba::Item ctxValue = zorba->getItemFactory()->createString("foo");100 zorba::Item ctxValue = zorba->getItemFactory()->createString("foo");
105101
106 zorba::StaticContext_t sctx = zorba->createStaticContext();102 zorba::XQuery_t query = zorba->compileQuery(queryStream);
107 sctx->setContextItemStaticType(type);
108
109 zorba::XQuery_t query = zorba->compileQuery(queryStream, sctx);
110103
111 Zorba_SerializerOptions serOptions;104 Zorba_SerializerOptions serOptions;
112 serOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;105 serOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
@@ -138,6 +131,46 @@
138 return 0;131 return 0;
139}132}
140133
134int test_3(zorba::Zorba* zorba)
135{
136 try
137 {
138 std::ifstream queryStream("context_item2.xq");
139 assert(queryStream.good());
140 std::ostringstream resultStream;
141
142 {
143 zorba::TypeIdentifier_t type =
144 zorba::TypeIdentifier::createNamedType("http://www.w3.org/2001/XMLSchema",
145 "integer");
146
147 zorba::Item ctxValue = zorba->getItemFactory()->createInteger(10);
148
149 zorba::StaticContext_t sctx = zorba->createStaticContext();
150 sctx->setContextItemStaticType(type);
151
152 zorba::XQuery_t query = zorba->compileQuery(queryStream, sctx);
153
154 zorba::DynamicContext* dctx = query->getDynamicContext();
155 dctx->setContextItem(ctxValue);
156
157 query->execute(resultStream);
158
159 return 5;
160 }
161 }
162 catch (zorba::XQueryException& qe)
163 {
164 std::cerr << qe << std::endl;
165 if (qe.diagnostic() == zorba::err::XPTY0004)
166 {
167 return 0;
168 }
169 return 1;
170 }
171
172 return 2;
173}
141174
142int context_item(int argc, char* argv[]) 175int context_item(int argc, char* argv[])
143{176{
@@ -150,9 +183,11 @@
150183
151 int result2 = test_2(zorba);184 int result2 = test_2(zorba);
152185
186 int result3 = test_3(zorba);
187
153 zorba->shutdown();188 zorba->shutdown();
154 zorba::StoreManager::shutdownStore(store);189 zorba::StoreManager::shutdownStore(store);
155 return result1 + result2;190 return result1 + result2 + result3;
156}191}
157192
158/* vim:set et sw=2 ts=2: */193/* vim:set et sw=2 ts=2: */

Subscribers

People subscribed via source and target branches