Changeset: 3508c0f49d74 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3508c0f49d74
Added Files:
        sql/test/mergetables/Tests/sqlsmith-exist-lateral.sql
        sql/test/mergetables/Tests/sqlsmith-exist-lateral.stable.err
        sql/test/mergetables/Tests/sqlsmith-exist-lateral.stable.out
Modified Files:
        sql/server/rel_select.c
        sql/test/mergetables/Tests/All
Branch: Jul2017
Log Message:

fixed crash in correlated exists with lateral


diffs (157 lines):

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
@@ -5054,7 +5054,6 @@ rel_query(mvc *sql, sql_rel *rel, symbol
        if (ek.card != card_relation && sn->orderby)
                return sql_error(sql, 01, "SELECT: ORDER BY only allowed on 
outermost SELECT");
 
-
        sql->use_views = 1;
        if (sn->from) {         /* keep variable list with tables and names */
                dlist *fl = sn->from->data.lval;
@@ -5077,7 +5076,7 @@ rel_query(mvc *sql, sql_rel *rel, symbol
                                 */ 
                                if (used && rel)
                                        rel = rel_dup(rel);
-                               if (!used && (!sn->lateral && !lateral) && rel) 
{
+                               if (!used && ((!sn->lateral && !lateral) || 
(apply == APPLY_EXISTS || apply == APPLY_NOTEXISTS)) && rel) {
                                        sql_rel *o = rel;
 
                                        /* remove the outer (running) project */
diff --git a/sql/test/mergetables/Tests/All b/sql/test/mergetables/Tests/All
--- a/sql/test/mergetables/Tests/All
+++ b/sql/test/mergetables/Tests/All
@@ -27,4 +27,5 @@ HAVE_NETCDF?sqlsmith.Bug-6451
 HAVE_NETCDF?sqlsmith.Bug-6453
 HAVE_NETCDF&HAVE_SAMTOOLS?sqlsmith.Bug-6455
 HAVE_GEOM?sqlsmith.Bug-6459
+HAVE_NETCDF?sqlsmith-exist-lateral
 mergedb_drop
diff --git a/sql/test/mergetables/Tests/sqlsmith-exist-lateral.sql 
b/sql/test/mergetables/Tests/sqlsmith-exist-lateral.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/mergetables/Tests/sqlsmith-exist-lateral.sql
@@ -0,0 +1,25 @@
+select 
+  ref_11.access as c0,
+  ref_12.revsorted as c1
+from
+  sys._tables as ref_11
+    inner join sys.statistics as ref_12
+    on (((false)
+          or (ref_11.id is NULL))
+        or (EXISTS (
+          select 
+              ref_13.dim_id as c0,
+              ref_11.query as c1
+            from
+              sys.netcdf_vardim as ref_13,
+              lateral (select 
+                    ref_11.access as c0,
+                    ref_13.var_id as c1,
+                    ref_11.commit_action as c2,
+                    ref_11.system as c3
+                  from
+                    sys.r2 as ref_14
+                  where true) as subq_0
+            where ref_13.var_id is not NULL)))
+where true;
+
diff --git a/sql/test/mergetables/Tests/sqlsmith-exist-lateral.stable.err 
b/sql/test/mergetables/Tests/sqlsmith-exist-lateral.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/mergetables/Tests/sqlsmith-exist-lateral.stable.err
@@ -0,0 +1,34 @@
+stderr of test 'sqlsmith-exist-lateral` in directory 'sql/test/mergetables` 
itself:
+
+
+# 21:45:47 >  
+# 21:45:47 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=36057" "--set" 
"mapi_usock=/var/tmp/mtest-32287/.s.monetdb.36057" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_mergetables"
+# 21:45: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 = 36057
+# cmdline opt  mapi_usock = /var/tmp/mtest-32287/.s.monetdb.36057
+# cmdline opt  monet_prompt = 
+# cmdline opt  gdk_dbpath = 
/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_mergetables
+# cmdline opt  gdk_debug = 536870922
+
+# 21:45:47 >  
+# 21:45:47 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-32287" "--port=36057"
+# 21:45:47 >  
+
+
+# 21:45:47 >  
+# 21:45:47 >  "Done."
+# 21:45:47 >  
+
diff --git a/sql/test/mergetables/Tests/sqlsmith-exist-lateral.stable.out 
b/sql/test/mergetables/Tests/sqlsmith-exist-lateral.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/mergetables/Tests/sqlsmith-exist-lateral.stable.out
@@ -0,0 +1,54 @@
+stdout of test 'sqlsmith-exist-lateral` in directory 'sql/test/mergetables` 
itself:
+
+
+# 21:45:47 >  
+# 21:45:47 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=36057" "--set" 
"mapi_usock=/var/tmp/mtest-32287/.s.monetdb.36057" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_mergetables"
+# 21:45:47 >  
+
+# MonetDB 5 server v11.27.6
+# This is an unreleased version
+# Serving database 'mTests_sql_test_mergetables', 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:36057/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-32287/.s.monetdb.36057
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 21:45:47 >  
+# 21:45:47 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-32287" "--port=36057"
+# 21:45:47 >  
+
+#select 
+#  ref_11.access as c0,
+#  ref_12.revsorted as c1
+#from
+#  sys._tables as ref_11
+#    inner join sys.statistics as ref_12
+#    on (((false)
+#          or (ref_11.id is NULL))
+#        or (EXISTS (
+#          select 
+#              ref_13.dim_id as c0,
+#              ref_11.query as c1
+#            from
+#              sys.netcdf_vardim as ref_13,
+#              lateral (select 
+#                    ref_11.access as c0,
+#                    ref_13.var_id as c1,
+#                    ref_11.commit_action as c2,
+#                    ref_11.system as c3
+% .L35,        .L37 # table_name
+% c0,  c1 # name
+% smallint,    boolean # type
+% 1,   5 # length
+
+# 21:45:47 >  
+# 21:45:47 >  "Done."
+# 21:45:47 >  
+
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to