Changeset: 52858676c04b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=52858676c04b
Added Files:
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case-nullif-coalesce.Bug-6565.stable.err
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case-nullif-coalesce.Bug-6565.stable.out
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-mal-calc-undefined.Bug-6566.stable.err
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-mal-calc-undefined.Bug-6566.stable.out
Modified Files:
        sql/server/rel_optimizer.c
        sql/server/rel_select.c
        sql/test/BugTracker-2015/Tests/null.Bug-3833.stable.out
        sql/test/BugTracker-2016/Tests/null_in_null.Bug-3900.stable.out
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-wrong-cast-null.Bug-6551.stable.out
Branch: Mar2018
Log Message:

fxes for bugs 6565 and 6565
6565 make sure we handle just created projections in the project2groupby
6566 when rewriting a function with a 'NULL' argument into NULL, cast it into 
the right type


diffs (256 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
@@ -2812,15 +2812,20 @@ exp_simplify_math( mvc *sql, sql_exp *e,
                if (!f->func->s && list_length(l) == 2) {
                        sql_exp *le = l->h->data;
                        sql_exp *re = l->h->next->data;
+                       sql_subtype *et = exp_subtype(e);
 
                        if (exp_is_atom(le) && exp_is_null(sql, le)) {
                                (*changes)++;
                                exp_setname(sql->sa, le, exp_relname(e), 
exp_name(e));
+                               if (subtype_cmp(et, exp_subtype(le)) != 0)
+                                       le = exp_convert(sql->sa, le, 
exp_subtype(le), et);
                                return le;
                        }
                        if (exp_is_atom(re) && exp_is_null(sql, re)) {
                                (*changes)++;
                                exp_setname(sql->sa, re, exp_relname(e), 
exp_name(e));
+                               if (subtype_cmp(et, exp_subtype(re)) != 0)
+                                       re = exp_convert(sql->sa, re, 
exp_subtype(re), et);
                                return re;
                        }
                }
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
@@ -184,6 +184,8 @@ rel_project2groupby(mvc *sql, sql_rel *g
                g->op = op_groupby;
                g->r = new_exp_list(sql->sa); /* add empty groupby column list 
*/
                
+               if (!g->exps)
+                       g->exps = new_exp_list(sql->sa);
                for (en = g->exps->h; en; en = en->next) {
                        sql_exp *e = en->data;
 
diff --git a/sql/test/BugTracker-2015/Tests/null.Bug-3833.stable.out 
b/sql/test/BugTracker-2015/Tests/null.Bug-3833.stable.out
--- a/sql/test/BugTracker-2015/Tests/null.Bug-3833.stable.out
+++ b/sql/test/BugTracker-2015/Tests/null.Bug-3833.stable.out
@@ -43,8 +43,8 @@ Ready.
 #SELECT (1 = NULL);
 % .L2 # table_name
 % L2 # name
-% tinyint # type
-% 1 # length
+% boolean # type
+% 5 # length
 [ NULL ]
 #SELECT (TRUE OR NULL);
 % .L2 # table_name
diff --git a/sql/test/BugTracker-2016/Tests/null_in_null.Bug-3900.stable.out 
b/sql/test/BugTracker-2016/Tests/null_in_null.Bug-3900.stable.out
--- a/sql/test/BugTracker-2016/Tests/null_in_null.Bug-3900.stable.out
+++ b/sql/test/BugTracker-2016/Tests/null_in_null.Bug-3900.stable.out
@@ -38,8 +38,8 @@ Ready.
 #select null in (1);
 % .L3 # table_name
 % L3 # name
-% tinyint # type
-% 1 # length
+% boolean # type
+% 5 # length
 [ NULL ]
 #select null between null and null;
 % .L2 # table_name
diff --git 
a/sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case-nullif-coalesce.Bug-6565.stable.err
 
b/sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case-nullif-coalesce.Bug-6565.stable.err
new file mode 100644
--- /dev/null
+++ 
b/sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case-nullif-coalesce.Bug-6565.stable.err
@@ -0,0 +1,35 @@
+stderr of test 'sqlitelogictest-complex-case-nullif-coalesce.Bug-6565` in 
directory 'sql/test/BugTracker-2018` itself:
+
+
+# 11:19:51 >  
+# 11:19:51 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=32042" "--set" 
"mapi_usock=/var/tmp/mtest-29502/.s.monetdb.32042" "--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:19:51 >  
+
+# 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 = 32042
+# cmdline opt  mapi_usock = /var/tmp/mtest-29502/.s.monetdb.32042
+# 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:19:51 >  
+# 11:19:51 >  "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-29502" "--port=32042"
+# 11:19:51 >  
+
+
+# 11:19:51 >  
+# 11:19:51 >  "Done."
+# 11:19:51 >  
+
diff --git 
a/sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case-nullif-coalesce.Bug-6565.stable.out
 
b/sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case-nullif-coalesce.Bug-6565.stable.out
new file mode 100644
--- /dev/null
+++ 
b/sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case-nullif-coalesce.Bug-6565.stable.out
@@ -0,0 +1,39 @@
+stdout of test 'sqlitelogictest-complex-case-nullif-coalesce.Bug-6565` in 
directory 'sql/test/BugTracker-2018` itself:
+
+
+# 11:19:51 >  
+# 11:19:51 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=32042" "--set" 
"mapi_usock=/var/tmp/mtest-29502/.s.monetdb.32042" "--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:19:51 >  
+
+# 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:32042/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-29502/.s.monetdb.32042
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 11:19:51 >  
+# 11:19:51 >  "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-29502" "--port=32042"
+# 11:19:51 >  
+
+#SELECT + NULLIF ( + 67, + + NULLIF ( + + 46, 66 - CASE WHEN 51 IN ( + 91 ) 
THEN + SUM ( CAST ( NULL AS INTEGER ) )
+#+ - 92 ELSE - ( - 47 ) END ) ) / - CAST ( NULL AS INTEGER ) + + NULLIF ( - 
COALESCE ( CAST ( - 35 AS INTEGER ), + 6,
+#COUNT ( ALL 28 ) ), 75 + 14 );
+% .L12 # table_name
+% L12 # name
+% bigint # type
+% 1 # length
+[ NULL ]
+
+# 11:19:51 >  
+# 11:19:51 >  "Done."
+# 11:19:51 >  
+
diff --git 
a/sql/test/BugTracker-2018/Tests/sqlitelogictest-mal-calc-undefined.Bug-6566.stable.err
 
b/sql/test/BugTracker-2018/Tests/sqlitelogictest-mal-calc-undefined.Bug-6566.stable.err
new file mode 100644
--- /dev/null
+++ 
b/sql/test/BugTracker-2018/Tests/sqlitelogictest-mal-calc-undefined.Bug-6566.stable.err
@@ -0,0 +1,35 @@
+stderr of test 'sqlitelogictest-mal-calc-undefined.Bug-6566` in directory 
'sql/test/BugTracker-2018` itself:
+
+
+# 13:05:56 >  
+# 13:05:56 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=37783" "--set" 
"mapi_usock=/var/tmp/mtest-17337/.s.monetdb.37783" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/niels/scratch/rc-old/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2018"
 "--set" "embedded_c=true"
+# 13:05:56 >  
+
+# 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 = 37783
+# cmdline opt  mapi_usock = /var/tmp/mtest-17337/.s.monetdb.37783
+# 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
+
+# 13:05:57 >  
+# 13:05:57 >  "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-17337" "--port=37783"
+# 13:05:57 >  
+
+
+# 13:05:57 >  
+# 13:05:57 >  "Done."
+# 13:05:57 >  
+
diff --git 
a/sql/test/BugTracker-2018/Tests/sqlitelogictest-mal-calc-undefined.Bug-6566.stable.out
 
b/sql/test/BugTracker-2018/Tests/sqlitelogictest-mal-calc-undefined.Bug-6566.stable.out
new file mode 100644
--- /dev/null
+++ 
b/sql/test/BugTracker-2018/Tests/sqlitelogictest-mal-calc-undefined.Bug-6566.stable.out
@@ -0,0 +1,51 @@
+stdout of test 'sqlitelogictest-mal-calc-undefined.Bug-6566` in directory 
'sql/test/BugTracker-2018` itself:
+
+
+# 13:05:56 >  
+# 13:05:56 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=37783" "--set" 
"mapi_usock=/var/tmp/mtest-17337/.s.monetdb.37783" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/niels/scratch/rc-old/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2018"
 "--set" "embedded_c=true"
+# 13:05:56 >  
+
+# 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:37783/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-17337/.s.monetdb.37783
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 13:05:57 >  
+# 13:05:57 >  "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-17337" "--port=37783"
+# 13:05:57 >  
+
+#CREATE TABLE tab0(col0 INTEGER, col1 INTEGER, col2 INTEGER);
+#INSERT INTO tab0 VALUES(97,1,99), (15,81,47), (87,21,10);
+[ 3    ]
+#SELECT - col0 - - - col0 * + CAST ( NULL AS INTEGER ) FROM tab0;
+% sys.L3 # table_name
+% L3 # name
+% bigint # type
+% 1 # length
+[ NULL ]
+[ NULL ]
+[ NULL ]
+#SELECT ALL - col1 * - 16 * + CAST ( NULL AS INTEGER ) FROM tab0 cor0;
+% sys.L3 # table_name
+% L3 # name
+% bigint # type
+% 1 # length
+[ NULL ]
+[ NULL ]
+[ NULL ]
+#DROP TABLE tab0;
+
+# 13:05:57 >  
+# 13:05:57 >  "Done."
+# 13:05:57 >  
+
diff --git 
a/sql/test/BugTracker-2018/Tests/sqlitelogictest-wrong-cast-null.Bug-6551.stable.out
 
b/sql/test/BugTracker-2018/Tests/sqlitelogictest-wrong-cast-null.Bug-6551.stable.out
--- 
a/sql/test/BugTracker-2018/Tests/sqlitelogictest-wrong-cast-null.Bug-6551.stable.out
+++ 
b/sql/test/BugTracker-2018/Tests/sqlitelogictest-wrong-cast-null.Bug-6551.stable.out
@@ -26,7 +26,7 @@ Ready.
 #SELECT 0 * + 77 * CAST ( NULL AS INTEGER ) AS col2;
 % .L3 # table_name
 % col2 # name
-% int # type
+% bigint # type
 % 1 # length
 [ NULL ]
 
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to