Changeset: 885e050fdec6 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=885e050fdec6
Added Files:
        sql/test/BugTracker-2018/Tests/ordered-index-error.Bug-6572.stable.err
        sql/test/BugTracker-2018/Tests/ordered-index-error.Bug-6572.stable.out
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case.Bug-6573.stable.err
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case.Bug-6573.stable.out
Modified Files:
        sql/server/rel_optimizer.c
        sql/server/rel_select.c
        sql/test/bugs/Tests/create_insert_select_aggr-bug-00001.stable.out
        sql/test/mergetables/Tests/mergequery.stable.out
Branch: Mar2018
Log Message:

fixes for bugs 6572, 6573 and 6574
also fix select -2*50 cast problem, fix type of function in rewriter.

6572/6574 fixed in dead code optimizer

6573 fixed problem in 'IN' handling with constants


diffs (truncated from 416 to 300 lines):

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
@@ -2865,7 +2865,7 @@ exp_simplify_math( mvc *sql, sql_exp *e,
                                if (la && ra) {
                                        atom *a = atom_mul(la, ra);
 
-                                       if (a) {
+                                       if (a && atom_cast(sql->sa, a, 
exp_subtype(e))) {
                                                sql_exp *ne = exp_atom(sql->sa, 
a);
                                                (*changes)++;
                                                exp_setname(sql->sa, ne, 
exp_relname(e), exp_name(e));
@@ -2959,7 +2959,7 @@ exp_simplify_math( mvc *sql, sql_exp *e,
                                if (la && ra) {
                                        atom *a = atom_add(la, ra);
 
-                                       if (a) {
+                                       if (a) { 
                                                sql_exp *ne = exp_atom(sql->sa, 
a);
                                                (*changes)++;
                                                exp_setname(sql->sa, ne, 
exp_relname(e), exp_name(e));
@@ -6022,12 +6022,14 @@ rel_mark_used(mvc *sql, sql_rel *rel, in
                        sql_rel *l = rel->l;
 
                        positional_exps_mark_used(rel, l);
-               //      rel_mark_used(sql, rel->l, 1);
+                       exps_mark_used(sql->sa, rel, l);
+                       rel_mark_used(sql, rel->l, 0);
                        /* based on child check set expression list */
                        if (is_project(l->op) && need_distinct(l))
                                positional_exps_mark_used(l, rel);
                        positional_exps_mark_used(rel, rel->r);
-               //      rel_mark_used(sql, rel->r, 1);
+                       exps_mark_used(sql->sa, rel, rel->r);
+                       rel_mark_used(sql, rel->r, 0);
                }
                break;
 
@@ -6377,12 +6379,16 @@ rel_dce_down(mvc *sql, sql_rel *rel, lis
                        rel_dce_sub(sql, rel, refs);
                /* fall through */
 
-       case op_insert:
        case op_truncate:
        case op_ddl:
 
                return rel;
 
+       case op_insert:
+               rel_used(rel->r);
+               rel_dce_sub(sql, rel->r, refs);
+               return rel;
+
        case op_update:
        case op_delete:
 
diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -2072,7 +2072,7 @@ rel_logical_value_exp(mvc *sql, sql_rel 
                ek.card = card_set;
                if (!left) {
                        left = *rel;
-                       if (outer && !outer->l && !list_empty(outer->exps) && 
needproj) {
+                       if (!exp_is_atom(l) && outer && !outer->l && 
!list_empty(outer->exps) && needproj) {
                                l = rel_project_add_exp(sql, left, l);
                                l = exp_column(sql->sa, exp_relname(l), 
exp_name(l), exp_subtype(l), l->card, has_nil(l), is_intern(l));
                        }
diff --git 
a/sql/test/BugTracker-2018/Tests/ordered-index-error.Bug-6572.stable.err 
b/sql/test/BugTracker-2018/Tests/ordered-index-error.Bug-6572.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2018/Tests/ordered-index-error.Bug-6572.stable.err
@@ -0,0 +1,35 @@
+stderr of test 'ordered-index-error.Bug-6572` in directory 
'sql/test/BugTracker-2018` itself:
+
+
+# 11:24:04 >  
+# 11:24:04 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=39857" "--set" 
"mapi_usock=/var/tmp/mtest-13995/.s.monetdb.39857" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/niels/scratch/rc-old/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2018"
 "--set" "embedded_c=true"
+# 11:24:04 >  
+
+# builtin opt  gdk_dbpath = 
/home/niels/scratch/rc-old/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 = 39857
+# cmdline opt  mapi_usock = /var/tmp/mtest-13995/.s.monetdb.39857
+# cmdline opt  monet_prompt = 
+# cmdline opt  gdk_dbpath = 
/home/niels/scratch/rc-old/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2018
+# cmdline opt  embedded_c = true
+# cmdline opt  gdk_debug = 553648138
+
+# 11:24:04 >  
+# 11:24:04 >  "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-13995" "--port=39857"
+# 11:24:04 >  
+
+
+# 11:24:04 >  
+# 11:24:04 >  "Done."
+# 11:24:04 >  
+
diff --git 
a/sql/test/BugTracker-2018/Tests/ordered-index-error.Bug-6572.stable.out 
b/sql/test/BugTracker-2018/Tests/ordered-index-error.Bug-6572.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2018/Tests/ordered-index-error.Bug-6572.stable.out
@@ -0,0 +1,45 @@
+stdout of test 'ordered-index-error.Bug-6572` in directory 
'sql/test/BugTracker-2018` itself:
+
+
+# 11:24:04 >  
+# 11:24:04 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=39857" "--set" 
"mapi_usock=/var/tmp/mtest-13995/.s.monetdb.39857" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/niels/scratch/rc-old/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2018"
 "--set" "embedded_c=true"
+# 11:24:04 >  
+
+# MonetDB 5 server v11.29.2
+# This is an unreleased version
+# Serving database 'mTests_sql_test_BugTracker-2018', using 8 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit
+# 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:39857/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-13995/.s.monetdb.39857
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 11:24:04 >  
+# 11:24:04 >  "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-13995" "--port=39857"
+# 11:24:04 >  
+
+#create table t1(v0 int, v1 char(1));
+#insert into t1 values (1,'a'),(2,'b'),(3,'c');
+[ 3    ]
+#create ordered index index_t1_v1 on t1(v1);
+#create table t2(v1 char(1));
+#insert into t2 values ('a');
+[ 1    ]
+#create temp table t3 as
+#(select t1.v0 from t1,t2 where trim(t2.v1)=t1.v1)
+#on commit preserve rows;
+#drop index index_t1_v1;
+#drop table t1;
+#drop table t2;
+#drop table t3;
+
+# 11:24:04 >  
+# 11:24:04 >  "Done."
+# 11:24:04 >  
+
diff --git 
a/sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case.Bug-6573.stable.err
 
b/sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case.Bug-6573.stable.err
new file mode 100644
--- /dev/null
+++ 
b/sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case.Bug-6573.stable.err
@@ -0,0 +1,35 @@
+stderr of test 'sqlitelogictest-complex-case.Bug-6573` in directory 
'sql/test/BugTracker-2018` itself:
+
+
+# 10:51:31 >  
+# 10:51:31 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=39754" "--set" 
"mapi_usock=/var/tmp/mtest-7312/.s.monetdb.39754" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/niels/scratch/rc-old/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2018"
 "--set" "embedded_c=true"
+# 10:51:31 >  
+
+# builtin opt  gdk_dbpath = 
/home/niels/scratch/rc-old/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 = 39754
+# cmdline opt  mapi_usock = /var/tmp/mtest-7312/.s.monetdb.39754
+# cmdline opt  monet_prompt = 
+# cmdline opt  gdk_dbpath = 
/home/niels/scratch/rc-old/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2018
+# cmdline opt  embedded_c = true
+# cmdline opt  gdk_debug = 553648138
+
+# 10:51:31 >  
+# 10:51:31 >  "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-7312" "--port=39754"
+# 10:51:31 >  
+
+
+# 10:51:31 >  
+# 10:51:31 >  "Done."
+# 10:51:31 >  
+
diff --git 
a/sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case.Bug-6573.stable.out
 
b/sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case.Bug-6573.stable.out
new file mode 100644
--- /dev/null
+++ 
b/sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case.Bug-6573.stable.out
@@ -0,0 +1,40 @@
+stdout of test 'sqlitelogictest-complex-case.Bug-6573` in directory 
'sql/test/BugTracker-2018` itself:
+
+
+# 10:51:31 >  
+# 10:51:31 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=39754" "--set" 
"mapi_usock=/var/tmp/mtest-7312/.s.monetdb.39754" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/niels/scratch/rc-old/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2018"
 "--set" "embedded_c=true"
+# 10:51:31 >  
+
+# MonetDB 5 server v11.29.2
+# This is an unreleased version
+# Serving database 'mTests_sql_test_BugTracker-2018', using 8 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit
+# 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:39754/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-7312/.s.monetdb.39754
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 10:51:31 >  
+# 10:51:31 >  "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-7312" "--port=39754"
+# 10:51:31 >  
+
+#SELECT - ( 5 ) AS col1, + CASE WHEN NOT - 43 NOT IN ( + + 33 * 65, - 31 ) 
THEN NULL WHEN ( + ( - 41 ) ) IN
+#( 73 * CASE + + 33 WHEN - 25 THEN - CAST ( NULL AS INTEGER ) ELSE NULL END ) 
THEN 64 WHEN NOT
+#( + CAST ( + CASE + 52 WHEN COUNT ( * ) THEN NULL WHEN 51 THEN - 68 ELSE NULL 
END AS INTEGER ) ) = 50
+#THEN NULL END * 11 + NULLIF ( ( - 3 ) + 51, 32 ) AS col1;
+% .L2, .L17 # table_name
+% col1,        col1 # name
+% tinyint,     smallint # type
+% 2,   1 # length
+[ -5,  NULL    ]
+
+# 10:51:31 >  
+# 10:51:31 >  "Done."
+# 10:51:31 >  
+
diff --git a/sql/test/bugs/Tests/create_insert_select_aggr-bug-00001.stable.out 
b/sql/test/bugs/Tests/create_insert_select_aggr-bug-00001.stable.out
--- a/sql/test/bugs/Tests/create_insert_select_aggr-bug-00001.stable.out
+++ b/sql/test/bugs/Tests/create_insert_select_aggr-bug-00001.stable.out
@@ -73,7 +73,7 @@ Ready.
 #select (4-1)*5;
 % .L2 # table_name
 % L2 # name
-% tinyint # type
+% smallint # type
 % 2 # length
 [ 15   ]
 % sys._tables, sys._tables,    sys._tables,    sys._tables,    sys._tables # 
table_name
diff --git a/sql/test/mergetables/Tests/mergequery.stable.out 
b/sql/test/mergetables/Tests/mergequery.stable.out
--- a/sql/test/mergetables/Tests/mergequery.stable.out
+++ b/sql/test/mergetables/Tests/mergequery.stable.out
@@ -90,46 +90,46 @@ Ready.
 % clob # type
 % 142 # length
 function user.s22_1():void;
-    X_3:void := querylog.define("explain insert into answ\nselect * from 
complete where x>=1.0 and x <=2.0;":str, "default_pipe":str, 68:int);
-barrier X_159:bit := language.dataflow();
-    X_76:bat[:dbl] := bat.new(nil:dbl);
+    X_3:void := querylog.define("explain insert into answ\nselect * from 
complete where x>=1.0 and x <=2.0;":str, "default_pipe":str, 66:int);
+barrier X_155:bit := language.dataflow();
+    X_74:bat[:dbl] := bat.new(nil:dbl);
     X_6:int := sql.mvc();
     X_10:bat[:dbl] := sql.bind(X_6:int, "sys":str, "part1":str, "x":str, 
0:int);
     C_7:bat[:oid] := sql.tid(X_6:int, "sys":str, "part1":str);
     C_38:bat[:oid] := algebra.select(X_10:bat[:dbl], C_7:bat[:oid], 1:dbl, 
2:dbl, true:bit, true:bit, false:bit);
     X_42:bat[:dbl] := algebra.projection(C_38:bat[:oid], X_10:bat[:dbl]);
-    X_48:bat[:dbl] := sql.bind(X_6:int, "sys":str, "part2":str, "x":str, 
0:int);
-    C_46:bat[:oid] := sql.tid(X_6:int, "sys":str, "part2":str);
-    C_71:bat[:oid] := algebra.select(X_48:bat[:dbl], C_46:bat[:oid], 1:dbl, 
2:dbl, true:bit, true:bit, false:bit);
-    X_60:bat[:dbl] := sql.bind(X_6:int, "sys":str, "part2":str, "z":str, 
0:int);
-    X_74:bat[:dbl] := algebra.projection(C_71:bat[:oid], X_60:bat[:dbl]);
-    X_54:bat[:dbl] := sql.bind(X_6:int, "sys":str, "part2":str, "y":str, 
0:int);
-    X_73:bat[:dbl] := algebra.projection(C_71:bat[:oid], X_54:bat[:dbl]);
-    X_72:bat[:dbl] := algebra.projection(C_71:bat[:oid], X_48:bat[:dbl]);
+    X_47:bat[:dbl] := sql.bind(X_6:int, "sys":str, "part2":str, "x":str, 
0:int);
+    C_45:bat[:oid] := sql.tid(X_6:int, "sys":str, "part2":str);
+    C_70:bat[:oid] := algebra.select(X_47:bat[:dbl], C_45:bat[:oid], 1:dbl, 
2:dbl, true:bit, true:bit, false:bit);
+    X_59:bat[:dbl] := sql.bind(X_6:int, "sys":str, "part2":str, "z":str, 
0:int);
+    X_73:bat[:dbl] := algebra.projection(C_70:bat[:oid], X_59:bat[:dbl]);
+    X_53:bat[:dbl] := sql.bind(X_6:int, "sys":str, "part2":str, "y":str, 
0:int);
+    X_72:bat[:dbl] := algebra.projection(C_70:bat[:oid], X_53:bat[:dbl]);
+    X_71:bat[:dbl] := algebra.projection(C_70:bat[:oid], X_47:bat[:dbl]);
     X_27:bat[:dbl] := sql.bind(X_6:int, "sys":str, "part1":str, "z":str, 
0:int);
     X_44:bat[:dbl] := algebra.projection(C_38:bat[:oid], X_27:bat[:dbl]);
     X_20:bat[:dbl] := sql.bind(X_6:int, "sys":str, "part1":str, "y":str, 
0:int);
     X_43:bat[:dbl] := algebra.projection(C_38:bat[:oid], X_20:bat[:dbl]);
-    X_78:bat[:dbl] := bat.append(X_76:bat[:dbl], X_42:bat[:dbl], true:bit);
-    X_80:bat[:dbl] := bat.append(X_78:bat[:dbl], X_72:bat[:dbl], true:bit);
-    X_81:bat[:dbl] := bat.new(nil:dbl);
-    X_82:bat[:dbl] := bat.append(X_81:bat[:dbl], X_43:bat[:dbl], true:bit);
-    X_83:bat[:dbl] := bat.append(X_82:bat[:dbl], X_73:bat[:dbl], true:bit);
-    X_84:bat[:dbl] := bat.new(nil:dbl);
-    X_85:bat[:dbl] := bat.append(X_84:bat[:dbl], X_44:bat[:dbl], true:bit);
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to