zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #15067
[Merge] lp:~zorba-coders/zorba/no-copy into lp:zorba
Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/no-copy into lp:zorba.
Commit message:
No-copy rule overhaul
Requested reviews:
Markos Zaharioudakis (markos-za)
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/no-copy/+merge/127281
No-copy rule overhaul
--
https://code.launchpad.net/~zorba-coders/zorba/no-copy/+merge/127281
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/compiler/rewriter/rules/nodeid_rules.cpp'
--- src/compiler/rewriter/rules/nodeid_rules.cpp 2012-10-01 08:15:43 +0000
+++ src/compiler/rewriter/rules/nodeid_rules.cpp 2012-10-01 13:40:32 +0000
@@ -589,11 +589,16 @@
{
// Serialization may or may not be a "node-id-sesitive" op.
static_context* sctx = node->get_sctx();
+<<<<<<< TREE
if (sctx->preserve_mode() == StaticContextConsts::preserve_ns &&
sctx->inherit_mode() == StaticContextConsts::inherit_ns)
+=======
+ if (sctx->preserve_mode() == StaticContextConsts::preserve_ns)
+>>>>>>> MERGE-SOURCE
{
- markForSerialization(rCtx.theRoot);
+ if (sctx->inherit_mode() == StaticContextConsts::inherit_ns)
+ markForSerialization(rCtx.theRoot);
}
else
{
@@ -1066,9 +1071,24 @@
/*******************************************************************************
- The purpose of this method is to find patrh exprs that are inside the subtree
- of "node" and which return nodes that may propagated in the result of the
- "node" expr.
+ This method is called only if the result of the query is going to be used
+ for serialization only, and the copy-namespaces mode is [preserve inherit].
+
+ In this case, the result of the query should not contain any shared node N,
+ because if N was reached via a referencing tree, then serializing N will
+ miss the namespace bindings that N would have inherited from the referencing
+ tree if N had been copied inot that tree.
+
+ To enforce the above restriction, this method looks for expressions under
+ "node" that constructor new nodes or receive nodes as input, and may propagate
+ such nodes into the result of the "node" expr. It then marks such expr as
+ "forSerialization".
+
+
+extract descendant nodes out of their input nodes, and which
+ nodes may be propagated in the It then marks such
+ exprs as "unsafe", in order to make sure that their input trees will be
+ standalone.
********************************************************************************/
void MarkNodeCopyProps::markForSerialization(expr* node)
{
@@ -1097,7 +1117,6 @@
case var_expr::win_var:
case var_expr::wincond_out_var:
case var_expr::wincond_in_var:
- case var_expr::groupby_var:
case var_expr::non_groupby_var:
{
if (!e->willBeSerialized())
@@ -1111,6 +1130,7 @@
case var_expr::copy_var:
case var_expr::catch_var:
{
+ e->setWillBeSerialized(ANNOTATION_TRUE);
return;
}
@@ -1149,6 +1169,7 @@
return;
}
+ case var_expr::groupby_var:
case var_expr::wincond_in_pos_var:
case var_expr::wincond_out_pos_var:
case var_expr::pos_var:
@@ -1247,7 +1268,6 @@
return;
}
- case promote_expr_kind:
case treat_expr_kind:
case order_expr_kind:
case wrapper_expr_kind:
@@ -1311,40 +1331,16 @@
case eval_expr_kind:
{
- eval_expr* e = static_cast<eval_expr*>(node);
-
- csize numVars = e->num_vars();
-
- for (csize i = 0; i < numVars; ++i)
- {
- expr* arg = e->get_arg_expr(i);
-
- if (arg == NULL)
- continue;
-
- markForSerialization(arg);
- }
-
- return;
+ break;
}
case debugger_expr_kind:
{
- break;
+ break; // ????
}
case dynamic_function_invocation_expr_kind:
{
- dynamic_function_invocation_expr* e =
- static_cast<dynamic_function_invocation_expr*>(node);
-
- const std::vector<expr*>& args = e->get_args();
-
- FOR_EACH(std::vector<expr*>, ite, args)
- {
- markForSerialization((*ite));
- }
-
break;
}
@@ -1354,13 +1350,12 @@
user_function* udf = static_cast<user_function*>(e->get_function());
- UDFCallChain dummyUdfCaller;
-
markForSerialization(udf->getBody());
return;
}
+ case promote_expr_kind:
case castable_expr_kind:
case cast_expr_kind:
case instanceof_expr_kind:
=== modified file 'src/runtime/core/trycatch.cpp'
--- src/runtime/core/trycatch.cpp 2012-09-17 00:36:37 +0000
+++ src/runtime/core/trycatch.cpp 2012-10-01 13:40:32 +0000
@@ -399,13 +399,15 @@
LetVarConstIter lErrorObjVarIterEnd = lIter->second.end();
std::vector<store::Item_t> eObjs;
- if ( UserException const *ue = dynamic_cast<UserException const*>( &e ) ) {
+ if ( UserException const *ue = dynamic_cast<UserException const*>( &e ) )
+ {
UserException::error_object_type const &eo = ue->error_object();
if ( !eo.empty() )
convert_error_object( eo, &eObjs );
}
- for ( ; lErrorObjVarIter != lErrorObjVarIterEnd; lErrorObjVarIter++ ) {
+ for ( ; lErrorObjVarIter != lErrorObjVarIterEnd; lErrorObjVarIter++ )
+ {
store::Iterator_t lErrorObjIter = eObjs.empty() ?
new ItemIterator() : new ItemIterator(eObjs);
lErrorObjIter->open();
@@ -604,10 +606,11 @@
{
theChild->close(planState);
- std::vector<TryCatchIterator::CatchClause>::iterator lIter = theCatchClauses.begin();
- std::vector<TryCatchIterator::CatchClause>::iterator lEnd = theCatchClauses.end();
+ std::vector<CatchClause>::iterator lIter = theCatchClauses.begin();
+ std::vector<CatchClause>::iterator lEnd = theCatchClauses.end();
- for ( ; lIter != lEnd; ++lIter ) {
+ for ( ; lIter != lEnd; ++lIter )
+ {
( *lIter ).catch_expr->close(planState);
}
@@ -619,9 +622,10 @@
{
v.beginVisit(*this);
theChild->accept ( v );
- std::vector<TryCatchIterator::CatchClause>::const_iterator lIter = theCatchClauses.begin();
- std::vector<TryCatchIterator::CatchClause>::const_iterator lEnd = theCatchClauses.end();
- for ( ; lIter != lEnd; ++lIter ) {
+ std::vector<CatchClause>::const_iterator lIter = theCatchClauses.begin();
+ std::vector<CatchClause>::const_iterator lEnd = theCatchClauses.end();
+ for ( ; lIter != lEnd; ++lIter )
+ {
( *lIter ).catch_expr->accept ( v );
}
v.endVisit(*this);
=== added file 'test/rbkt/ExpQueryResults/zorba/no-copy/ser_01.xml.res'
--- test/rbkt/ExpQueryResults/zorba/no-copy/ser_01.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/no-copy/ser_01.xml.res 2012-10-01 13:40:32 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<a xmlns:p1="www.foo1.com" xmlns:p2="www.foo2.com"/>
=== added file 'test/rbkt/ExpQueryResults/zorba/no-copy/ser_02.xml.res'
--- test/rbkt/ExpQueryResults/zorba/no-copy/ser_02.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/no-copy/ser_02.xml.res 2012-10-01 13:40:32 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<a xmlns:p1="www.foo1.com"/>
=== modified file 'test/rbkt/Queries/zorba/no-copy/dataguide-c.xq'
--- test/rbkt/Queries/zorba/no-copy/dataguide-c.xq 2012-09-17 00:36:37 +0000
+++ test/rbkt/Queries/zorba/no-copy/dataguide-c.xq 2012-10-01 13:40:32 +0000
@@ -64,17 +64,15 @@
{
}
- if($e) then
- if(empty($c)) then
- {
- element {$n } { attribute {"L"} {$label}, $ca}
- }
+ if($e)
+ then
+ if(empty($c))
+ then
+ element { $n } { attribute {"L"} {$label}, $ca }
else
- element {$n } { attribute {"L"} {$label}, $ca, $cc }
+ element { $n } { attribute {"L"} {$label}, $ca, $cc }
else
- {
- attribute {$n} {$label}
- }
+ attribute { $n } {$label}
};
=== added file 'test/rbkt/Queries/zorba/no-copy/ser_01.xq'
--- test/rbkt/Queries/zorba/no-copy/ser_01.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/no-copy/ser_01.xq 2012-10-01 13:40:32 +0000
@@ -0,0 +1,20 @@
+
+declare namespace opt = "http://www.zorba-xquery.com/options/optimizer";
+
+declare copy-namespaces preserve, inherit;
+
+declare option opt:enable "for-serialization-only";
+
+declare variable $doc1 :=
+<doc1 xmlns:p1="www.foo1.com">
+<a/>
+</doc1>;
+
+
+let $doc2 := <doc2 xmlns:p2="www.foo2.com">{$doc1/a}</doc2>
+return
+$doc2/a
+,
+"
+"
+
=== added file 'test/rbkt/Queries/zorba/no-copy/ser_02.xq'
--- test/rbkt/Queries/zorba/no-copy/ser_02.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/no-copy/ser_02.xq 2012-10-01 13:40:32 +0000
@@ -0,0 +1,18 @@
+declare namespace opt = "http://www.zorba-xquery.com/options/optimizer";
+
+declare copy-namespaces preserve, no-inherit;
+
+declare option opt:enable "for-serialization-only";
+
+declare variable $doc1 :=
+<doc1 xmlns:p1="www.foo1.com">
+<a/>
+</doc1>;
+
+
+let $doc2 := <doc2 xmlns:p2="www.foo2.com">{$doc1/a}</doc2>
+return
+$doc2/a
+,
+"
+"
Follow ups
-
[Merge] lp:~zorba-coders/zorba/no-copy into lp:zorba
From: noreply, 2012-10-02
-
[Merge] lp:~zorba-coders/zorba/no-copy into lp:zorba
From: Zorba Build Bot, 2012-10-02
-
[Merge] lp:~zorba-coders/zorba/no-copy into lp:zorba
From: Zorba Build Bot, 2012-10-02
-
[Merge] lp:~zorba-coders/zorba/no-copy into lp:zorba
From: Markos Zaharioudakis, 2012-10-02
-
[Merge] lp:~zorba-coders/zorba/no-copy into lp:zorba
From: Zorba Build Bot, 2012-10-01
-
Re: [Merge] lp:~zorba-coders/zorba/no-copy into lp:zorba
From: Zorba Build Bot, 2012-10-01
-
[Merge] lp:~zorba-coders/zorba/no-copy into lp:zorba
From: Zorba Build Bot, 2012-10-01
-
[Merge] lp:~zorba-coders/zorba/no-copy into lp:zorba
From: Markos Zaharioudakis, 2012-10-01
-
[Merge] lp:~zorba-coders/zorba/no-copy into lp:zorba
From: Zorba Build Bot, 2012-10-01
-
Re: [Merge] lp:~zorba-coders/zorba/no-copy into lp:zorba
From: Zorba Build Bot, 2012-10-01
-
[Merge] lp:~zorba-coders/zorba/no-copy into lp:zorba
From: Zorba Build Bot, 2012-10-01
-
[Merge] lp:~zorba-coders/zorba/no-copy into lp:zorba
From: Markos Zaharioudakis, 2012-10-01
-
[Merge] lp:~zorba-coders/zorba/no-copy into lp:zorba
From: Zorba Build Bot, 2012-10-01
-
Re: [Merge] lp:~zorba-coders/zorba/no-copy into lp:zorba
From: Zorba Build Bot, 2012-10-01
-
[Merge] lp:~zorba-coders/zorba/no-copy into lp:zorba
From: Zorba Build Bot, 2012-10-01
-
[Merge] lp:~zorba-coders/zorba/no-copy into lp:zorba
From: Markos Zaharioudakis, 2012-10-01
-
Re: [Merge] lp:~zorba-coders/zorba/no-copy into lp:zorba
From: Markos Zaharioudakis, 2012-10-01
-
[Merge] lp:~zorba-coders/zorba/no-copy into lp:zorba
From: Markos Zaharioudakis, 2012-10-01