← Back to team overview

zorba-coders team mailing list archive

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

 

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

Requested reviews:
  Markos Zaharioudakis (markos-za)

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

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)
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-899364/+merge/118727
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2012-08-07 14:45:59 +0000
+++ ChangeLog	2012-08-08 12:26:10 +0000
@@ -16,10 +16,10 @@
     http://www.zorba-xquery.com/modules/store/data-structures/unordered-map module.
   * Added support for fragments to fn:path
   * Positional pagination support for collections
-  * New function in the http://www.zorba-xquery.com/modules/store/static/indexes/dml module which returns
-    the value of all keys contained in an index
+  * New function in the http://www.zorba-xquery.com/modules/store/static/indexes/dml
+    module which returns the value of all keys contained in an index
   * Incremental maintenance for general indexes
-	
+
 Optimizations:
   * Optimization of comparison operations
   * Tighter hoisting of expressions (also fixes bug #967428)

=== modified file 'include/zorba/pregenerated/diagnostic_list.h'
--- include/zorba/pregenerated/diagnostic_list.h	2012-07-30 12:23:36 +0000
+++ include/zorba/pregenerated/diagnostic_list.h	2012-08-08 12:26:10 +0000
@@ -144,6 +144,8 @@
 
 extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0099;
 
+extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0103;
+
 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	2012-07-24 08:48:48 +0000
+++ modules/w3c/pregenerated/xqt-errors.xq	2012-08-08 12:26:10 +0000
@@ -609,6 +609,14 @@
 
 (:~
  :
+ : All variables in a window clause must have distinct names.
+ : 
+ : @see http://www.w3.org/2005/xqt-errors
+:)
+declare variable $err:XQST0103 as xs:QName := fn:QName($err:NS, "err:XQST0103");
+
+(:~
+ :
  : 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/compiler/expression/flwor_expr.cpp'
--- src/compiler/expression/flwor_expr.cpp	2012-07-24 08:48:48 +0000
+++ src/compiler/expression/flwor_expr.cpp	2012-08-08 12:26:10 +0000
@@ -77,8 +77,32 @@
 void forletwin_clause::set_var(var_expr_t v)
 {
   theVarExpr = v;
+
   if (theVarExpr != NULL)
+  {
     theVarExpr->set_flwor_clause(this);
+
+    if (theKind == window_clause && theVarExpr->get_type() != NULL)
+    {
+      RootTypeManager& rtm = GENV_TYPESYSTEM;
+      TypeManager* tm = theVarExpr->get_type_manager();
+
+      const QueryLoc& loc = theVarExpr->get_loc();
+
+      xqtref_t varType = theVarExpr->get_type();
+      xqtref_t domainType = theDomainExpr->get_return_type();
+
+      if (!TypeOps::is_subtype(tm, *rtm.ITEM_TYPE_STAR, *varType, loc) &&
+          !TypeOps::is_subtype(tm, *domainType, *varType, loc))
+      {
+        theDomainExpr = new treat_expr(theDomainExpr->get_sctx(),
+                                       theDomainExpr->get_loc(),
+                                       theDomainExpr,
+                                       varType,
+                                       TreatIterator::TYPE_MATCH);
+      }
+    }
+  }
 }
 
 
@@ -245,6 +269,7 @@
     TypeManager* tm = sctx->get_typemanager();
 
     xqtref_t declaredType = varExpr->get_type();
+
     if (declaredType != NULL)
     {
       xqtref_t domainType = domainExpr->get_return_type();
@@ -253,6 +278,7 @@
           !TypeOps::is_subtype(tm, *domainType, *declaredType, loc))
       {
         xqtref_t varType = TypeOps::intersect_type(*domainType, *declaredType, tm);
+
         if (TypeOps::is_equal(tm, *varType, *rtm.NONE_TYPE, loc))
         {
           RAISE_ERROR(err::XPTY0004, loc,
@@ -349,6 +375,7 @@
     TypeManager* tm = sctx->get_typemanager();
 
     xqtref_t varType = varExpr->get_type();
+
     if (varType != NULL)
     {
       xqtref_t domainType = domainExpr->get_return_type();

=== 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-08 12:26:10 +0000
@@ -1128,14 +1128,27 @@
 {
   assert(sctx != NULL);
 
-  if(e->get_kind() == var_expr::let_var)
+  switch (e->get_kind())
+  {
+  case var_expr::let_var:
   {
     sctx->bind_var(e, e->get_loc(), err::XQST0039);
-  }
-  else
+    break;
+  }
+  case var_expr::win_var:
+  case var_expr::wincond_out_var:
+  case var_expr::wincond_out_pos_var:
+  case var_expr::wincond_in_var:
+  case var_expr::wincond_in_pos_var:
+  {
+    sctx->bind_var(e, e->get_loc(), err::XQST0103);
+    break;
+  }
+  default:
   {
     sctx->bind_var(e, e->get_loc(), err::XQST0049);
   }
+  }
 }
 
 
@@ -5883,7 +5896,6 @@
     {
       // window var + output window condition vars
       pop_scope();
-      pop_scope();
       break;
     }
     case flwor_clause::group_clause:
@@ -6223,10 +6235,6 @@
   var_expr_t windowVarExpr = pop_nodestack_var();
   windowVarExpr->set_flwor_clause(windowClause);
 
-  // Create scope for the output window-condition vars. These vars are visible
-  // outside the window clause only.
-  push_scope();
-
   // Create var_exprs for output window-condition vars, associate them with this
   // window clause, and push them to the nodestack.
   rchandle<FLWORWinCond> cond;
@@ -6357,33 +6365,6 @@
 
 
 /*******************************************************************************
-  WindowVarDecl ::= "$" VarName TypeDeclaration? "in"  ExprSingle
-********************************************************************************/
-void* begin_visit(const WindowVarDecl& v)
-{
-  TRACE_VISIT();
-
-  // Done with input window condition vars.
-  pop_scope();
-
-  return no_state;
-}
-
-void end_visit(const WindowVarDecl& v, void* /*visit_state*/)
-{
-  TRACE_VISIT_OUT();
-
-  // Create scope for the window var
-  push_scope();
-
-  xqtref_t type = (v.get_var_type() == NULL ? NULL : pop_tstack());
-
-  var_expr_t ve = bind_var(loc, v.get_var_name(), var_expr::win_var, type);
-  push_nodestack(ve.getp());
-}
-
-
-/*******************************************************************************
   WindowStartCondition ::= "start" WindowVars "when" ExprSingle
 
   WindowEndCondition ::= "only"? "end" WindowVars "when" ExprSingle
@@ -6424,6 +6405,33 @@
 }
 
 
+/*******************************************************************************
+  WindowVarDecl ::= "$" VarName TypeDeclaration? "in"  ExprSingle
+********************************************************************************/
+void* begin_visit(const WindowVarDecl& v)
+{
+  TRACE_VISIT();
+
+  // Done with input window condition vars.
+  pop_scope();
+
+  return no_state;
+}
+
+void end_visit(const WindowVarDecl& v, void* /*visit_state*/)
+{
+  TRACE_VISIT_OUT();
+
+  // Create scope for the window var and the output window-condition vars
+  push_scope();
+
+  xqtref_t type = (v.get_var_type() == NULL ? NULL : pop_tstack());
+
+  var_expr_t ve = bind_var(loc, v.get_var_name(), var_expr::win_var, type);
+
+  push_nodestack(ve.getp());
+}
+
 
 /*******************************************************************************
   GroupByClause ::= "group" "by" GroupingSpecList

=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml	2012-08-02 13:41:29 +0000
+++ src/diagnostics/diagnostic_en.xml	2012-08-08 12:26:10 +0000
@@ -605,6 +605,13 @@
       <value>module contains more than one context item declaration</value>
     </diagnostic>
 
+    <diagnostic code="XQST0103">
+      <comment>
+      All variables in a window clause must have distinct names.
+      </comment>
+      <value>$1: non-distinct variable in window clause</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-07-30 12:23:36 +0000
+++ src/diagnostics/pregenerated/diagnostic_list.cpp	2012-08-08 12:26:10 +0000
@@ -199,6 +199,9 @@
 XQueryErrorCode XQST0099( "XQST0099" );
 
 
+XQueryErrorCode XQST0103( "XQST0103" );
+
+
 XQueryErrorCode XQST0106( "XQST0106" );
 
 

=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp	2012-08-02 13:42:35 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp	2012-08-08 12:26:10 +0000
@@ -238,6 +238,7 @@
   { "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" },
+  { "XQST0103", "$1: non-distinct variable in window clause" },
   { "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" },

=== modified file 'test/rbkt/Queries/CMakeLists.txt'
--- test/rbkt/Queries/CMakeLists.txt	2012-08-03 04:35:01 +0000
+++ test/rbkt/Queries/CMakeLists.txt	2012-08-08 12:26:10 +0000
@@ -562,20 +562,6 @@
 EXPECTED_FAILURE(test/rbkt/zorba/ext_var/w3c/extvardef-015 923686)
 EXPECTED_FAILURE(test/rbkt/zorba/ext_var/w3c/extvardef-016 923686)
 
-# Failing windowing tests.
-EXPECTED_FAILURE(test/rbkt/zorba/windowing/tumbling22 899363)
-
-EXPECTED_FAILURE(test/rbkt/zorba/windowing/tumbling44 899366)
-
-EXPECTED_FAILURE(test/rbkt/zorba/windowing/tumbling14 899364)
-EXPECTED_FAILURE(test/rbkt/zorba/windowing/tumbling16 899364)
-EXPECTED_FAILURE(test/rbkt/zorba/windowing/tumbling15 899364)
-EXPECTED_FAILURE(test/rbkt/zorba/windowing/tumbling18 899364)
-EXPECTED_FAILURE(test/rbkt/zorba/windowing/tumbling19 899364)
-EXPECTED_FAILURE(test/rbkt/zorba/windowing/tumbling20 899364)
-EXPECTED_FAILURE(test/rbkt/zorba/windowing/tumbling17 899364)
-EXPECTED_FAILURE(test/rbkt/zorba/windowing/tumbling21 899364)
-
 # Failing due to flworfound.org hosting changes.
 EXPECTED_FAILURE(test/rbkt/zorba/versioning/import5 1022495)
 EXPECTED_FAILURE(test/rbkt/zorba/fetch/fetch_bogus2 1022494)


Follow ups