Changeset: d9135c8dafb2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d9135c8dafb2
Added Files:
sql/test/BugTracker-2021/Tests/batappend-undefined.Bug-7130.sql
sql/test/BugTracker-2021/Tests/batappend-undefined.Bug-7130.stable.err
sql/test/BugTracker-2021/Tests/batappend-undefined.Bug-7130.stable.out
Modified Files:
sql/server/rel_select.c
sql/test/BugTracker-2021/Tests/All
Branch: Oct2020
Log Message:
Backported changeset 734fbb3ba87a into Oct2020. This fixes bugs #7130 and #7131
diffs (182 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
@@ -943,10 +943,13 @@ table_ref(sql_query *query, sql_rel *rel
node *n,*m;
sql_rel *rel;
- if (sql->emode == m_deps)
+ if (sql->emode == m_deps) {
rel = rel_basetable(sql, t, tname);
- else
+ } else {
rel = rel_parse(sql, t->s, t->query,
m_instantiate);
+ if (rel)
+ rel = rel_unnest(sql, rel);
+ }
if (!rel)
return NULL;
diff --git a/sql/test/BugTracker-2021/Tests/All
b/sql/test/BugTracker-2021/Tests/All
--- a/sql/test/BugTracker-2021/Tests/All
+++ b/sql/test/BugTracker-2021/Tests/All
@@ -9,3 +9,4 @@ lowercase-cryllic.Bug-7126
unnest-union.Bug-7127
subquery-missing.Bug-7128
batcalc-between-undefined.Bug-7129
+batappend-undefined.Bug-7130
diff --git a/sql/test/BugTracker-2021/Tests/batappend-undefined.Bug-7130.sql
b/sql/test/BugTracker-2021/Tests/batappend-undefined.Bug-7130.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2021/Tests/batappend-undefined.Bug-7130.sql
@@ -0,0 +1,40 @@
+start transaction;
+
+create table t_qh ( c_f INTEGER , c_y2 INTEGER , c_i768 INTEGER , c_tqx TEXT ,
c_mknkhml TEXT, primary key(c_f, c_y2), unique(c_y2) );
+insert into t_qh values (1,1,1,'a','a'),(2,2,2,'b','b'),(3,3,3,'c','c');
+
+create table t_ckfystsc ( c_kvhq5p INTEGER , c_aifpl INTEGER , c_jf6 TEXT ,
c_f31ix TEXT NOT NULL, c_lo0zqfe TEXT , c_zv INTEGER , c_l153 INTEGER , primary
key(c_zv), unique(c_zv) );
+insert into t_ckfystsc values
(1,1,'a','a','a',1,1),(2,2,'b','b','b',2,2),(3,3,'c','c','c',3,3);
+
+create view t_vehkuero as select distinct abs( cast(subq_0.c1 as INTEGER)) as
c0 from (select ref_0.c_f as c0, ref_0.c_f as c1, ref_0.c_i768 as c2,
ref_0.c_y2 as c3 from t_qh as ref_0)
+as subq_0 where cast(nullif('zdo', 'apqonv1a') as CHAR) like 'aou%2' AND
length( cast(case when subq_0.c1 = ( select subq_0.c3 as c0 from t_qh as ref_6
+where (subq_0.c0 <> ( select subq_0.c0 as c0 from t_qh as ref_7)) ) then 'xk'
else 'xk' end as CHAR)) <> subq_0.c0;
+
+select 1000 in (select 2 from t_vehkuero) from (select 1 as c0 from
t_ckfystsc) as subq_0;
+ -- False
+ -- False
+ -- False
+
+select case when subq_0.c0 in ( select ref_5.c_tqx as c0 from t_qh as ref_5
where ref_5.c_y2 in ( select ref_6.c_y2 as c0 from t_qh as ref_6 union select 2
as c0 from t_vehkuero as ref_7))
+then cast(nullif(subq_0.c0, subq_0.c0) as CHAR) else cast(nullif(subq_0.c0,
subq_0.c0) as CHAR) end as c0 from (select ref_0.c_lo0zqfe as c0, ref_0.c_aifpl
as c1 from t_ckfystsc as ref_0) as subq_0;
+ -- NULL
+ -- NULL
+ -- NULL
+
+rollback;
+
+create table t_qh ( c_f INTEGER , c_y2 INTEGER , c_i768 INTEGER , c_tqx
INTEGER , primary key(c_i768), unique(c_y2) );
+insert into t_qh values (1,1,1,1),(2,2,2,2),(3,3,3,3);
+
+create view t_amy as select ref_1.c_f as c0 from t_qh as ref_0 cross join t_qh
as ref_1 left outer join (select ref_2.c_i768 as c0, cast(sum( cast(ref_3.c_f
as INTEGER)) as bigint) as c1, count(*) as c2 from t_qh as ref_2
+left outer join t_qh as ref_3 on (ref_2.c_f < ref_2.c_f) where ref_2.c_i768 >
ref_3.c_y2 group by ref_2.c_i768) as subq_0 on (ref_0.c_y2 < ref_1.c_f) where
ref_0.c_f <> ( select ref_4.c_i768 as c0 from t_qh
+as ref_4 cross join t_qh as ref_5 where EXISTS ( select ref_6.c_i768 as c0,
ref_1.c_i768 as c1, ref_6.c_y2 as c2 from t_qh as ref_6 where subq_0.c0 < (
select subq_0.c1 as c0 from t_qh as ref_7
+where (ref_5.c_f <> ref_6.c_f) or (subq_0.c1 is NULL))));
+
+select (subq_0.c0 = case when EXISTS ( select ref_15.c0 as c6 from t_amy as
ref_15) then subq_0.c1 else subq_0.c1 end) as c4 from (select ref_12.c_f as c0,
30 as c1 from t_qh as ref_12) as subq_0;
+ -- error, more than one match
+
+select (select (select 1 where subq_0.c0 = (select subq_0.c1 from t_qh)) from
(select 320, 1) subq_0(c0,c1)) from (select 2) subq_0(c3);
+ -- error, more than one match
+
+drop table t_qh cascade;
diff --git
a/sql/test/BugTracker-2021/Tests/batappend-undefined.Bug-7130.stable.err
b/sql/test/BugTracker-2021/Tests/batappend-undefined.Bug-7130.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2021/Tests/batappend-undefined.Bug-7130.stable.err
@@ -0,0 +1,35 @@
+stderr of test 'batappend-undefined.Bug-7130` in directory
'sql/test/BugTracker-2021` itself:
+
+
+# 14:39:22 >
+# 14:39:22 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_listenaddr=all" "--set" "mapi_port=37036" "--set"
"mapi_usock=/var/tmp/mtest-27053/.s.monetdb.37036" "--forcemito"
"--dbpath=/home/ferreira/repositories/MonetDB-Oct2020/BUILD/var/MonetDB/mTests_sql_test_BugTracker-2021"
"--set" "embedded_r=yes" "--set" "embedded_c=true"
+# 14:39:22 >
+
+# builtin opt gdk_dbpath =
/home/ferreira/repositories/MonetDB-Oct2020/BUILD/var/monetdb5/dbfarm/demo
+# builtin opt mapi_port = 50000
+# builtin opt sql_optimizer = default_pipe
+# builtin opt sql_debug = 0
+# builtin opt raw_strings = false
+# cmdline opt gdk_nr_threads = 0
+# cmdline opt mapi_listenaddr = all
+# cmdline opt mapi_port = 37036
+# cmdline opt mapi_usock = /var/tmp/mtest-27053/.s.monetdb.37036
+# cmdline opt gdk_dbpath =
/home/ferreira/repositories/MonetDB-Oct2020/BUILD/var/MonetDB/mTests_sql_test_BugTracker-2021
+# cmdline opt embedded_r = yes
+# cmdline opt embedded_c = true
+
+# 14:39:23 >
+# 14:39:23 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-27053" "--port=37036"
+# 14:39:23 >
+
+MAPI = (monetdb) /var/tmp/mtest-27774/.s.monetdb.32515
+QUERY = select (subq_0.c0 = case when EXISTS ( select ref_15.c0 as c6 from
t_amy as ref_15) then subq_0.c1 else subq_0.c1 end) as c4 from (select
ref_12.c_f as c0, 30 as c1 from t_qh as ref_12) as subq_0;
+ERROR = !GDK reported error: BATsubcross: more than one match
+MAPI = (monetdb) /var/tmp/mtest-29298/.s.monetdb.35652
+QUERY = select (select (select 1 where subq_0.c0 = (select subq_0.c1 from
t_qh)) from (select 320, 1) subq_0(c0,c1)) from (select 2) subq_0(c3);
+ERROR = !GDK reported error: BATsubcross: more than one match
+
+# 14:39:23 >
+# 14:39:23 > "Done."
+# 14:39:23 >
+
diff --git
a/sql/test/BugTracker-2021/Tests/batappend-undefined.Bug-7130.stable.out
b/sql/test/BugTracker-2021/Tests/batappend-undefined.Bug-7130.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2021/Tests/batappend-undefined.Bug-7130.stable.out
@@ -0,0 +1,65 @@
+stdout of test 'batappend-undefined.Bug-7130` in directory
'sql/test/BugTracker-2021` itself:
+
+
+# 14:39:22 >
+# 14:39:22 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_listenaddr=all" "--set" "mapi_port=37036" "--set"
"mapi_usock=/var/tmp/mtest-27053/.s.monetdb.37036" "--forcemito"
"--dbpath=/home/ferreira/repositories/MonetDB-Oct2020/BUILD/var/MonetDB/mTests_sql_test_BugTracker-2021"
"--set" "embedded_r=yes" "--set" "embedded_c=true"
+# 14:39:22 >
+
+# MonetDB 5 server v11.39.18 (hg id: af88b10dddb7)
+# This is an unreleased version
+# Serving database 'mTests_sql_test_BugTracker-2021', using 8 threads
+# Compiled for x86_64-pc-linux-gnu/64bit with 128bit integers
+# Found 15.342 GiB available main-memory of which we use 12.504 GiB
+# Copyright (c) 1993 - July 2008 CWI.
+# Copyright (c) August 2008 - 2021 MonetDB B.V., all rights reserved
+# Visit https://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://fedora:37036/
+# Listening for UNIX domain connection requests on
mapi:monetdb:///var/tmp/mtest-27053/.s.monetdb.37036
+# MonetDB/GIS module loaded
+# MonetDB/R module loaded
+# MonetDB/SQL module loaded
+
+# 14:39:23 >
+# 14:39:23 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-27053" "--port=37036"
+# 14:39:23 >
+
+#start transaction;
+#create table t_qh ( c_f INTEGER , c_y2 INTEGER , c_i768 INTEGER , c_tqx TEXT
, c_mknkhml TEXT, primary key(c_f, c_y2), unique(c_y2) );
+#insert into t_qh values (1,1,1,'a','a'),(2,2,2,'b','b'),(3,3,3,'c','c');
+[ 3 ]
+#create table t_ckfystsc ( c_kvhq5p INTEGER , c_aifpl INTEGER , c_jf6 TEXT ,
c_f31ix TEXT NOT NULL, c_lo0zqfe TEXT , c_zv INTEGER , c_l153 INTEGER , primary
key(c_zv), unique(c_zv) );
+#insert into t_ckfystsc values
(1,1,'a','a','a',1,1),(2,2,'b','b','b',2,2),(3,3,'c','c','c',3,3);
+[ 3 ]
+#create view t_vehkuero as select distinct abs( cast(subq_0.c1 as INTEGER)) as
c0 from (select ref_0.c_f as c0, ref_0.c_f as c1, ref_0.c_i768 as c2,
ref_0.c_y2 as c3 from t_qh as ref_0)
+#as subq_0 where cast(nullif('zdo', 'apqonv1a') as CHAR) like 'aou%2' AND
length( cast(case when subq_0.c1 = ( select subq_0.c3 as c0 from t_qh as ref_6
+#where (subq_0.c0 <> ( select subq_0.c0 as c0 from t_qh as ref_7)) ) then 'xk'
else 'xk' end as CHAR)) <> subq_0.c0;
+#select 1000 in (select 2 from t_vehkuero) from (select 1 as c0 from
t_ckfystsc) as subq_0;
+% .%15 # table_name
+% %15 # name
+% boolean # type
+% 5 # length
+[ false ]
+[ false ]
+[ false ]
+#select case when subq_0.c0 in ( select ref_5.c_tqx as c0 from t_qh as ref_5
where ref_5.c_y2 in ( select ref_6.c_y2 as c0 from t_qh as ref_6 union select 2
as c0 from t_vehkuero as ref_7))
+#then cast(nullif(subq_0.c0, subq_0.c0) as CHAR) else cast(nullif(subq_0.c0,
subq_0.c0) as CHAR) end as c0 from (select ref_0.c_lo0zqfe as c0, ref_0.c_aifpl
as c1 from t_ckfystsc as ref_0) as subq_0;
+% . # table_name
+% c0 # name
+% char # type
+% 1 # length
+[ NULL ]
+[ NULL ]
+[ NULL ]
+#drop table t_qh cascade;
+#create table t_qh ( c_f INTEGER , c_y2 INTEGER , c_i768 INTEGER , c_tqx
INTEGER , primary key(c_i768), unique(c_y2) );
+#insert into t_qh values (1,1,1,1),(2,2,2,2),(3,3,3,3);
+[ 3 ]
+#create view t_amy as select ref_1.c_f as c0 from t_qh as ref_0 cross join
t_qh as ref_1 left outer join (select ref_2.c_i768 as c0, sum( cast(ref_3.c_f
as INTEGER)) as c1, count(*) as c2 from t_qh as ref_2
+#left outer join t_qh as ref_3 on (ref_2.c_f < ref_2.c_f) where ref_2.c_i768 >
ref_3.c_y2 group by ref_2.c_i768) as subq_0 on (ref_0.c_y2 < ref_1.c_f) where
ref_0.c_f <> ( select ref_4.c_i768 as c0 from t_qh
+#as ref_4 cross join t_qh as ref_5 where EXISTS ( select ref_6.c_i768 as c0,
ref_1.c_i768 as c1, ref_6.c_y2 as c2 from t_qh as ref_6 where subq_0.c0 < (
select subq_0.c1 as c0 from t_qh as ref_7
+#rollback;
+
+# 14:39:23 >
+# 14:39:23 > "Done."
+# 14:39:23 >
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list