Changeset: f3b9839c7ed6 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f3b9839c7ed6 Added Files: sql/test/BugTracker-2014/Tests/crash_on_groupby_distinct_serial.Bug-3463.sql sql/test/BugTracker-2014/Tests/crash_on_groupby_distinct_serial.Bug-3463.stable.err sql/test/BugTracker-2014/Tests/crash_on_groupby_distinct_serial.Bug-3463.stable.out Modified Files: sql/server/rel_optimizer.c sql/test/BugTracker-2014/Tests/All Branch: Jan2014 Log Message:
fixed bug 3463, make sure we also handle aliases in the aggr list when reducing groupby expressions diffs (116 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 @@ -3912,7 +3912,11 @@ rel_reduce_groupby_exps(int *changes, mv if (scores[l] == -1 && exp_match_exp(e,gb)) { sql_column *c = exp_find_column_(rel, e, -2, &bt); - sql_exp *rs = exp_column(sql->sa, rnme, c->base.name, exp_subtype(e), rel->card, has_nil(e), is_intern(e)); + sql_exp *rs; + + if (!c) + c = exp_find_column_(rel, gb, -2, &bt); + rs = exp_column(sql->sa, rnme, c->base.name, exp_subtype(e), rel->card, has_nil(e), is_intern(e)); exp_setname(sql->sa, rs, exp_find_rel_name(e), exp_name(e)); append(r->exps, rs); fnd = 1; 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 @@ -13,3 +13,4 @@ setreadonly_forgets_changes.Bug-3446 select-having.Bug-3458 crash_on_or_with_in.Bug-3461 in_incorrect_multi.Bug-3462 +crash_on_groupby_distinct_serial.Bug-3463 diff --git a/sql/test/BugTracker-2014/Tests/crash_on_groupby_distinct_serial.Bug-3463.sql b/sql/test/BugTracker-2014/Tests/crash_on_groupby_distinct_serial.Bug-3463.sql new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2014/Tests/crash_on_groupby_distinct_serial.Bug-3463.sql @@ -0,0 +1,3 @@ +CREATE TABLE test (a int, b int, c serial); +SELECT a as t, count(distinct c) FROM test GROUP BY t; +drop table test; diff --git a/sql/test/BugTracker-2014/Tests/crash_on_groupby_distinct_serial.Bug-3463.stable.err b/sql/test/BugTracker-2014/Tests/crash_on_groupby_distinct_serial.Bug-3463.stable.err new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2014/Tests/crash_on_groupby_distinct_serial.Bug-3463.stable.err @@ -0,0 +1,35 @@ +stderr of test 'crash_on_groupby_distinct_serial.Bug-3463` in directory 'sql/test/BugTracker-2014` itself: + + +# 12:20:38 > +# 12:20:38 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=38842" "--set" "mapi_usock=/var/tmp/mtest-18464/.s.monetdb.38842" "--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" +# 12:20:38 > + +# 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 = 38842 +# cmdline opt mapi_usock = /var/tmp/mtest-18464/.s.monetdb.38842 +# 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 + +# 12:20:39 > +# 12:20:39 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-18464" "--port=38842" +# 12:20:39 > + + +# 12:20:39 > +# 12:20:39 > "Done." +# 12:20:39 > + diff --git a/sql/test/BugTracker-2014/Tests/crash_on_groupby_distinct_serial.Bug-3463.stable.out b/sql/test/BugTracker-2014/Tests/crash_on_groupby_distinct_serial.Bug-3463.stable.out new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2014/Tests/crash_on_groupby_distinct_serial.Bug-3463.stable.out @@ -0,0 +1,39 @@ +stdout of test 'crash_on_groupby_distinct_serial.Bug-3463` in directory 'sql/test/BugTracker-2014` itself: + + +# 12:20:38 > +# 12:20:38 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=38842" "--set" "mapi_usock=/var/tmp/mtest-18464/.s.monetdb.38842" "--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" +# 12:20:38 > + +# MonetDB 5 server v11.17.14 +# 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:38842/ +# Listening for UNIX domain connection requests on mapi:monetdb:///var/tmp/mtest-18464/.s.monetdb.38842 +# MonetDB/GIS module loaded +# MonetDB/JAQL module loaded +# MonetDB/SQL module loaded + +Ready. + +# 12:20:39 > +# 12:20:39 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-18464" "--port=38842" +# 12:20:39 > + +#CREATE TABLE test (a int, b int, c serial); +#SELECT a as t, count(distinct c) FROM test GROUP BY t; +% sys.test, sys.L1 # table_name +% t, L1 # name +% int, wrd # type +% 1, 1 # length +#drop table test; + +# 12:20:39 > +# 12:20:39 > "Done." +# 12:20:39 > + _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list