Markos Zaharioudakis has proposed merging 
lp:~zorba-coders/zorba/markos-scratch2 into lp:zorba.

Requested reviews:
  Markos Zaharioudakis (markos-za)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch2/+merge/111026

Fixed bug #1008082 (bug in transform expr when a copy var is not used anywhere)
-- 
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch2/+merge/111026
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2012-06-15 21:31:03 +0000
+++ ChangeLog	2012-06-19 14:25:23 +0000
@@ -14,6 +14,7 @@
 Bug Fixes/Other Changes:
   * Fixed bug #991088$ (raise XUST0001 in trycatch with mixed updating and simple clauses)
   * Fixed bug #854506 (ugly type error messages) and partial fix for bug #867008
+  * Fixed bug #1008082 (bug in transform expr when a copy var is not used anywhere)
   * Fixed bug #1003023$ (optimizer problems due to common subexpression after
     var folding into if-then-else)
   * Fixed bug #1006166 (disabling 2 functions with the same qname)

=== modified file 'src/runtime/update/update.cpp'
--- src/runtime/update/update.cpp	2012-06-15 21:31:03 +0000
+++ src/runtime/update/update.cpp	2012-06-19 14:25:23 +0000
@@ -741,6 +741,13 @@
 /*******************************************************************************
 
 ********************************************************************************/
+void CopyClause::serialize(::zorba::serialization::Archiver& ar)
+{
+  ar & theCopyVars;
+  ar & theInput;
+}
+
+
 TransformIterator::TransformIterator(
     static_context* sctx,
     const QueryLoc& aLoc,
@@ -765,6 +772,17 @@
 }
 
 
+void TransformIterator::serialize(::zorba::serialization::Archiver& ar)
+{
+  serialize_baseclass(ar, (Batcher<TransformIterator>*)this);
+  ar & theCopyClauses;
+  ar & theModifyIter;
+  ar & thePulHolderIter;
+  ar & theApplyIter;
+  ar & theReturnIter;
+}
+
+
 uint32_t 
 TransformIterator::getStateSizeOfSubtree() const 
 {
@@ -801,15 +819,15 @@
 bool
 TransformIterator::nextImpl(store::Item_t& result, PlanState& aPlanState) const
 {
-  std::vector<ForVarIter_t>::const_iterator lVarRefIter; 
-  std::vector<ForVarIter_t>::const_iterator lVarRefEnd;
+  std::vector<ForVarIter_t>::const_iterator varRefIte; 
+  std::vector<ForVarIter_t>::const_iterator varRefEnd;
   store::Item_t pulItem;
   store::Item_t validationPul;
   store::PUL_t pul;
   store::Item_t temp;
   store::Item_t lItem;
-  store::Item_t lCopyNode;
-  store::CopyMode lCopyMode;
+  store::Item_t copyNode;
+  store::CopyMode copymode;
   bool typePreserve;
   bool nsPreserve;
   bool nsInherit;
@@ -826,22 +844,22 @@
   nsInherit = (theSctx->inherit_mode() == StaticContextConsts::inherit_ns ?
                true : false);
 
-  lCopyMode.set(true, typePreserve, nsPreserve, nsInherit);
+  copymode.set(true, typePreserve, nsPreserve, nsInherit);
 
   {
-    ulong numCopyClauses = (ulong)theCopyClauses.size(); 
+    csize numCopyClauses = theCopyClauses.size(); 
     std::vector<store::Item*> copyNodes(numCopyClauses);
 
     // For each copy var compute the target node and bind that node to all
     // references of the copy var.
-    for (ulong i = 0; i < numCopyClauses; i++)
+    for (csize i = 0; i < numCopyClauses; i++)
     {
       const CopyClause& copyClause = theCopyClauses[i];
 
-      if (!consumeNext(lCopyNode, copyClause.theInput, aPlanState) ||
-          (!lCopyNode->isNode()
+      if (!consumeNext(copyNode, copyClause.theInput, aPlanState) ||
+          (!copyNode->isNode()
 #ifdef ZORBA_WITH_JSON
-           && !lCopyNode->isJSONItem()
+           && !copyNode->isJSONItem()
 #endif
           ))
       {
@@ -853,13 +871,16 @@
         throw XQUERY_EXCEPTION(err::XUTY0013, ERROR_LOC(loc));
       }
 
-      copyNodes[i] = lCopyNode->copy(NULL, lCopyMode);
-
-      lVarRefIter = copyClause.theCopyVars.begin();
-      lVarRefEnd = copyClause.theCopyVars.end();
-      for(; lVarRefIter != lVarRefEnd; ++lVarRefIter)
+      if (!copyClause.theCopyVars.empty())
       {
-        (*lVarRefIter)->bind(copyNodes[i], aPlanState);
+        copyNodes[i] = copyNode->copy(NULL, copymode);
+
+        varRefIte = copyClause.theCopyVars.begin();
+        varRefEnd = copyClause.theCopyVars.end();
+        for(; varRefIte != varRefEnd; ++varRefIte)
+        {
+          (*varRefIte)->bind(copyNodes[i], aPlanState);
+        }
       }
     }
 

=== modified file 'src/runtime/update/update.h'
--- src/runtime/update/update.h	2012-06-15 21:31:03 +0000
+++ src/runtime/update/update.h	2012-06-19 14:25:23 +0000
@@ -159,24 +159,16 @@
 
 public:
   SERIALIZABLE_CLASS(CopyClause);
-
   SERIALIZABLE_CLASS_CONSTRUCTOR(CopyClause);
-
-  void serialize(::zorba::serialization::Archiver &ar)
-  {
-    ar & theCopyVars;
-    ar & theInput;
-  }
+  void serialize(::zorba::serialization::Archiver& ar);
 
 public:
   CopyClause() {}
 
-  CopyClause(
-        std::vector<ForVarIter_t>& aCopyVars,
-        PlanIter_t                 aInput)
+  CopyClause(std::vector<ForVarIter_t>& copyVars, PlanIter_t input)
     :
-    theCopyVars(aCopyVars),
-    theInput(aInput)
+    theCopyVars(copyVars),
+    theInput(input)
   {}
 
   ~CopyClause() {}
@@ -195,25 +187,17 @@
 public:
   SERIALIZABLE_CLASS(TransformIterator)
   SERIALIZABLE_CLASS_CONSTRUCTOR2(TransformIterator, Batcher<TransformIterator>)
-  void serialize(::zorba::serialization::Archiver& ar)
-  {
-    serialize_baseclass(ar, (Batcher<TransformIterator>*)this);
-    ar & theCopyClauses;
-    ar & theModifyIter;
-    ar & thePulHolderIter;
-    ar & theApplyIter;
-    ar & theReturnIter;
-  }
+  void serialize(::zorba::serialization::Archiver& ar);
 
 public:
   TransformIterator (
-    static_context* sctx,
-    const QueryLoc& aLoc,
-    std::vector<CopyClause>& aCopyClauses,
-    PlanIter_t aModifyIter,
-    PlanIter_t aPulHolderIter,
-    PlanIter_t aApplyIter,
-    PlanIter_t aReturnIter);
+      static_context* sctx,
+      const QueryLoc& aLoc,
+      std::vector<CopyClause>& aCopyClauses,
+      PlanIter_t aModifyIter,
+      PlanIter_t aPulHolderIter,
+      PlanIter_t aApplyIter,
+      PlanIter_t aReturnIter);
 
   ~TransformIterator();
 

=== added file 'test/rbkt/ExpQueryResults/zorba/updates/transform01.xml.res'
--- test/rbkt/ExpQueryResults/zorba/updates/transform01.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/updates/transform01.xml.res	2012-06-19 14:25:23 +0000
@@ -0,0 +1,1 @@
+<a/>

=== added file 'test/rbkt/Queries/zorba/updates/transform01.xq'
--- test/rbkt/Queries/zorba/updates/transform01.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/updates/transform01.xq	2012-06-19 14:25:23 +0000
@@ -0,0 +1,3 @@
+copy $x := <a/>, $y := <b/>
+modify ()
+return $x

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to