← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/bug-1024892 into lp:zorba

 

Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/bug-1024892 into lp:zorba.

Requested reviews:
  Markos Zaharioudakis (markos-za)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-1024892/+merge/118977

Fixed bug #1024892 (index declaration references udf declared after the index)
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1024892/+merge/118977
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2012-08-07 14:45:59 +0000
+++ ChangeLog	2012-08-09 14:58:27 +0000
@@ -1,5 +1,12 @@
 Zorba - The XQuery Processor
 
+version 2.7
+
+Bug Fixes/Other Changes:
+  * Fixed bugs #899364 and 899363 (throw XQST0103 in case of non-distinct window
+    variables)
+  * Fixed bug #899366 (enforce the type declaration of a window variable)
+  * Fixed bug #1024892 (index declaration references udf declared after the index)
 
 version 2.6
 

=== modified file 'src/compiler/parsetree/parsenodes.cpp'
--- src/compiler/parsetree/parsenodes.cpp	2012-07-24 08:48:48 +0000
+++ src/compiler/parsetree/parsenodes.cpp	2012-08-09 14:58:27 +0000
@@ -628,11 +628,19 @@
 
   VFO_Decl ::= VarDecl | ContextItemDecl | FunctionDecl | IndexDecl | OptionDecl
 ********************************************************************************/
-VFO_DeclList::VFO_DeclList(
-    const QueryLoc& loc_)
+VFO_DeclList::VFO_DeclList(const QueryLoc& loc)
   :
-  parsenode(loc_)
-{
+  parsenode(loc)
+{
+}
+
+
+void VFO_DeclList::push_back(const rchandle<parsenode>& decl)
+{
+  theDecls.push_back(decl);
+
+  bool isIndexDecl = (dynamic_cast<AST_IndexDecl*>(decl.getp()) != NULL);
+  theIndexDeclFlags.push_back(isIndexDecl);
 }
 
 
@@ -640,12 +648,24 @@
 {
   BEGIN_VISITOR();
 
-  for (std::vector<rchandle<parsenode> >::const_iterator it = vfo_hv.begin();
-       it != vfo_hv.end();
-       ++it)
-  {
-    ACCEPT_CHK (*it);
-  }
+  csize numDecls = theDecls.size();
+
+  for (csize i = 0; i < numDecls; ++i)
+  {
+    if (theIndexDeclFlags[i])
+      continue;
+
+    ACCEPT_CHK(theDecls[i]);
+  }
+
+  for (csize i = 0; i < numDecls; ++i)
+  {
+    if (!theIndexDeclFlags[i])
+      continue;
+
+    ACCEPT_CHK(theDecls[i]);
+  }
+
   END_VISITOR();
 }
 

=== modified file 'src/compiler/parsetree/parsenodes.h'
--- src/compiler/parsetree/parsenodes.h	2012-07-24 08:48:48 +0000
+++ src/compiler/parsetree/parsenodes.h	2012-08-09 14:58:27 +0000
@@ -813,30 +813,27 @@
 class VFO_DeclList : public parsenode
 {
 protected:
-  std::vector<rchandle<parsenode> > vfo_hv;
+  std::vector<rchandle<parsenode> > theDecls;
+  std::vector<bool>                 theIndexDeclFlags;
 
 public:
   VFO_DeclList(const QueryLoc&);
 
-  ulong size () const { return (ulong)vfo_hv.size (); }
-
-  void push_front(rchandle<parsenode> vfo_h) { vfo_hv.insert(vfo_hv.begin(), vfo_h); }
-
-  void push_back(rchandle<parsenode> vfo_h) { vfo_hv.push_back(vfo_h); }
-
-  void push_back (const VFO_DeclList &other) { vfo_hv.insert(vfo_hv.end(), other.vfo_hv.begin(), other.vfo_hv.end()); }
-
-  rchandle<parsenode> operator[](int k) const { return vfo_hv[k]; }
-
-  std::vector<rchandle<parsenode> >::iterator begin() { return vfo_hv.begin(); }
-
-  std::vector<rchandle<parsenode> >::iterator end() { return vfo_hv.end(); }
-
-  std::vector<rchandle<parsenode> >::const_iterator begin() const { return vfo_hv.begin(); }
-
-  std::vector<rchandle<parsenode> >::const_iterator end() const { return vfo_hv.end(); }
-
-  const VarDecl* findVarDecl(const QName& varname);
+  csize size() const { return theDecls.size(); }
+
+  void push_back(const rchandle<parsenode>& vfo);
+
+  rchandle<parsenode> operator[](int k) const { return theDecls[k]; }
+
+  std::vector<rchandle<parsenode> >::const_iterator begin() const 
+  {
+    return theDecls.begin();
+  }
+
+  std::vector<rchandle<parsenode> >::const_iterator end() const
+  {
+    return theDecls.end();
+  }
 
   void accept(parsenode_visitor&) const;
 };

=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp	2012-07-31 22:06:33 +0000
+++ src/compiler/translator/translator.cpp	2012-08-09 14:58:27 +0000
@@ -3169,7 +3169,7 @@
   //  (3) and then creates the udf object and binds it in the sctx.
   // The 1st pass also binds all options, so that the module version information
   // is available if we try to load external function libraries.
-  // 2nd pass;  happens when accept() is called on each individual FunctionDecl
+  // The 2nd pass happens when accept() is called on each individual FunctionDecl
   // node in the list.
 
   for (std::vector<rchandle<parsenode> >::const_iterator it = v.begin();

=== added file 'test/rbkt/ExpQueryResults/zorba/xqddf/test5.xml.res'
=== added file 'test/rbkt/Queries/zorba/xqddf/test5.xq'
--- test/rbkt/Queries/zorba/xqddf/test5.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqddf/test5.xq	2012-08-09 14:58:27 +0000
@@ -0,0 +1,7 @@
+import module namespace guestbook = "http://www.28msec.com/guestbook"; at "test5.xqlib";
+
+
+import module namespace db = "http://www.zorba-xquery.com/modules/store/static/collections/ddl";;
+
+
+db:create($guestbook:entries);

=== added file 'test/rbkt/Queries/zorba/xqddf/test5.xqlib'
--- test/rbkt/Queries/zorba/xqddf/test5.xqlib	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqddf/test5.xqlib	2012-08-09 14:58:27 +0000
@@ -0,0 +1,28 @@
+module namespace guestbook = "http://www.28msec.com/guestbook";;
+
+import module namespace functx = "http://www.functx.com/";;
+
+import module namespace db = "http://www.zorba-xquery.com/modules/store/static/collections/dml";;
+
+import module namespace idx = "http://www.zorba-xquery.com/modules/store/static/indexes/dml";;
+
+declare namespace an = "http://www.zorba-xquery.com/annotations";;
+
+declare collection guestbook:entries as node()*;
+
+declare variable $guestbook:entries as xs:QName := xs:QName("guestbook:entries");
+
+(: Access a document range :)
+declare %private %an:automatic %an:unique %an:value-range index guestbook:by-date
+on nodes db:collection(xs:QName('guestbook:entries'))
+by guestbook:convert-dateTime(@datetime) as xs:dateTime;
+
+
+declare %private variable $guestbook:by-date as xs:QName := xs:QName('guestbook:by-date');
+
+
+declare function guestbook:convert-dateTime($dateTime as xs:string) as xs:dateTime 
+{
+  current-dateTime()
+};
+


Follow ups