zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #06377
[Merge] lp:~zorba-coders/zorba/947627 into lp:zorba
Matthias Brantner has proposed merging lp:~zorba-coders/zorba/947627 into lp:zorba.
Requested reviews:
Markos Zaharioudakis (markos-za)
Till Westmann (tillw)
Related bugs:
Bug #947627 in Zorba: "setting the static type of the context item is ignored"
https://bugs.launchpad.net/zorba/+bug/947627
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/947627/+merge/97570
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
--
https://code.launchpad.net/~zorba-coders/zorba/947627/+merge/97570
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog 2012-03-12 20:01:39 +0000
+++ ChangeLog 2012-03-15 04:19:18 +0000
@@ -49,6 +49,7 @@
* Fixed bug #911585 (management of variables during eval)
* Fixed bug #866423 (fn:empty and fn:exists iterators must reset their input in
case of early-out)
+ * Fixed bug #947627 (setting the static type of the context item is ignored)
* Fixed bug #945241 (StaticCollectionManager::declaredIndexes() and temporary indexes)
* Fixed bug #872288 (reset recursive flag during node rename)
* Fixed bug #905041 (allow for the default element and function namespaces to be
=== modified file 'include/zorba/pregenerated/diagnostic_list.h'
--- include/zorba/pregenerated/diagnostic_list.h 2012-03-12 23:43:56 +0000
+++ include/zorba/pregenerated/diagnostic_list.h 2012-03-15 04:19:18 +0000
@@ -172,6 +172,8 @@
extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0098;
+extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0099;
+
extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0106;
extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0111;
=== modified file 'modules/w3c/pregenerated/xqt-errors.xq'
--- modules/w3c/pregenerated/xqt-errors.xq 2011-11-15 08:10:49 +0000
+++ modules/w3c/pregenerated/xqt-errors.xq 2012-03-15 04:19:18 +0000
@@ -766,6 +766,14 @@
(:~
:
+ : If a module contains more than one context item declaration, a static error is raised [err:XQST0099].
+ :
+ : @see http://www.w3.org/2005/xqt-errors
+:)
+declare variable $err:XQST0099 as xs:QName := fn:QName($err:NS, "err:XQST0099");
+
+(:~
+ :
: It is a static error if a function's annotations contain more than one
: annotation named \c private or \c public. It is a static error if a
: function's annotations contain more than one annotation named \c
=== modified file 'src/api/staticcontextimpl.cpp'
--- src/api/staticcontextimpl.cpp 2012-03-07 15:49:25 +0000
+++ src/api/staticcontextimpl.cpp 2012-03-15 04:19:18 +0000
@@ -932,6 +932,10 @@
void
StaticContextImpl::setContextItemStaticType(TypeIdentifier_t type)
{
+ if (theCtx->is_context_item_type_set())
+ {
+ throw ZORBA_EXCEPTION(err::XQST0099);
+ }
xqtref_t xqType = NULL;
if (type != NULL)
{
=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp 2012-03-07 14:22:29 +0000
+++ src/compiler/translator/translator.cpp 2012-03-15 04:19:18 +0000
@@ -3917,6 +3917,10 @@
RAISE_ERROR(err::XPST0003, loc,
ERROR_PARAMS(ZED(XPST0003_XQueryVersionAtLeast30_2), theSctx->xquery_version()));
+ if (theSctx->is_context_item_type_set())
+ {
+ RAISE_ERROR_NO_PARAMS(err::XQST0099, loc);
+ }
theHaveContextItemDecl = true;
return no_state;
=== modified file 'src/context/root_static_context.cpp'
--- src/context/root_static_context.cpp 2012-01-23 10:06:24 +0000
+++ src/context/root_static_context.cpp 2012-03-15 04:19:18 +0000
@@ -93,8 +93,6 @@
set_default_function_ns(W3C_FN_NS, true, loc);
- set_context_item_type(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
-
add_collation(ZORBA_DEF_COLLATION_NS, QueryLoc::null);
add_collation(W3C_CODEPT_COLLATION_NS, QueryLoc::null);
set_default_collation(W3C_CODEPT_COLLATION_NS, QueryLoc::null);
=== modified file 'src/context/static_context.cpp'
--- src/context/static_context.cpp 2012-03-07 15:49:25 +0000
+++ src/context/static_context.cpp 2012-03-15 04:19:18 +0000
@@ -554,6 +554,7 @@
theHaveDefaultElementNamespace(false),
theHaveDefaultFunctionNamespace(false),
theContextItemType(GENV_TYPESYSTEM.ITEM_TYPE_ONE),
+ theContextItemTypeSet(false),
theVariablesMap(NULL),
theImportedPrivateVariablesMap(NULL),
theFunctionMap(NULL),
@@ -602,6 +603,7 @@
theHaveDefaultElementNamespace(false),
theHaveDefaultFunctionNamespace(false),
theContextItemType(GENV_TYPESYSTEM.ITEM_TYPE_ONE),
+ theContextItemTypeSet(false),
theVariablesMap(NULL),
theImportedPrivateVariablesMap(NULL),
theFunctionMap(NULL),
@@ -655,6 +657,7 @@
theHaveDefaultElementNamespace(false),
theHaveDefaultFunctionNamespace(false),
theContextItemType(GENV_TYPESYSTEM.ITEM_TYPE_ONE),
+ theContextItemTypeSet(false),
theVariablesMap(NULL),
theImportedPrivateVariablesMap(NULL),
theFunctionMap(NULL),
@@ -961,6 +964,7 @@
ar & theHaveDefaultFunctionNamespace;
ar & theContextItemType;
+ ar & theContextItemTypeSet;
ar & theVariablesMap;
ar & theImportedPrivateVariablesMap;
@@ -2218,12 +2222,31 @@
}
+/*******************************************************************************
+
+********************************************************************************/
+bool static_context::is_context_item_type_set() const
+{
+ const static_context* sctx = this;
+ while (sctx != NULL)
+ {
+ if (sctx->theContextItemTypeSet)
+ return true;
+
+ sctx = sctx->theParent;
+ }
+
+ return false;
+}
+
+
/***************************************************************************//**
********************************************************************************/
void static_context::set_context_item_type(const xqtref_t& t)
{
theContextItemType = t;
+ theContextItemTypeSet = true;
}
=== modified file 'src/context/static_context.h'
--- src/context/static_context.h 2012-03-07 15:49:25 +0000
+++ src/context/static_context.h 2012-03-15 04:19:18 +0000
@@ -520,6 +520,7 @@
bool theHaveDefaultFunctionNamespace;
xqtref_t theContextItemType;
+ bool theContextItemTypeSet;
VariableMap * theVariablesMap;
@@ -798,6 +799,8 @@
bool returnPrivateVars = false,
bool externalVarsOnly = false) const;
+ bool is_context_item_type_set() const;
+
void set_context_item_type(const xqtref_t& t);
const XQType* get_context_item_type() const;
=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml 2012-03-12 23:43:56 +0000
+++ src/diagnostics/diagnostic_en.xml 2012-03-15 04:19:18 +0000
@@ -716,6 +716,13 @@
<value>properties "$1" and "$2", representing characters used in picture string, do not have distinct values</value>
</diagnostic>
+ <diagnostic code="XQST0099">
+ <comment>
+ If a module contains more than one context item declaration, a static error is raised [err:XQST0099].
+ </comment>
+ <value>module contains more than one context item declaration</value>
+ </diagnostic>
+
<diagnostic code="XQST0106">
<comment>
It is a static error if a function's annotations contain more than one
=== modified file 'src/diagnostics/pregenerated/diagnostic_list.cpp'
--- src/diagnostics/pregenerated/diagnostic_list.cpp 2012-03-12 23:43:56 +0000
+++ src/diagnostics/pregenerated/diagnostic_list.cpp 2012-03-15 04:19:18 +0000
@@ -241,6 +241,9 @@
XQueryErrorCode XQST0098( "XQST0098" );
+XQueryErrorCode XQST0099( "XQST0099" );
+
+
XQueryErrorCode XQST0106( "XQST0106" );
=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp 2012-03-12 23:43:56 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp 2012-03-15 04:19:18 +0000
@@ -178,6 +178,7 @@
{ "XQST0090", "\"$1\": invalid character reference in XML $2" },
{ "XQST0093", "\"$1\": module must not depend on itself" },
{ "XQST0098", "properties \"$1\" and \"$2\", representing characters used in picture string, do not have distinct values" },
+ { "XQST0099", "module contains more than one context item declaration" },
{ "XQST0106", "$1: multiple annotations with $2 names" },
{ "XQST0111", "$1" },
{ "XQTY0024", "element constructor content sequence must not have an attribute node following a non-attribute node" },
=== 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-03-15 04:19:18 +0000
@@ -0,0 +1,1 @@
+Error: http://www.w3.org/2005/xqt-errors:XQST0099
=== 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-03-15 04:19:18 +0000
@@ -0,0 +1,5 @@
+declare context item as item() := 2;
+
+declare context item as xs:string := "3";
+
+.
=== modified file 'test/unit/context_item.cpp'
--- test/unit/context_item.cpp 2011-12-30 17:55:53 +0000
+++ test/unit/context_item.cpp 2012-03-15 04:19:18 +0000
@@ -97,16 +97,9 @@
std::ostringstream resultStream;
{
- zorba::TypeIdentifier_t type =
- zorba::TypeIdentifier::createNamedType("http://www.w3.org/2001/XMLSchema",
- "integer");
-
zorba::Item ctxValue = zorba->getItemFactory()->createString("foo");
- zorba::StaticContext_t sctx = zorba->createStaticContext();
- sctx->setContextItemStaticType(type);
-
- zorba::XQuery_t query = zorba->compileQuery(queryStream, sctx);
+ zorba::XQuery_t query = zorba->compileQuery(queryStream);
Zorba_SerializerOptions serOptions;
serOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
@@ -138,6 +131,46 @@
return 0;
}
+int test_3(zorba::Zorba* zorba)
+{
+ try
+ {
+ std::ifstream queryStream("context_item2.xq");
+ assert(queryStream.good());
+ std::ostringstream resultStream;
+
+ {
+ zorba::TypeIdentifier_t type =
+ zorba::TypeIdentifier::createNamedType("http://www.w3.org/2001/XMLSchema",
+ "integer");
+
+ zorba::Item ctxValue = zorba->getItemFactory()->createString("foo");
+
+ zorba::StaticContext_t sctx = zorba->createStaticContext();
+ sctx->setContextItemStaticType(type);
+
+ zorba::XQuery_t query = zorba->compileQuery(queryStream, sctx);
+
+ zorba::DynamicContext* dctx = query->getDynamicContext();
+ dctx->setContextItem(ctxValue);
+
+ query->execute(resultStream);
+
+ return 5;
+ }
+ }
+ catch (zorba::XQueryException& qe)
+ {
+ std::cerr << qe << std::endl;
+ if (qe.diagnostic() == zorba::err::XQST0099)
+ {
+ return 0;
+ }
+ return 1;
+ }
+
+ return 2;
+}
int context_item(int argc, char* argv[])
{
@@ -150,9 +183,11 @@
int result2 = test_2(zorba);
+ int result3 = test_3(zorba);
+
zorba->shutdown();
zorba::StoreManager::shutdownStore(store);
- return result1 + result2;
+ return result1 + result2 + result3;
}
/* vim:set et sw=2 ts=2: */
Follow ups
-
[Merge] lp:~zorba-coders/zorba/947627 into lp:zorba
From: noreply, 2012-04-23
-
[Merge] lp:~zorba-coders/zorba/947627 into lp:zorba
From: Zorba Build Bot, 2012-04-23
-
[Merge] lp:~zorba-coders/zorba/947627 into lp:zorba
From: Zorba Build Bot, 2012-04-23
-
[Merge] lp:~zorba-coders/zorba/947627 into lp:zorba
From: Markos Zaharioudakis, 2012-04-23
-
Re: [Merge] lp:~zorba-coders/zorba/947627 into lp:zorba
From: Markos Zaharioudakis, 2012-04-23
-
Re: [Merge] lp:~zorba-coders/zorba/947627 into lp:zorba
From: Till Westmann, 2012-03-20
-
[Merge] lp:~zorba-coders/zorba/947627 into lp:zorba
From: Zorba Build Bot, 2012-03-15
-
Re: [Merge] lp:~zorba-coders/zorba/947627 into lp:zorba
From: Zorba Build Bot, 2012-03-15
-
[Merge] lp:~zorba-coders/zorba/947627 into lp:zorba
From: Zorba Build Bot, 2012-03-15
-
[Merge] lp:~zorba-coders/zorba/947627 into lp:zorba
From: Zorba Build Bot, 2012-03-15
-
[Merge] lp:~zorba-coders/zorba/947627 into lp:zorba
From: Zorba Build Bot, 2012-03-15
-
[Merge] lp:~zorba-coders/zorba/947627 into lp:zorba
From: Matthias Brantner, 2012-03-15