Update of /cvsroot/monetdb/pathfinder/compiler/core
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16885/core

Modified Files:
      Tag: XQuery_0-24
        coreopt.brg 
Log Message:
-- Added rewrite on the XQuery Core level:
 
   Turn a list of conjunctive predicates
   into a list of unrelated nested predicates.

   example:                        if (exp1)
                                   then if (exp2)
   if (exp1 and exp2 and exp3)          then if (exp3)
   then exp4                   ==>           then exp4
   else ()                                   else ()
                                        else ()
                                   else ()

   This solves bug '[ 1908822 ] PFalg: fails to compile multi-join query'
   as long as we still have bit-encoded column names in the algebra.


U coreopt.brg
Index: coreopt.brg
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/core/coreopt.brg,v
retrieving revision 1.67
retrieving revision 1.67.2.1
diff -u -d -r1.67 -r1.67.2.1
--- coreopt.brg 4 Apr 2008 09:17:18 -0000       1.67
+++ coreopt.brg 29 May 2008 11:51:25 -0000      1.67.2.1
@@ -277,6 +277,9 @@
 CoreExpr:           if_ (CoreExpr,
                          then_else (CoreExpr, CoreExpr))        =   49(10);
                                                                      
+CoreExpr:           if_ (CoreExpr,
+                         then_else (CoreExpr, empty))           =  31 (10);
+                                                                     
 CoreExpr:           seq (seq (CoreExpr, CoreExpr), CoreExpr)    =  15 (10);
 CoreExpr:           seq (CoreExpr, CoreExpr)                    =   50(10);
 CoreExpr:           seq (empty, CoreExpr)                       =  16 (10);
@@ -739,6 +742,31 @@
 
             break;
 
+        /* CoreExpr:           if_ (CoreExpr,
+                                    then_else (CoreExpr, empty)) */
+        case 31:
+            /* rewrite conjunctive selections into nested selections */
+            if (L(p)->kind == c_apply &&
+                !PFqname_eq (L(p)->sem.fun->qname, PFqname (PFns_op, "and"))) {
+                PFcnode_t *sec_arg = LLRL(p);
+                assert (PFty_subtype (TY(sec_arg), PFty_xs_boolean()));
+                L(p) = LLL(p);
+                RL(p) = if_ (sec_arg, then_else (RL(p), empty ()));
+                    
+                /* type-check what we just created */
+                PFty_check (p);
+
+                rewritten = true;
+
+                /*
+                 * Re-label entire subtree. Type-checking may have
+                 * modified all the state labels in the subtree, so
+                 * we have to restore them.
+                 */
+                PFcoreopt_label (p);
+            }
+            break;
+
         /* CoreExpr:           seq (seq (CoreExpr, CoreExpr), CoreExpr) */
         case 15:
         /* CoreExpr:           twig_seq (seq (CoreExpr, CoreExpr), CoreExpr) */


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins

Reply via email to