Changeset: 629384f37bb0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=629384f37bb0
Added Files:
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-select-nullif-case.Bug-6579.stable.err
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-select-nullif-case.Bug-6579.stable.out
Modified Files:
        sql/backends/monet5/rel_bin.c
        sql/server/rel_optimizer.c
        
sql/test/BugTracker-2008/Tests/auto_coersion_bug.SF-2075157.stable.out.int128
        sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out
        sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out.int128
        sql/test/BugTracker-2014/Tests/manifold.Bug-3556.stable.out
        sql/test/BugTracker-2015/Tests/schemadiff.Bug-3778.stable.out
        sql/test/Tests/median_stdev.stable.out
        sql/test/pg_regress/Tests/select_views.stable.out
Branch: default
Log Message:

fixes for bug 6579, ie split aggr/function into a lower
project earlier.


diffs (truncated from 351 to 300 lines):

diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -510,11 +510,6 @@ exp_bin(backend *be, sql_exp *e, stmt *l
                        if (sel && strcmp(sql_func_mod(f->func), "calc") == 0 
&& nrcols && strcmp(sql_func_imp(f->func), "ifthenelse") != 0)
                                list_append(l,sel);
                }
-               /*
-               if (strcmp(f->func->base.name, "identity") == 0) 
-                       s = stmt_mirror(be, l->h->data);
-               else
-               */
                if (cond_execution) {
                        /* var_x = nil; */
                        nme = number2name(name, 16, ++sql->label);
diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -7063,7 +7063,7 @@ add_exps_too_project(mvc *sql, list *exp
        for(n=exps->h; n; n = n->next) {
                sql_exp *e = n->data;
 
-               if (!exp_is_atom(e) && e->type != e_column)
+               if (/*!exp_is_atom(e) &&*/ e->type != e_column)
                        n->data = add_exp_too_project(sql, e, rel);
        }
 }
@@ -7125,7 +7125,7 @@ split_exps(mvc *sql, list *exps, sql_rel
 static sql_rel *
 rel_split_project(int *changes, mvc *sql, sql_rel *rel, int top) 
 {
-       if (is_project(rel->op) && list_length(rel->exps) && rel->l) {
+       if (is_project(rel->op) && list_length(rel->exps) && 
(is_groupby(rel->op) || rel->l)) {
                list *exps = rel->exps;
                node *n;
                int funcs = 0;
@@ -9199,19 +9199,21 @@ optimize_rel(mvc *sql, sql_rel *rel, int
 #endif
 
        /* simple merging of projects */
-       if (gp.cnt[op_project] || gp.cnt[op_ddl]) {
+       if (gp.cnt[op_project] || gp.cnt[op_groupby] || gp.cnt[op_ddl]) {
                rel = rewrite(sql, rel, &rel_merge_projects, &changes);
+
+               /* push (simple renaming) projections up */
+               if (gp.cnt[op_project])
+                       rel = rewrite(sql, rel, &rel_push_project_up, 
&changes); 
+               if (level <= 0 && (gp.cnt[op_project] || gp.cnt[op_groupby])) 
+                       rel = rel_split_project(&changes, sql, rel, 1);
+
                if (level <= 0) {
                        rel = rewrite(sql, rel, &rel_case_fixup, &changes);
                        rel = rewrite(sql, rel, &rel_simplify_math, &changes);
                        rel = rewrite(sql, rel, &rel_distinct_project2groupby, 
&changes);
                }
        }
-       /* push (simple renaming) projections up */
-       if (gp.cnt[op_project]) 
-               rel = rewrite(sql, rel, &rel_push_project_up, &changes); 
-       if (level <= 0 && (gp.cnt[op_project] || gp.cnt[op_groupby])) 
-               rel = rel_split_project(&changes, sql, rel, 1);
 
        if ((gp.cnt[op_select] || gp.cnt[op_left] || gp.cnt[op_right] || 
gp.cnt[op_full]) && level <= 0)
                rel = rewrite(sql, rel, &rel_simplify_predicates, &changes); 
diff --git 
a/sql/test/BugTracker-2008/Tests/auto_coersion_bug.SF-2075157.stable.out.int128 
b/sql/test/BugTracker-2008/Tests/auto_coersion_bug.SF-2075157.stable.out.int128
--- 
a/sql/test/BugTracker-2008/Tests/auto_coersion_bug.SF-2075157.stable.out.int128
+++ 
b/sql/test/BugTracker-2008/Tests/auto_coersion_bug.SF-2075157.stable.out.int128
@@ -33,7 +33,7 @@ Ready.
 [ 1    ]
 #SELECT SUM(2 * COL1 * COL2)
 #FROM A2;
-% sys.L4 # table_name
+% .L3 # table_name
 % L3 # name
 % hugeint # type
 % 6 # length
diff --git a/sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out 
b/sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out
--- a/sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out
+++ b/sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out
@@ -31,13 +31,13 @@ Ready.
 % .plan # table_name
 % rel # name
 % clob # type
-% 145 # length
+% 117 # length
 project (
 | project (
 | | group by (
 | | | table(sys.dbg) [ "dbg"."a", "dbg"."b" ] COUNT 
 | | ) [ "dbg"."a" as "d" ] [ "dbg"."d", sys.sum no nil ("dbg"."b") as 
"L3"."L3", "L3"."L3" as "L5"."L5" ]
-| ) [ "dbg"."d", "L3"."L3", sys.sql_div("L5"."L5", tinyint "2" as "L7"."L7") 
as "L12"."L12", sys.sql_mul("L12"."L12", tinyint "2") as "L10"."f" ]
+| ) [ "dbg"."d", "L3"."L3", sys.sql_mul(sys.sql_div("L5"."L5", tinyint "2" as 
"L7"."L7"), tinyint "2") as "L10"."f" ]
 ) [ "dbg"."d", "L3"."L3", "L10"."f" ]
 #set optimizer = 'sequential_pipe';
 #set optimizer = 'default_pipe';
@@ -56,13 +56,13 @@ project (
 % .plan # table_name
 % rel # name
 % clob # type
-% 159 # length
+% 131 # length
 project (
 | project (
 | | group by (
 | | | table(sys.dbg) [ "dbg"."a", "dbg"."b" ] COUNT 
 | | ) [ "dbg"."a" as "d" ] [ "dbg"."d", sys.sum no nil ("dbg"."b") as 
"L3"."L3", "L3"."L3" as "L6"."L6" ]
-| ) [ "dbg"."d", "L3"."L3" as "L4"."e", sys.sql_div("L6"."L6", tinyint "2" as 
"L10"."L10") as "L13"."L13", sys.sql_mul("L13"."L13", tinyint "2") as "L11"."f" 
]
+| ) [ "dbg"."d", "L3"."L3" as "L4"."e", sys.sql_mul(sys.sql_div("L6"."L6", 
tinyint "2" as "L10"."L10"), tinyint "2") as "L11"."f" ]
 ) [ "dbg"."d", "L4"."e", "L11"."f" ]
 #set optimizer = 'sequential_pipe';
 #set optimizer = 'default_pipe';
diff --git 
a/sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out.int128 
b/sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out.int128
--- a/sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out.int128
+++ b/sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out.int128
@@ -31,13 +31,13 @@ Ready.
 % .plan # table_name
 % rel # name
 % clob # type
-% 145 # length
+% 117 # length
 project (
 | project (
 | | group by (
 | | | table(sys.dbg) [ "dbg"."a", "dbg"."b" ] COUNT 
 | | ) [ "dbg"."a" as "d" ] [ "dbg"."d", sys.sum no nil ("dbg"."b") as 
"L3"."L3", "L3"."L3" as "L5"."L5" ]
-| ) [ "dbg"."d", "L3"."L3", sys.sql_div("L5"."L5", tinyint "2" as "L7"."L7") 
as "L12"."L12", sys.sql_mul("L12"."L12", tinyint "2") as "L10"."f" ]
+| ) [ "dbg"."d", "L3"."L3", sys.sql_mul(sys.sql_div("L5"."L5", tinyint "2" as 
"L7"."L7"), tinyint "2") as "L10"."f" ]
 ) [ "dbg"."d", "L3"."L3", "L10"."f" ]
 #set optimizer = 'sequential_pipe';
 #set optimizer = 'default_pipe';
@@ -56,13 +56,13 @@ project (
 % .plan # table_name
 % rel # name
 % clob # type
-% 159 # length
+% 131 # length
 project (
 | project (
 | | group by (
 | | | table(sys.dbg) [ "dbg"."a", "dbg"."b" ] COUNT 
 | | ) [ "dbg"."a" as "d" ] [ "dbg"."d", sys.sum no nil ("dbg"."b") as 
"L3"."L3", "L3"."L3" as "L6"."L6" ]
-| ) [ "dbg"."d", "L3"."L3" as "L4"."e", sys.sql_div("L6"."L6", tinyint "2" as 
"L10"."L10") as "L13"."L13", sys.sql_mul("L13"."L13", tinyint "2") as "L11"."f" 
]
+| ) [ "dbg"."d", "L3"."L3" as "L4"."e", sys.sql_mul(sys.sql_div("L6"."L6", 
tinyint "2" as "L10"."L10"), tinyint "2") as "L11"."f" ]
 ) [ "dbg"."d", "L4"."e", "L11"."f" ]
 #set optimizer = 'sequential_pipe';
 #set optimizer = 'default_pipe';
diff --git a/sql/test/BugTracker-2014/Tests/manifold.Bug-3556.stable.out 
b/sql/test/BugTracker-2014/Tests/manifold.Bug-3556.stable.out
--- a/sql/test/BugTracker-2014/Tests/manifold.Bug-3556.stable.out
+++ b/sql/test/BugTracker-2014/Tests/manifold.Bug-3556.stable.out
@@ -129,12 +129,12 @@ end user.s4_1;
 % clob # type
 % 210 # length
 function user.s6_1():void;
-    X_4:void := querylog.define("explain select replace(a1,a2,a3), id\nfrom 
(\n select name as a1, \\'a\\' as a2, \\'A\\' as a3, id + 1 as id \n from 
sys.functions\n) as x;":str, "sequential_pipe":str, 40:int);
-    X_42:bat[:str] := bat.new(nil:str);
-    X_48:bat[:int] := bat.new(nil:int);
-    X_46:bat[:int] := bat.new(nil:int);
+    X_4:void := querylog.define("explain select replace(a1,a2,a3), id\nfrom 
(\n select name as a1, \\'a\\' as a2, \\'A\\' as a3, id + 1 as id \n from 
sys.functions\n) as x;":str, "sequential_pipe":str, 41:int);
+    X_43:bat[:str] := bat.new(nil:str);
+    X_49:bat[:int] := bat.new(nil:int);
+    X_47:bat[:int] := bat.new(nil:int);
+    X_46:bat[:str] := bat.new(nil:str);
     X_45:bat[:str] := bat.new(nil:str);
-    X_44:bat[:str] := bat.new(nil:str);
     X_7:int := sql.mvc();
     C_8:bat[:oid] := sql.tid(X_7:int, "sys":str, "functions":str);
     X_21:bat[:str] := sql.bind(X_7:int, "sys":str, "functions":str, 
"name":str, 0:int);
@@ -149,20 +149,21 @@ function user.s6_1():void;
     X_20:bat[:int] := algebra.projection(C_8:bat[:oid], X_19:bat[:int]);
     X_29:bat[:str] := algebra.project(X_20:bat[:int], "a":str);
     X_31:bat[:str] := algebra.project(X_20:bat[:int], "A":str);
-    X_38:bat[:str] := mal.manifold("str":str, "replace":str, X_27:bat[:str], 
X_29:bat[:str], X_31:bat[:str]);
+    X_39:bat[:str] := mal.manifold("str":str, "replace":str, X_27:bat[:str], 
X_29:bat[:str], X_31:bat[:str]);
     X_32:bat[:lng] := batcalc.lng(X_20:bat[:int]);
-    X_35:bat[:lng] := batcalc.+(X_32:bat[:lng], 1:lng);
-    X_49:bat[:str] := bat.append(X_42:bat[:str], "sys.L12":str);
-    X_51:bat[:str] := bat.append(X_44:bat[:str], "L12":str);
-    X_53:bat[:str] := bat.append(X_45:bat[:str], "varchar":str);
-    X_55:bat[:int] := bat.append(X_46:bat[:int], 0:int);
-    X_57:bat[:int] := bat.append(X_48:bat[:int], 0:int);
-    X_58:bat[:str] := bat.append(X_49:bat[:str], "sys.x":str);
-    X_60:bat[:str] := bat.append(X_51:bat[:str], "id":str);
-    X_62:bat[:str] := bat.append(X_53:bat[:str], "bigint":str);
-    X_64:bat[:int] := bat.append(X_55:bat[:int], 64:int);
-    X_66:bat[:int] := bat.append(X_57:bat[:int], 0:int);
-    sql.resultSet(X_58:bat[:str], X_60:bat[:str], X_62:bat[:str], 
X_64:bat[:int], X_66:bat[:int], X_38:bat[:str], X_35:bat[:lng]);
+    X_35:bat[:lng] := algebra.project(X_20:bat[:int], 1:lng);
+    X_36:bat[:lng] := batcalc.+(X_32:bat[:lng], X_35:bat[:lng]);
+    X_50:bat[:str] := bat.append(X_43:bat[:str], "sys.L12":str);
+    X_52:bat[:str] := bat.append(X_45:bat[:str], "L12":str);
+    X_54:bat[:str] := bat.append(X_46:bat[:str], "varchar":str);
+    X_56:bat[:int] := bat.append(X_47:bat[:int], 0:int);
+    X_58:bat[:int] := bat.append(X_49:bat[:int], 0:int);
+    X_59:bat[:str] := bat.append(X_50:bat[:str], "sys.x":str);
+    X_61:bat[:str] := bat.append(X_52:bat[:str], "id":str);
+    X_63:bat[:str] := bat.append(X_54:bat[:str], "bigint":str);
+    X_65:bat[:int] := bat.append(X_56:bat[:int], 64:int);
+    X_67:bat[:int] := bat.append(X_58:bat[:int], 0:int);
+    sql.resultSet(X_59:bat[:str], X_61:bat[:str], X_63:bat[:str], 
X_65:bat[:int], X_67:bat[:int], X_39:bat[:str], X_36:bat[:lng]);
 end user.s6_1;
 #inline               actions= 0 time=3 usec 
 #candidates           actions= 1 time=23 usec 
diff --git a/sql/test/BugTracker-2015/Tests/schemadiff.Bug-3778.stable.out 
b/sql/test/BugTracker-2015/Tests/schemadiff.Bug-3778.stable.out
--- a/sql/test/BugTracker-2015/Tests/schemadiff.Bug-3778.stable.out
+++ b/sql/test/BugTracker-2015/Tests/schemadiff.Bug-3778.stable.out
@@ -27,7 +27,7 @@ Ready.
 # 11:19:25 >  "/usr/bin/python2" "schemadiff.Bug-3778.SQL.py" 
"schemadiff.Bug-3778"
 # 11:19:25 >  
 
-(mapi:monetdb://monetdb@localhost/worker_0) 'user.l4' undefined in:     
rmt5_X_2_bat_int:bat[:int] := user.l4();
+(mapi:monetdb://monetdb@localhost/worker_0) 'user.l4' undefined in:     
rmt8_X_2_bat_int:bat[:int] := user.l4();
 
 
 # 11:19:26 >  
diff --git 
a/sql/test/BugTracker-2018/Tests/sqlitelogictest-select-nullif-case.Bug-6579.stable.err
 
b/sql/test/BugTracker-2018/Tests/sqlitelogictest-select-nullif-case.Bug-6579.stable.err
new file mode 100644
--- /dev/null
+++ 
b/sql/test/BugTracker-2018/Tests/sqlitelogictest-select-nullif-case.Bug-6579.stable.err
@@ -0,0 +1,35 @@
+stderr of test 'sqlitelogictest-select-nullif-case.Bug-6579` in directory 
'sql/test/BugTracker-2018` itself:
+
+
+# 09:56:14 >  
+# 09:56:14 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=31815" "--set" 
"mapi_usock=/var/tmp/mtest-15495/.s.monetdb.31815" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2018"
 "--set" "embedded_c=true"
+# 09:56:14 >  
+
+# builtin opt  gdk_dbpath = 
/home/niels/scratch/rc-clean/Linux-x86_64/var/monetdb5/dbfarm/demo
+# builtin opt  gdk_debug = 0
+# builtin opt  gdk_vmtrim = no
+# 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  mapi_open = true
+# cmdline opt  mapi_port = 31815
+# cmdline opt  mapi_usock = /var/tmp/mtest-15495/.s.monetdb.31815
+# cmdline opt  monet_prompt = 
+# cmdline opt  gdk_dbpath = 
/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2018
+# cmdline opt  embedded_c = true
+# cmdline opt  gdk_debug = 553648138
+
+# 09:56:14 >  
+# 09:56:14 >  "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-15495" "--port=31815"
+# 09:56:14 >  
+
+
+# 09:56:14 >  
+# 09:56:14 >  "Done."
+# 09:56:14 >  
+
diff --git 
a/sql/test/BugTracker-2018/Tests/sqlitelogictest-select-nullif-case.Bug-6579.stable.out
 
b/sql/test/BugTracker-2018/Tests/sqlitelogictest-select-nullif-case.Bug-6579.stable.out
new file mode 100644
--- /dev/null
+++ 
b/sql/test/BugTracker-2018/Tests/sqlitelogictest-select-nullif-case.Bug-6579.stable.out
@@ -0,0 +1,38 @@
+stdout of test 'sqlitelogictest-select-nullif-case.Bug-6579` in directory 
'sql/test/BugTracker-2018` itself:
+
+
+# 09:56:14 >  
+# 09:56:14 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=31815" "--set" 
"mapi_usock=/var/tmp/mtest-15495/.s.monetdb.31815" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2018"
 "--set" "embedded_c=true"
+# 09:56:14 >  
+
+# MonetDB 5 server v11.30.0
+# This is an unreleased version
+# Serving database 'mTests_sql_test_BugTracker-2018', using 8 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 128bit integers
+# Found 15.387 GiB available main-memory.
+# Copyright (c) 1993 - July 2008 CWI.
+# Copyright (c) August 2008 - 2018 MonetDB B.V., all rights reserved
+# Visit https://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://xps13:31815/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-15495/.s.monetdb.31815
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 09:56:14 >  
+# 09:56:14 >  "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-15495" "--port=31815"
+# 09:56:14 >  
+
+#SELECT ALL - 70 + + - 89 - + ( SUM ( + CASE - NULLIF ( + 87, CASE CAST ( NULL 
AS INTEGER ) WHEN 13 / + ( 68 * - ( 64 ) )
+#THEN + 39 WHEN 70 * - 95 THEN 60 ELSE 15 + + 25 END * 5 ) WHEN + 36 THEN NULL 
WHEN 24 THEN NULL ELSE 66 END ) ) AS col2;
+% .L10 # table_name
+% col2 # name
+% hugeint # type
+% 4 # length
+[ -225 ]
+
+# 09:56:14 >  
+# 09:56:14 >  "Done."
+# 09:56:14 >  
+
diff --git a/sql/test/Tests/median_stdev.stable.out 
b/sql/test/Tests/median_stdev.stable.out
--- a/sql/test/Tests/median_stdev.stable.out
+++ b/sql/test/Tests/median_stdev.stable.out
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to