Changeset: 239017b3bde8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=239017b3bde8
Added Files:
        sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6418.sql
        sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6418.stable.err
        sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6418.stable.out
Modified Files:
        sql/server/rel_optimizer.c
        sql/test/BugTracker-2017/Tests/All
Branch: Jul2017
Log Message:

fixed bug 6418, ie add full projection list in unions (split outerjoin rewriter)


diffs (173 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
@@ -7418,10 +7418,11 @@ static sql_rel *
 rel_split_outerjoin(int *changes, mvc *sql, sql_rel *rel)
 {
        if ((rel->op == op_left || rel->op == op_right || rel->op == op_full) 
&& 
-                       list_length(rel->exps) && exps_nr_of_or(rel->exps) == 
list_length(rel->exps)) { 
+                       list_length(rel->exps) == 1 && exps_nr_of_or(rel->exps) 
== list_length(rel->exps)) { 
                sql_rel *l = rel_dup(rel->l), *nl, *nll, *nlr;
                sql_rel *r = rel_dup(rel->r), *nr;
                sql_exp *e;
+               list *exps;
 
                nll = rel_crossproduct(sql->sa, l, r, op_join); 
                nlr = rel_crossproduct(sql->sa, l, r, op_join); 
@@ -7451,7 +7452,9 @@ rel_split_outerjoin(int *changes, mvc *s
                                rel_projections(sql, l, NULL, 1, 1));
                        /* add null's for right */
                        add_nulls( sql, nr, r);
+                       exps = rel_projections(sql, nl, NULL, 1, 1);
                        nl = rel_setop(sql->sa, nl, nr, op_union);
+                       nl->exps = exps;
                        set_processed(nl);
                }
                if (rel->op == op_right || rel->op == op_full) {
@@ -7468,7 +7471,9 @@ rel_split_outerjoin(int *changes, mvc *s
                        nr->exps = list_merge(nr->exps, 
                                rel_projections(sql, r, NULL, 1, 1),
                                (fdup)NULL);
+                       exps = rel_projections(sql, nl, NULL, 1, 1);
                        nl = rel_setop(sql->sa, nl, nr, op_union);
+                       nl->exps = exps;
                        set_processed(nl);
                }
 
diff --git a/sql/test/BugTracker-2017/Tests/All 
b/sql/test/BugTracker-2017/Tests/All
--- a/sql/test/BugTracker-2017/Tests/All
+++ b/sql/test/BugTracker-2017/Tests/All
@@ -76,3 +76,4 @@ sqlitelogictest-having-with-in.Bug-6410
 sqlitelogictest-aggregation-distinct.Bug-6411
 sqlitelogictest-aggregation-not-in.Bug-6416
 sqlsmith-semijoin-constant.bug-6417
+sqlsmith.Bug-6418
diff --git a/sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6418.sql 
b/sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6418.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6418.sql
@@ -0,0 +1,23 @@
+CREATE TABLE PARTSUPP ( PS_PARTKEY     INTEGER NOT NULL,
+                             PS_SUPPKEY     INTEGER NOT NULL,
+                             PS_AVAILQTY    INTEGER NOT NULL,
+                             PS_SUPPLYCOST  DECIMAL(15,2)  NOT NULL,
+                             PS_COMMENT     VARCHAR(199) NOT NULL );
+select  
+  ref_2.key_type_id as c0, 
+  ref_3.ps_availqty as c1, 
+  sample_0.name as c2
+from 
+  tmp.idxs as sample_0
+      right join sys.sequences as sample_1
+      on ((true) 
+          or ((sample_0.name is NULL) 
+            or (sample_0.type is not NULL)))
+    inner join sys.key_types as ref_2
+      left join sys.partsupp as ref_3
+      on (ref_2.key_type_id is not NULL)
+    on (sample_1.schema_id is NULL)
+where true
+limit 116;
+
+drop table partsupp;
diff --git a/sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6418.stable.err 
b/sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6418.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6418.stable.err
@@ -0,0 +1,34 @@
+stderr of test 'sqlsmith.Bug-6418` in directory 'sql/test/BugTracker-2017` 
itself:
+
+
+# 23:28:47 >  
+# 23:28:47 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=30700" "--set" 
"mapi_usock=/var/tmp/mtest-25365/.s.monetdb.30700" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2017"
+# 23:28:47 >  
+
+# builtin opt  gdk_dbpath = 
/home/niels/scratch/rc-monetdb/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 = 30700
+# cmdline opt  mapi_usock = /var/tmp/mtest-25365/.s.monetdb.30700
+# cmdline opt  monet_prompt = 
+# cmdline opt  gdk_dbpath = 
/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2017
+# cmdline opt  gdk_debug = 536870922
+
+# 23:28:48 >  
+# 23:28:48 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-25365" "--port=30700"
+# 23:28:48 >  
+
+
+# 23:28:48 >  
+# 23:28:48 >  "Done."
+# 23:28:48 >  
+
diff --git a/sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6418.stable.out 
b/sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6418.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6418.stable.out
@@ -0,0 +1,57 @@
+stdout of test 'sqlsmith.Bug-6418` in directory 'sql/test/BugTracker-2017` 
itself:
+
+
+# 23:28:47 >  
+# 23:28:47 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=30700" "--set" 
"mapi_usock=/var/tmp/mtest-25365/.s.monetdb.30700" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2017"
+# 23:28:47 >  
+
+# MonetDB 5 server v11.27.6
+# This is an unreleased version
+# Serving database 'mTests_sql_test_BugTracker-2017', using 4 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 128bit integers
+# Found 7.330 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2017 MonetDB B.V., all rights reserved
+# Visit https://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://localhost.nes.nl:30700/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-25365/.s.monetdb.30700
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 23:28:48 >  
+# 23:28:48 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-25365" "--port=30700"
+# 23:28:48 >  
+
+#CREATE TABLE PARTSUPP ( PS_PARTKEY     INTEGER NOT NULL,
+#                             PS_SUPPKEY     INTEGER NOT NULL,
+#                             PS_AVAILQTY    INTEGER NOT NULL,
+#                             PS_SUPPLYCOST  DECIMAL(15,2)  NOT NULL,
+#                             PS_COMMENT     VARCHAR(199) NOT NULL );
+#select  
+#  ref_2.key_type_id as c0, 
+#  ref_3.ps_availqty as c1, 
+#  sample_0.name as c2
+#from 
+#  tmp.idxs as sample_0
+#      right join sys.sequences as sample_1
+#      on ((true) 
+#          or ((sample_0.name is NULL) 
+#            or (sample_0.type is not NULL)))
+#    inner join sys.key_types as ref_2
+#      left join sys.partsupp as ref_3
+#      on (ref_2.key_type_id is not NULL)
+#    on (sample_1.schema_id is NULL)
+#where true
+#limit 116;
+% .L2, .L4,    .L6 # table_name
+% c0,  c1,     c2 # name
+% smallint,    int,    varchar # type
+% 1,   1,      0 # length
+#drop table partsupp;
+
+# 23:28:48 >  
+# 23:28:48 >  "Done."
+# 23:28:48 >  
+
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to