Changeset: 0260b270032c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0260b270032c
Added Files:
        sql/test/BugTracker-2017/Tests/null_matches_in_outer.Bug-6398.sql
        sql/test/BugTracker-2017/Tests/null_matches_in_outer.Bug-6398.stable.err
        sql/test/BugTracker-2017/Tests/null_matches_in_outer.Bug-6398.stable.out
Modified Files:
        sql/backends/monet5/rel_bin.c
        sql/benchmarks/tpch/fileleak/Tests/leaks.stable.out
        sql/benchmarks/tpch/fileleak/Tests/leaks.stable.out.Windows
        sql/test/BugTracker-2017/Tests/All
Branch: Jul2017
Log Message:

fixed bug 6398, ie handle null matches in outer joins


diffs (248 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
@@ -1952,11 +1952,12 @@ rel2bin_semijoin(backend *be, sql_rel *r
                                idx = 1;
                        /* stop on first non equality join */
                        if (!join) {
+                               if (en->next && s->type != st_join && s->type 
!= st_join2 && s->type != st_joinN) 
+                                       break;
                                join = s;
                        } else if (s->type != st_join && s->type != st_join2 && 
s->type != st_joinN) {
                                /* handle select expressions */
-                               assert(0);
-                               return NULL;
+                               break;
                        }
                        if (s->type == st_join || s->type == st_join2 || 
s->type == st_joinN) { 
                                list_append(lje, s->op1);
@@ -1986,7 +1987,7 @@ rel2bin_semijoin(backend *be, sql_rel *r
                /* construct relation */
                nl = sa_list(sql->sa);
 
-               /* first project using equi-joins */
+               /* first project after equi-joins */
                for( n = left->op4.lval->h; n; n = n->next ) {
                        stmt *c = n->data;
                        const char *rnme = table_name(sql->sa, c);
diff --git a/sql/benchmarks/tpch/fileleak/Tests/leaks.stable.out 
b/sql/benchmarks/tpch/fileleak/Tests/leaks.stable.out
--- a/sql/benchmarks/tpch/fileleak/Tests/leaks.stable.out
+++ b/sql/benchmarks/tpch/fileleak/Tests/leaks.stable.out
@@ -25,22 +25,22 @@ Ready.
 # 16:01:26 >  "/usr/bin/python2" "leaks.SQL.py" "leaks"
 # 16:01:26 >  
 
-(u'l_comment', 262144, 0)
-(u'l_commitdate', 262144, 0)
-(u'l_discount', 524288, 0)
-(u'l_extendedprice', 524288, 0)
-(u'l_linenumber', 262144, 0)
+(u'l_comment', 65536, 0)
+(u'l_commitdate', 65536, 0)
+(u'l_discount', 65536, 0)
+(u'l_extendedprice', 65536, 0)
+(u'l_linenumber', 65536, 0)
 (u'l_linestatus', 0, 0)
-(u'l_orderkey', 262144, 0)
-(u'l_partkey', 262144, 0)
-(u'l_quantity', 524288, 0)
-(u'l_receiptdate', 262144, 0)
+(u'l_orderkey', 65536, 0)
+(u'l_partkey', 65536, 0)
+(u'l_quantity', 65536, 0)
+(u'l_receiptdate', 65536, 0)
 (u'l_returnflag', 0, 0)
-(u'l_shipdate', 262144, 0)
+(u'l_shipdate', 65536, 0)
 (u'l_shipinstruct', 0, 0)
 (u'l_shipmode', 0, 0)
-(u'l_suppkey', 262144, 0)
-(u'l_tax', 524288, 0)
+(u'l_suppkey', 65536, 0)
+(u'l_tax', 65536, 0)
 
 # 16:01:26 >  
 # 16:01:26 >  "Done."
diff --git a/sql/benchmarks/tpch/fileleak/Tests/leaks.stable.out.Windows 
b/sql/benchmarks/tpch/fileleak/Tests/leaks.stable.out.Windows
--- a/sql/benchmarks/tpch/fileleak/Tests/leaks.stable.out.Windows
+++ b/sql/benchmarks/tpch/fileleak/Tests/leaks.stable.out.Windows
@@ -25,22 +25,22 @@ Ready.
 # 16:01:26 >  "/usr/bin/python2" "leaks.SQL.py" "leaks"
 # 16:01:26 >  
 
-(u'l_comment', 262144, 0)
-(u'l_commitdate', 262144, 0)
-(u'l_discount', 524288, 0)
-(u'l_extendedprice', 524288, 0)
-(u'l_linenumber', 262144, 0)
+(u'l_comment', 65536, 0)
+(u'l_commitdate', 65536, 0)
+(u'l_discount', 65536, 0)
+(u'l_extendedprice', 65536, 0)
+(u'l_linenumber', 65536, 0)
 (u'l_linestatus', 0, 0)
-(u'l_orderkey', 262144, 0)
-(u'l_partkey', 262144, 0)
-(u'l_quantity', 524288, 0)
-(u'l_receiptdate', 262144, 0)
+(u'l_orderkey', 65536, 0)
+(u'l_partkey', 65536, 0)
+(u'l_quantity', 65536, 0)
+(u'l_receiptdate', 65536, 0)
 (u'l_returnflag', 0, 0)
-(u'l_shipdate', 262144, 0)
+(u'l_shipdate', 65536, 0)
 (u'l_shipinstruct', 0, 0)
 (u'l_shipmode', 0, 0)
-(u'l_suppkey', 262144, 0)
-(u'l_tax', 524288, 0)
+(u'l_suppkey', 65536, 0)
+(u'l_tax', 65536, 0)
 
 # 16:01:26 >  
 # 16:01:26 >  "Done."
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
@@ -69,3 +69,4 @@ sqllitelogistest_case.Bug-6335
 udf_crash_subquery_scalar_paramters.Bug-6399
 side-effect.Bug-6397
 copy_into_crash.Bug-6404
+null_matches_in_outer.Bug-6398
diff --git a/sql/test/BugTracker-2017/Tests/null_matches_in_outer.Bug-6398.sql 
b/sql/test/BugTracker-2017/Tests/null_matches_in_outer.Bug-6398.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2017/Tests/null_matches_in_outer.Bug-6398.sql
@@ -0,0 +1,24 @@
+
+create table "E" (
+       "intCol" bigint,
+       "stringCol" string
+);
+
+insert into "E" values (0, 'zero');
+insert into "E" values (1, 'one');
+insert into "E" values (2, 'two');
+insert into "E" values (null, null);
+
+create table "I" (
+       "intCol" bigint,
+       "stringCol" string
+);
+
+insert into "I" values (2, 'due');
+insert into "I" values (4, 'quattro');
+insert into "I" values (null, 'this is not null');
+
+select * from "E" left outer join "I" on "E"."intCol" = "I"."intCol" or 
("E"."intCol" is null and  "I"."intCol" is null);
+
+drop table "E";
+drop table "I";
diff --git 
a/sql/test/BugTracker-2017/Tests/null_matches_in_outer.Bug-6398.stable.err 
b/sql/test/BugTracker-2017/Tests/null_matches_in_outer.Bug-6398.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2017/Tests/null_matches_in_outer.Bug-6398.stable.err
@@ -0,0 +1,34 @@
+stderr of test 'null_matches_in_outer.Bug-6398` in directory 
'sql/test/BugTracker-2017` itself:
+
+
+# 21:23:55 >  
+# 21:23:55 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=35535" "--set" 
"mapi_usock=/var/tmp/mtest-31827/.s.monetdb.35535" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2017"
+# 21:23:55 >  
+
+# 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 = 35535
+# cmdline opt  mapi_usock = /var/tmp/mtest-31827/.s.monetdb.35535
+# 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
+
+# 21:23:56 >  
+# 21:23:56 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-31827" "--port=35535"
+# 21:23:56 >  
+
+
+# 21:23:56 >  
+# 21:23:56 >  "Done."
+# 21:23:56 >  
+
diff --git 
a/sql/test/BugTracker-2017/Tests/null_matches_in_outer.Bug-6398.stable.out 
b/sql/test/BugTracker-2017/Tests/null_matches_in_outer.Bug-6398.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2017/Tests/null_matches_in_outer.Bug-6398.stable.out
@@ -0,0 +1,64 @@
+stdout of test 'null_matches_in_outer.Bug-6398` in directory 
'sql/test/BugTracker-2017` itself:
+
+
+# 21:23:55 >  
+# 21:23:55 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=35535" "--set" 
"mapi_usock=/var/tmp/mtest-31827/.s.monetdb.35535" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2017"
+# 21:23:55 >  
+
+# 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:35535/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-31827/.s.monetdb.35535
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 21:23:56 >  
+# 21:23:56 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-31827" "--port=35535"
+# 21:23:56 >  
+
+#create table "E" (
+#      "intCol" bigint,
+#      "stringCol" string
+#);
+#insert into "E" values (0, 'zero');
+[ 1    ]
+#insert into "E" values (1, 'one');
+[ 1    ]
+#insert into "E" values (2, 'two');
+[ 1    ]
+#insert into "E" values (null, null);
+[ 1    ]
+#create table "I" (
+#      "intCol" bigint,
+#      "stringCol" string
+#);
+#insert into "I" values (2, 'due');
+[ 1    ]
+#insert into "I" values (4, 'quattro');
+[ 1    ]
+#insert into "I" values (null, 'this is not null');
+[ 1    ]
+#select * from "E" left outer join "I" on "E"."intCol" = "I"."intCol" or 
("E"."intCol" is null and  "I"."intCol" is null);
+% .E,  .E,     .I,     .I # table_name
+% intCol,      stringCol,      intCol, stringCol # name
+% bigint,      clob,   bigint, clob # type
+% 1,   4,      1,      16 # length
+[ 2,   "two",  2,      "due"   ]
+[ NULL,        NULL,   NULL,   "this is not null"      ]
+[ 0,   "zero", NULL,   NULL    ]
+[ 1,   "one",  NULL,   NULL    ]
+#drop table "E";
+#drop table "I";
+
+# 21:23:56 >  
+# 21:23:56 >  "Done."
+# 21:23:56 >  
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to