Changeset: 0d847c10703d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0d847c10703d
Modified Files:
        monetdb5/optimizer/opt_mergetable.mx
Branch: default
Log Message:

Merge with Aug2011 branch.


diffs (truncated from 468 to 300 lines):

diff --git a/monetdb5/optimizer/opt_mergetable.mx 
b/monetdb5/optimizer/opt_mergetable.mx
--- a/monetdb5/optimizer/opt_mergetable.mx
+++ b/monetdb5/optimizer/opt_mergetable.mx
@@ -167,6 +167,7 @@ typedef struct mat {
        InstrPtr mm;    /* mat merge statement (needed for group/order by's and 
topn ) */
        int mv;         /* mat variable */
        int mv1;        /* second result variable */
+       int pushed;
        mat_type type;  /* type of operation */
 } mat_t;
 
@@ -461,23 +462,14 @@ MATpackAll2(MalBlkPtr mb, InstrPtr mi, m
        return 0;
 }
 
-/*
-static int
-pack_all_mats(mat_t *mat, int mtop, MalBlkPtr mb )
-{
-       while(mtop > 0) 
-               (void)MATpackAll(mb, NULL, mat, 0, &mtop);
-       return 0;
-}
-*/
-
 inline static int
-mat_add(mat_t *mat, int mtop, InstrPtr q, InstrPtr r, mat_type type) 
+mat_add(mat_t *mat, int mtop, InstrPtr q, InstrPtr r, mat_type type, int 
pushed) 
 {
        mat[mtop].mi = q;
        mat[mtop].mi1 = r;
        mat[mtop].mv = getArg(q,0);
        mat[mtop].mv1 = -1;
+       mat[mtop].pushed = pushed;
        if (r)
                mat[mtop].mv1 = getArg(r,0);
        mat[mtop].type = type;
@@ -618,8 +610,8 @@ disjoint(mat_t *mat, int *mtop, int m, M
                        r = pushArgument(mb, r, vj);
                }
        }
-       pushInstruction(mb,r);
-       *mtop = mat_add(mat, *mtop, r, NULL, mat_none);
+       //pushInstruction(mb,r);
+       *mtop = mat_add(mat, *mtop, r, NULL, mat_none, 0);
        GDKfree(used);
        return *mtop -1;
 }
@@ -773,7 +765,7 @@ mat_map(MalBlkPtr mb, InstrPtr p, mat_t 
                r = pushArgument(mb,r,getArg(q,0));
        }
        if (reuse < 0)
-               mtop = mat_add(mat, mtop, r, NULL, mat_none );
+               mtop = mat_add(mat, mtop, r, NULL, mat_none, 0 );
        return mtop;
 }
 
@@ -912,7 +904,7 @@ mat_join(MalBlkPtr mb, InstrPtr p, mat_t
        }
        if (r && r->argc <= 1) 
                return -1;
-       mtop = mat_add(mat, mtop, r, NULL, (m>=0)?useMatType(mat, m):mat_none);
+       mtop = mat_add(mat, mtop, r, NULL, (m>=0)?useMatType(mat, m):mat_none, 
0);
        if (m >= 0 && mat[m].type == mat_ext)
                (void)MATpackAll2(mb, NULL, mat, mtop-1, &mtop); 
        return mtop;
@@ -1549,7 +1541,7 @@ mat_group_new(MalBlkPtr mb, InstrPtr p, 
                r0 = pushArgument(mb,r0,getArg(q,0));
                r1 = pushArgument(mb,r1,getArg(q,1));
        }
-       mtop = mat_add(mat, mtop, r0, r1, mat_grp);
+       mtop = mat_add(mat, mtop, r0, r1, mat_grp, 0);
        if (getFunctionId(p) == doneRef)
                mat_pack_group(mb, mat, mtop-1, mtop-1);
        return mtop;
@@ -1595,7 +1587,7 @@ mat_group_derive(MalBlkPtr mb, InstrPtr 
                }
            }
        }
-       mtop = mat_add(mat, mtop, r0, r1, mat_grp);
+       mtop = mat_add(mat, mtop, r0, r1, mat_grp, 0);
        if (getFunctionId(p) == doneRef)
                mat_pack_group(mb, mat, mtop-1, mtop-1);
        return mtop;
@@ -1623,7 +1615,7 @@ mat_topn(MalBlkPtr mb, InstrPtr p, mat_t
                propagateProp(mb, q, getArg(q,1));
                pck = pushArgument(mb,pck,getArg(q,0));
        }
-       return mat_add(mat, mtop, pck, NULL, isSlice(p)?mat_slc:mat_tpn);
+       return mat_add(mat, mtop, pck, NULL, isSlice(p)?mat_slc:mat_tpn, 0);
 }
 
 static int
@@ -1649,7 +1641,7 @@ mat_topn2(MalBlkPtr mb, InstrPtr p, mat_
                propagateProp(mb, q, getArg(q,1));
                pck = pushArgument(mb,pck,getArg(q,0));
        }
-       return mat_add(mat, mtop, pck, NULL, mat_tpn);
+       return mat_add(mat, mtop, pck, NULL, mat_tpn, 0);
 }
 
 static int
@@ -1673,7 +1665,7 @@ mat_sort(MalBlkPtr mb, InstrPtr p, mat_t
                propagateProp(mb, q, getArg(q,1));
                pck = pushArgument(mb,pck,getArg(q,0));
        }
-       return mat_add(mat, mtop, pck, NULL, mat_rdr);
+       return mat_add(mat, mtop, pck, NULL, mat_rdr, 0);
 }
 
 static int
@@ -1699,7 +1691,7 @@ mat_sort2(MalBlkPtr mb, InstrPtr p, mat_
                propagateProp(mb, q, getArg(q,1));
                pck = pushArgument(mb,pck,getArg(q,0));
        }
-       return mat_add(mat, mtop, pck, NULL, mat_rdr);
+       return mat_add(mat, mtop, pck, NULL, mat_rdr, 0);
 }
 
 static int
@@ -1756,7 +1748,7 @@ mat_union(MalBlkPtr mb, InstrPtr p, mat_
                        r = pushArgument(mb, r, getArg(p,2));
                }
        }
-       return mat_add(mat, mtop, r, NULL, mat_none);
+       return mat_add(mat, mtop, r, NULL, mat_none, 0);
 }
 
 #if 0
@@ -1894,7 +1886,7 @@ mat_setop(MalBlkPtr mb, InstrPtr p, mat_
        m = isMATalias(getArg(p,1), mat, mtop);
        n = isMATalias(getArg(p,2), mat, mtop);
        if ((bc = mat_apply(mb, p, mat, Mtop, m, n, 0)) != NULL) 
-               *Mtop = mat_add(mat, *Mtop, bc, NULL, useMatType(mat, n) );
+               *Mtop = mat_add(mat, *Mtop, bc, NULL, useMatType(mat, n), 0 );
        return 0;
 }
 
@@ -1944,7 +1936,7 @@ OPTmergetableImplementation(Client cntxt
                p = old[i];
                if (getModuleId(p) == matRef && 
                   (getFunctionId(p) == newRef || getFunctionId(p) == packRef)){
-                       mtop = mat_add(mat, mtop, p, NULL, mat_none);
+                       mtop = mat_add(mat, mtop, p, NULL, mat_none, 1);
                        continue;
                }
 
@@ -2019,7 +2011,6 @@ OPTmergetableImplementation(Client cntxt
                        if ((m = mat_join(mb, p, mat, mtop, m, n)) < 0) {
                                error++;
                                goto fail;
-                               /*mtop = pack_all_mats(mat, mtop, mb);*/
                        } else
                                mtop = m;
                        /* after topn projection we should merge */
@@ -2233,7 +2224,7 @@ OPTmergetableImplementation(Client cntxt
 
                        m = isMATalias(getArg(p,1), mat, mtop);
                        mark = mat_mark(mb, p, mat, m);
-                       mtop = mat_add(mat, mtop, mark, NULL, useMatType(mat, 
m));
+                       mtop = mat_add(mat, mtop, mark, NULL, useMatType(mat, 
m), 0);
                        actions++;
                        continue;
                }
@@ -2257,7 +2248,7 @@ OPTmergetableImplementation(Client cntxt
                        InstrPtr r;
 
                        if ((r = mat_apply1(mb, p, mat, m, fm, 0)) != NULL)
-                               mtop = mat_add(mat, mtop, r, NULL, mat_none);
+                               mtop = mat_add(mat, mtop, r, NULL, mat_none, 0);
                        actions++;
                        continue;
                }
@@ -2288,7 +2279,7 @@ OPTmergetableImplementation(Client cntxt
                        }
 
                        if ((r = mat_apply1(mb, p, mat, m, fm, 0)) != NULL)
-                               mtop = mat_add(mat, mtop, r, NULL, 
useMatType(mat, m));
+                               mtop = mat_add(mat, mtop, r, NULL, 
useMatType(mat, m), 0);
 
                        /* packed group should include the mirror statement */
                        if (pack_mirror) {
@@ -2371,6 +2362,14 @@ fail:
        }
        DEBUGoptimizers
                mnstr_printf(cntxt->fdout,"#opt_mergetable: %d merge 
actions\n",actions);
+       for (i =0; i<mtop; i++) {
+               if (mat[i].pushed == 1)
+                       continue;
+               if (mat[i].mi && mat[i].mi->token != NOOPsymbol)
+                       freeInstruction(mat[i].mi);
+               if (mat[i].mi1 && mat[i].mi1->token != NOOPsymbol)
+                       freeInstruction(mat[i].mi1);
+       }
        GDKfree(mat);
        return actions;
 }
diff --git a/sql/test/BugTracker-2011/Tests/All 
b/sql/test/BugTracker-2011/Tests/All
--- a/sql/test/BugTracker-2011/Tests/All
+++ b/sql/test/BugTracker-2011/Tests/All
@@ -32,3 +32,5 @@ recursive_case.Bug-2838
 str_cast_exception.Bug-2847
 case-when-alias.Bug-2848
 multicolumn_constraints.Bug-2849
+CASE_nested_functions.Bug-2852
+FK_self_reference.Bug-2862
diff --git a/sql/test/BugTracker-2011/Tests/CASE_nested_functions.Bug-2852.sql 
b/sql/test/BugTracker-2011/Tests/CASE_nested_functions.Bug-2852.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2011/Tests/CASE_nested_functions.Bug-2852.sql
@@ -0,0 +1,22 @@
+CREATE TABLE t2852 (c INT);
+INSERT INTO t2852 VALUES (0);
+SELECT
+        COALESCE(
+            COALESCE("c"  /
+              CASE 
+              WHEN COALESCE("c" , 0)  = 0 
+              THEN
+              NULL
+              END
+            , 0)  - COALESCE("c"  /
+                      CASE
+                      WHEN "c"  = 0 
+                      THEN
+                      NULL
+                      END
+            ,0)
+        , 0)
+    FROM
+      t2852
+  ;
+DROP TABLE t2852;
diff --git 
a/sql/test/BugTracker-2011/Tests/CASE_nested_functions.Bug-2852.stable.err 
b/sql/test/BugTracker-2011/Tests/CASE_nested_functions.Bug-2852.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2011/Tests/CASE_nested_functions.Bug-2852.stable.err
@@ -0,0 +1,37 @@
+stderr of test 'CASE_nested_functions.Bug-2852` in directory 
'test/BugTracker-2011` itself:
+
+
+# 16:37:21 >  
+# 16:37:21 >   mserver5  --debug=10 --set gdk_nr_threads=0  --set 
"gdk_dbfarm=/net/rig.ins.cwi.nl/export/scratch0/manegold/Monet/HG/Aug2011/prefix/_/var/MonetDB"
 --set mapi_open=true --set mapi_port=39719 --set monet_prompt= --trace 
--forcemito --set mal_listing=2  "--dbname=mTests_test_BugTracker-2011" --set 
mal_listing=0 ; echo ; echo Over..
+# 16:37:21 >  
+
+# builtin opt  gdk_dbname = demo
+# builtin opt  gdk_dbfarm = 
/net/rig.ins.cwi.nl/export/scratch0/manegold/Monet/HG/Aug2011/prefix/_/var/monetdb5/dbfarm
+# builtin opt  gdk_debug = 0
+# builtin opt  gdk_alloc_map = no
+# builtin opt  gdk_vmtrim = yes
+# builtin opt  monet_prompt = >
+# builtin opt  monet_daemon = no
+# builtin opt  mapi_port = 50000
+# builtin opt  mapi_open = false
+# builtin opt  mapi_autosense = false
+# builtin opt  sql_optimizer = default_pipe
+# builtin opt  sql_debug = 0
+# cmdline opt  gdk_nr_threads = 0
+# cmdline opt  gdk_dbfarm = 
/net/rig.ins.cwi.nl/export/scratch0/manegold/Monet/HG/Aug2011/prefix/_/var/MonetDB
+# cmdline opt  mapi_open = true
+# cmdline opt  mapi_port = 39719
+# cmdline opt  monet_prompt = 
+# cmdline opt  mal_listing = 2
+# cmdline opt  gdk_dbname = mTests_test_BugTracker-2011
+# cmdline opt  mal_listing = 0
+
+# 16:37:21 >  
+# 16:37:21 >  mclient -lsql -ftest -i -e --host=rig --port=39719 
+# 16:37:21 >  
+
+
+# 16:37:23 >  
+# 16:37:23 >  Done.
+# 16:37:23 >  
+
diff --git 
a/sql/test/BugTracker-2011/Tests/CASE_nested_functions.Bug-2852.stable.out 
b/sql/test/BugTracker-2011/Tests/CASE_nested_functions.Bug-2852.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2011/Tests/CASE_nested_functions.Bug-2852.stable.out
@@ -0,0 +1,61 @@
+stdout of test 'CASE_nested_functions.Bug-2852` in directory 
'test/BugTracker-2011` itself:
+
+
+# 16:37:21 >  
+# 16:37:21 >   mserver5  --debug=10 --set gdk_nr_threads=0  --set 
"gdk_dbfarm=/net/rig.ins.cwi.nl/export/scratch0/manegold/Monet/HG/Aug2011/prefix/_/var/MonetDB"
 --set mapi_open=true --set mapi_port=39719 --set monet_prompt= --trace 
--forcemito --set mal_listing=2  "--dbname=mTests_test_BugTracker-2011" --set 
mal_listing=0 ; echo ; echo Over..
+# 16:37:21 >  
+
+# MonetDB 5 server v11.5.0
+# This is an unreleased version
+# Serving database 'mTests_test_BugTracker-2011', using 4 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs dynamically 
linked
+# Found 7.749 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2011 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://rig.ins.cwi.nl:39719/
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+
+Ready.
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to