Changeset: a36f972299ec for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a36f972299ec
Added Files:
sql/test/BugTracker-2014/Tests/union_with_subqueries.Bug-3518.sql
sql/test/BugTracker-2014/Tests/union_with_subqueries.Bug-3518.stable.err
sql/test/BugTracker-2014/Tests/union_with_subqueries.Bug-3518.stable.out
Modified Files:
sql/backends/monet5/rel_bin.c
sql/server/rel_optimizer.c
sql/test/BugTracker-2014/Tests/All
Branch: Jan2014
Log Message:
fixed bug 3518. The rel_push_aggr_down didn't handle aliases to other
aggregates correctly.
diffs (123 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
@@ -2481,7 +2481,9 @@ rel2bin_groupby( mvc *sql, sql_rel *rel,
stmt *aggrstmt = NULL;
- /* first look in the group by column list */
+ /* first look in the current aggr list (l) and group by column
list */
+ if (l && !aggrstmt && aggrexp->type == e_column)
+ aggrstmt = list_find_column(sql->sa, l, aggrexp->l,
aggrexp->r);
if (gbexps && !aggrstmt && aggrexp->type == e_column) {
aggrstmt = list_find_column(sql->sa, gbexps,
aggrexp->l, aggrexp->r);
if (aggrstmt && groupby)
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
@@ -2897,7 +2897,7 @@ rel_push_aggr_down(int *changes, mvc *sq
e = exp_column(sql->sa, exp_find_rel_name(e),
exp_name(e), exp_subtype(e), e->card, has_nil(e), is_intern(e));
ne = exp_aggr1(sql->sa, e, a, need_distinct(e),
1, e->card, 1);
} else {
- ne = exp_column(sql->sa, exp_find_rel_name(e),
exp_name(e), exp_subtype(e), e->card, has_nil(e), is_intern(e));
+ ne = exp_copy(sql->sa, oa);
}
exp_setname(sql->sa, ne, exp_find_rel_name(oa),
exp_name(oa));
append(exps, ne);
diff --git a/sql/test/BugTracker-2014/Tests/All
b/sql/test/BugTracker-2014/Tests/All
--- a/sql/test/BugTracker-2014/Tests/All
+++ b/sql/test/BugTracker-2014/Tests/All
@@ -20,3 +20,4 @@ local-temp-1.Bug-3468
local-temp-2.Bug-3468
oid-table-assert.Bug-3514
round-properties.Bug-3515
+union_with_subqueries.Bug-3518
diff --git a/sql/test/BugTracker-2014/Tests/union_with_subqueries.Bug-3518.sql
b/sql/test/BugTracker-2014/Tests/union_with_subqueries.Bug-3518.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2014/Tests/union_with_subqueries.Bug-3518.sql
@@ -0,0 +1,1 @@
+SELECT sum(a), sum(a) FROM (( SELECT 1 AS A ) UNION ALL (SELECT 3 AS A)) AS
query;
diff --git
a/sql/test/BugTracker-2014/Tests/union_with_subqueries.Bug-3518.stable.err
b/sql/test/BugTracker-2014/Tests/union_with_subqueries.Bug-3518.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2014/Tests/union_with_subqueries.Bug-3518.stable.err
@@ -0,0 +1,35 @@
+stderr of test 'union_with_subqueries.Bug-3518` in directory
'sql/test/BugTracker-2014` itself:
+
+
+# 18:48:46 >
+# 18:48:46 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=37060" "--set"
"mapi_usock=/var/tmp/mtest-27766/.s.monetdb.37060" "--set" "monet_prompt="
"--forcemito" "--set" "mal_listing=2"
"--dbpath=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2014"
"--set" "mal_listing=0"
+# 18:48:46 >
+
+# builtin opt gdk_dbpath =
/home/niels/scratch/rc-clean/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 = 37060
+# cmdline opt mapi_usock = /var/tmp/mtest-27766/.s.monetdb.37060
+# cmdline opt monet_prompt =
+# cmdline opt mal_listing = 2
+# cmdline opt gdk_dbpath =
/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2014
+# cmdline opt mal_listing = 0
+
+# 18:48:46 >
+# 18:48:46 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-27766" "--port=37060"
+# 18:48:46 >
+
+
+# 18:48:47 >
+# 18:48:47 > "Done."
+# 18:48:47 >
+
diff --git
a/sql/test/BugTracker-2014/Tests/union_with_subqueries.Bug-3518.stable.out
b/sql/test/BugTracker-2014/Tests/union_with_subqueries.Bug-3518.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2014/Tests/union_with_subqueries.Bug-3518.stable.out
@@ -0,0 +1,38 @@
+stdout of test 'union_with_subqueries.Bug-3518` in directory
'sql/test/BugTracker-2014` itself:
+
+
+# 18:48:46 >
+# 18:48:46 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=37060" "--set"
"mapi_usock=/var/tmp/mtest-27766/.s.monetdb.37060" "--set" "monet_prompt="
"--forcemito" "--set" "mal_listing=2"
"--dbpath=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2014"
"--set" "mal_listing=0"
+# 18:48:46 >
+
+# MonetDB 5 server v11.17.22
+# This is an unreleased version
+# Serving database 'mTests_sql_test_BugTracker-2014', using 4 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs dynamically
linked
+# Found 7.334 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2014 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://localhost.nes.nl:37060/
+# Listening for UNIX domain connection requests on
mapi:monetdb:///var/tmp/mtest-27766/.s.monetdb.37060
+# MonetDB/GIS module loaded
+# MonetDB/JAQL module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 18:48:46 >
+# 18:48:46 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-27766" "--port=37060"
+# 18:48:46 >
+
+#SELECT sum(a), sum(a) FROM (( SELECT 1 AS A ) UNION ALL (SELECT 3 AS A)) AS
query;
+% .L1, .L2 # table_name
+% L1, L2 # name
+% bigint, bigint # type
+% 1, 1 # length
+[ 4, 4 ]
+
+# 18:48:47 >
+# 18:48:47 > "Done."
+# 18:48:47 >
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list