Changeset: 7a69de77b1b3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7a69de77b1b3
Added Files:
sql/test/BugTracker-2017/Tests/sqlitelogictest-having-with-in.Bug-6410.stable.err
sql/test/BugTracker-2017/Tests/sqlitelogictest-having-with-in.Bug-6410.stable.out
sql/test/BugTracker-2017/Tests/sqlitelogictest-having-with-not-in.Bug-6409.stable.err
sql/test/BugTracker-2017/Tests/sqlitelogictest-having-with-not-in.Bug-6409.stable.out
Modified Files:
sql/backends/monet5/rel_bin.c
sql/server/rel_select.c
Branch: Jul2017
Log Message:
fixes for bugs 6409 and 6410. Only set subquery flags when realy needed.
diffs (278 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
@@ -561,6 +561,8 @@ exp_bin(backend *be, sql_exp *e, stmt *l
fprintf(stderr, "could not find %s.%s\n", (char*)e->l,
(char*)e->r);
print_stmtlist(sql->sa, left);
print_stmtlist(sql->sa, right);
+ assert(s);
+ return NULL;
}
} break;
case e_cmp: {
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
@@ -33,10 +33,6 @@ rel_setsubquery(sql_rel*r)
{
if (rel_is_ref(r))
return;
- if (r->l && !is_base(r->op))
- rel_setsubquery(r->l);
- if (r->r && is_join(r->op))
- rel_setsubquery(r->r);
set_subquery(r);
}
@@ -1779,7 +1775,6 @@ rel_compare(mvc *sql, sql_rel *rel, symb
rel = r;
}
} else if (r) {
- rel_setsubquery(r);
rs = rel_lastexp(sql, r);
if (r->card > CARD_ATOM) {
/* if single value (independed of relations),
rewrite */
@@ -2024,7 +2019,6 @@ rel_logical_value_exp(mvc *sql, sql_rel
if (!rel_find_exp(l, ls))
rel_project_add_exp(sql, l, ls);
}
- rel_setsubquery(r);
rs = rel_lastexp(sql, r);
if (r->card > CARD_ATOM) {
sql_subaggr *zero_or_one =
sql_bind_aggr(sql->sa, sql->session->schema, "zero_or_one", exp_subtype(rs));
@@ -2444,7 +2438,7 @@ rel_logical_exp(mvc *sql, sql_rel *rel,
symbol *lo = NULL;
dnode *n = dl->h->next, *dn = NULL;
sql_rel *left = NULL, *right = NULL, *outer = rel;
- sql_exp *l = NULL, *e, *r = NULL, *ident = NULL;
+ sql_exp *l = NULL, *e, *r = NULL, *outerident = NULL, *ident =
NULL;
list *vals = NULL, *ll = sa_list(sql->sa);
int correlated = 0;
int l_is_value = 1, r_is_rel = 0;
@@ -2558,10 +2552,14 @@ rel_logical_exp(mvc *sql, sql_rel *rel,
sql->errstr[0] = 0;
if (l_is_value) {
- outer = rel =
rel_add_identity(sql, rel_dup(outer), &ident);
- ident =
exp_column(sql->sa, exp_relname(ident), exp_name(ident), exp_subtype(ident),
ident->card, has_nil(ident), is_intern(ident));
- } else
+ if (!outerident) {
+ outer = rel =
rel_add_identity(sql, rel_dup(outer), &ident);
+ ident =
exp_column(sql->sa, exp_relname(ident), exp_name(ident), exp_subtype(ident),
ident->card, has_nil(ident), is_intern(ident));
+ outerident =
ident;
+ }
+ } else {
rel = left =
rel_dup(left);
+ }
r = rel_value_exp(sql, &rel,
sval, f, ek);
if (r && !is_project(rel->op)) {
rel =
rel_project(sql->sa, rel, NULL);
@@ -2583,9 +2581,17 @@ rel_logical_exp(mvc *sql, sql_rel *rel,
rl = rel_project_exp(sql->sa,
exp_label(sql->sa, r, ++sql->label));
}
if (right) {
+ int ident_colnr = -1;
+
+ if (ident) {
+ sql_exp *i =
exps_bind_column2(right->exps, exp_relname(ident), exp_name(ident));
+ ident_colnr =
list_position(right->exps, i);
+ }
rl = rel_setop(sql->sa, right,
rl, op_union);
rl->exps = rel_projections(sql,
rl, NULL, 0, 1);
set_processed(rl);
+ if (ident)
+ ident =
list_fetch(rl->exps, ident_colnr);
}
right = rl;
}
@@ -2632,7 +2638,7 @@ rel_logical_exp(mvc *sql, sql_rel *rel,
rel = rel_crossproduct(sql->sa, outer, right,
op_join);
rel->exps = sa_list(sql->sa);
- le = exp_compare(sql->sa, ident, le, cmp_equal);
+ le = exp_compare(sql->sa, outerident, le,
cmp_equal);
append(rel->exps, le);
} else {
rel = rel_crossproduct(sql->sa, left, right,
op_join);
@@ -4461,7 +4467,6 @@ rel_value_exp2(mvc *sql, sql_rel **rel,
if (*rel) {
sql_rel *p = *rel;
- rel_setsubquery(r);
/* in the selection phase we should have
project/groupbys, unless
* this is the value (column) for the
aggregation then the
* crossproduct is pushed under the
project/groupby. */
@@ -5065,7 +5070,8 @@ rel_query(mvc *sql, sql_rel *rel, symbol
/* remove the outer (running) project */
if (!is_processed(o) && is_project(o->op))
o = rel->l;
- rel_setsubquery(res);
+ if (res)
+ rel_setsubquery(res);
outer = rel;
/* create dummy single row project */
rel = rel_project(sql->sa, NULL, applyexps =
rel_projections(sql, o, NULL, 1, 1));
diff --git
a/sql/test/BugTracker-2017/Tests/sqlitelogictest-having-with-in.Bug-6410.stable.err
b/sql/test/BugTracker-2017/Tests/sqlitelogictest-having-with-in.Bug-6410.stable.err
new file mode 100644
--- /dev/null
+++
b/sql/test/BugTracker-2017/Tests/sqlitelogictest-having-with-in.Bug-6410.stable.err
@@ -0,0 +1,34 @@
+stderr of test 'sqlitelogictest-having-with-in.Bug-6410` in directory
'sql/test/BugTracker-2017` itself:
+
+
+# 13:37:58 >
+# 13:37:58 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=31716" "--set"
"mapi_usock=/var/tmp/mtest-5089/.s.monetdb.31716" "--set" "monet_prompt="
"--forcemito"
"--dbpath=/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2017"
+# 13:37:58 >
+
+# 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 = 31716
+# cmdline opt mapi_usock = /var/tmp/mtest-5089/.s.monetdb.31716
+# 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
+
+# 13:37:58 >
+# 13:37:58 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-5089" "--port=31716"
+# 13:37:58 >
+
+
+# 13:37:58 >
+# 13:37:58 > "Done."
+# 13:37:58 >
+
diff --git
a/sql/test/BugTracker-2017/Tests/sqlitelogictest-having-with-in.Bug-6410.stable.out
b/sql/test/BugTracker-2017/Tests/sqlitelogictest-having-with-in.Bug-6410.stable.out
new file mode 100644
--- /dev/null
+++
b/sql/test/BugTracker-2017/Tests/sqlitelogictest-having-with-in.Bug-6410.stable.out
@@ -0,0 +1,38 @@
+stdout of test 'sqlitelogictest-having-with-in.Bug-6410` in directory
'sql/test/BugTracker-2017` itself:
+
+
+# 13:37:58 >
+# 13:37:58 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=31716" "--set"
"mapi_usock=/var/tmp/mtest-5089/.s.monetdb.31716" "--set" "monet_prompt="
"--forcemito"
"--dbpath=/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2017"
+# 13:37:58 >
+
+# 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:31716/
+# Listening for UNIX domain connection requests on
mapi:monetdb:///var/tmp/mtest-5089/.s.monetdb.31716
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 13:37:58 >
+# 13:37:58 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-5089" "--port=31716"
+# 13:37:58 >
+
+#CREATE TABLE tab2(col0 INTEGER, col1 INTEGER, col2 INTEGER);
+#SELECT 9 - - col1 FROM tab2 GROUP BY col1 HAVING - CAST ( NULL AS INTEGER )
IN ( + - SUM ( - + 47 ), + MIN ( col2 ) );
+% .L2 # table_name
+% L2 # name
+% bigint # type
+% 1 # length
+#DROP TABLE tab2;
+
+# 13:37:58 >
+# 13:37:58 > "Done."
+# 13:37:58 >
+
diff --git
a/sql/test/BugTracker-2017/Tests/sqlitelogictest-having-with-not-in.Bug-6409.stable.err
b/sql/test/BugTracker-2017/Tests/sqlitelogictest-having-with-not-in.Bug-6409.stable.err
new file mode 100644
--- /dev/null
+++
b/sql/test/BugTracker-2017/Tests/sqlitelogictest-having-with-not-in.Bug-6409.stable.err
@@ -0,0 +1,34 @@
+stderr of test 'sqlitelogictest-having-with-not-in.Bug-6409` in directory
'sql/test/BugTracker-2017` itself:
+
+
+# 13:37:57 >
+# 13:37:57 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=31716" "--set"
"mapi_usock=/var/tmp/mtest-5089/.s.monetdb.31716" "--set" "monet_prompt="
"--forcemito"
"--dbpath=/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2017"
+# 13:37:57 >
+
+# 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 = 31716
+# cmdline opt mapi_usock = /var/tmp/mtest-5089/.s.monetdb.31716
+# 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
+
+# 13:37:57 >
+# 13:37:57 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-5089" "--port=31716"
+# 13:37:57 >
+
+
+# 13:37:58 >
+# 13:37:58 > "Done."
+# 13:37:58 >
+
diff --git
a/sql/test/BugTracker-2017/Tests/sqlitelogictest-having-with-not-in.Bug-6409.stable.out
b/sql/test/BugTracker-2017/Tests/sqlitelogictest-having-with-not-in.Bug-6409.stable.out
new file mode 100644
--- /dev/null
+++
b/sql/test/BugTracker-2017/Tests/sqlitelogictest-having-with-not-in.Bug-6409.stable.out
@@ -0,0 +1,38 @@
+stdout of test 'sqlitelogictest-having-with-not-in.Bug-6409` in directory
'sql/test/BugTracker-2017` itself:
+
+
+# 13:37:57 >
+# 13:37:57 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=31716" "--set"
"mapi_usock=/var/tmp/mtest-5089/.s.monetdb.31716" "--set" "monet_prompt="
"--forcemito"
"--dbpath=/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2017"
+# 13:37:57 >
+
+# 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:31716/
+# Listening for UNIX domain connection requests on
mapi:monetdb:///var/tmp/mtest-5089/.s.monetdb.31716
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 13:37:57 >
+# 13:37:57 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-5089" "--port=31716"
+# 13:37:57 >
+
+#CREATE TABLE tab1(col0 INTEGER, col1 INTEGER, col2 INTEGER);
+#SELECT cor0.col1 FROM tab1 AS cor0 GROUP BY cor0.col1 HAVING NULL NOT IN ( -
cor0.col1 );
+% sys.cor0 # table_name
+% col1 # name
+% int # type
+% 1 # length
+#DROP TABLE tab1;
+
+# 13:37:58 >
+# 13:37:58 > "Done."
+# 13:37:58 >
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list