Changeset: e8375b6f4bce for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e8375b6f4bce
Added Files:
sql/test/BugTracker-2018/Tests/sqlitelogictest-groupby-distinct-duplicate.Bug-6603.stable.err
sql/test/BugTracker-2018/Tests/sqlitelogictest-groupby-distinct-duplicate.Bug-6603.stable.out
Modified Files:
sql/server/rel_optimizer.c
Branch: Mar2018
Log Message:
fixed bug 6603 (ony reduce groupby/distinct if all groupby cols
are in the distinct list)
diffs (120 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
@@ -2243,6 +2243,7 @@ rel_distinct_project2groupby(int *change
need_distinct(rel) && l->op == op_select){
sql_rel *g = l->l;
if (is_groupby(g->op)) {
+ list *used = sa_list(sql->sa);
list *gbe = g->r;
node *n;
int fnd = 1;
@@ -2256,7 +2257,10 @@ rel_distinct_project2groupby(int *change
if (ne)
ne = list_find_exp( gbe, ne);
- fnd++;
+ if (ne && !list_find_exp(used, ne)) {
+ fnd++;
+ list_append(used, ne);
+ }
if (!ne)
fnd = 0;
}
@@ -2269,7 +2273,7 @@ rel_distinct_project2groupby(int *change
need_distinct(rel) && exps_card(rel->exps) > CARD_ATOM) {
node *n;
list *exps = new_exp_list(sql->sa), *gbe =
new_exp_list(sql->sa);
- list *obe = rel->r; /* we need to readd the ordering later */
+ list *obe = rel->r; /* we need to read the ordering later */
if (obe) {
int fnd = 0;
diff --git
a/sql/test/BugTracker-2018/Tests/sqlitelogictest-groupby-distinct-duplicate.Bug-6603.stable.err
b/sql/test/BugTracker-2018/Tests/sqlitelogictest-groupby-distinct-duplicate.Bug-6603.stable.err
new file mode 100644
--- /dev/null
+++
b/sql/test/BugTracker-2018/Tests/sqlitelogictest-groupby-distinct-duplicate.Bug-6603.stable.err
@@ -0,0 +1,35 @@
+stderr of test 'sqlitelogictest-groupby-distinct-duplicate.Bug-6603` in
directory 'sql/test/BugTracker-2018` itself:
+
+
+# 17:07:25 >
+# 17:07:25 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=31299" "--set"
"mapi_usock=/var/tmp/mtest-5982/.s.monetdb.31299" "--set" "monet_prompt="
"--forcemito"
"--dbpath=/home/niels/scratch/rc-old/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2018"
"--set" "embedded_c=true"
+# 17:07:25 >
+
+# builtin opt gdk_dbpath =
/home/niels/scratch/rc-old/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 = 31299
+# cmdline opt mapi_usock = /var/tmp/mtest-5982/.s.monetdb.31299
+# cmdline opt monet_prompt =
+# cmdline opt gdk_dbpath =
/home/niels/scratch/rc-old/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2018
+# cmdline opt embedded_c = true
+# cmdline opt gdk_debug = 553648138
+
+# 17:07:25 >
+# 17:07:25 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-5982" "--port=31299"
+# 17:07:25 >
+
+
+# 17:07:25 >
+# 17:07:25 > "Done."
+# 17:07:25 >
+
diff --git
a/sql/test/BugTracker-2018/Tests/sqlitelogictest-groupby-distinct-duplicate.Bug-6603.stable.out
b/sql/test/BugTracker-2018/Tests/sqlitelogictest-groupby-distinct-duplicate.Bug-6603.stable.out
new file mode 100644
--- /dev/null
+++
b/sql/test/BugTracker-2018/Tests/sqlitelogictest-groupby-distinct-duplicate.Bug-6603.stable.out
@@ -0,0 +1,43 @@
+stdout of test 'sqlitelogictest-groupby-distinct-duplicate.Bug-6603` in
directory 'sql/test/BugTracker-2018` itself:
+
+
+# 17:07:25 >
+# 17:07:25 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=31299" "--set"
"mapi_usock=/var/tmp/mtest-5982/.s.monetdb.31299" "--set" "monet_prompt="
"--forcemito"
"--dbpath=/home/niels/scratch/rc-old/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2018"
"--set" "embedded_c=true"
+# 17:07:25 >
+
+# MonetDB 5 server v11.29.4
+# This is an unreleased version
+# Serving database 'mTests_sql_test_BugTracker-2018', using 8 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 128bit integers
+# Found 15.386 GiB available main-memory.
+# Copyright (c) 1993 - July 2008 CWI.
+# Copyright (c) August 2008 - 2018 MonetDB B.V., all rights reserved
+# Visit https://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://xps13:31299/
+# Listening for UNIX domain connection requests on
mapi:monetdb:///var/tmp/mtest-5982/.s.monetdb.31299
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 17:07:25 >
+# 17:07:25 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-5982" "--port=31299"
+# 17:07:25 >
+
+#START TRANSACTION;
+#CREATE TABLE tab0(col0 INTEGER, col1 INTEGER, col2 INTEGER);
+#INSERT INTO tab0 VALUES(83,0,38),(26,0,79),(43,81,24);
+[ 3 ]
+#SELECT DISTINCT + + col1, col1 FROM tab0 AS cor0 GROUP BY col0, col1 HAVING
NOT NULL IS NOT NULL;
+% sys.cor0, sys.cor0 # table_name
+% col1, col1 # name
+% int, int # type
+% 2, 2 # length
+[ 0, 0 ]
+[ 81, 81 ]
+#ROLLBACK;
+
+# 17:07:25 >
+# 17:07:25 > "Done."
+# 17:07:25 >
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list