Changeset: b8a00fcd2d1b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b8a00fcd2d1b Added Files: sql/test/BugTracker-2019/Tests/count-distinct.Bug-6790.sql sql/test/BugTracker-2019/Tests/count-distinct.Bug-6790.stable.err sql/test/BugTracker-2019/Tests/count-distinct.Bug-6790.stable.out Modified Files: sql/server/rel_optimizer.c sql/test/BugTracker-2019/Tests/All Branch: default Log Message:
Merge with Nov2019 diffs (243 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 @@ -2493,9 +2493,7 @@ rel_distinct_aggregate_on_unique_values( for (node *m = ((list*)exp->l)->h; m && all_unique; m = m->next) { sql_exp *arg = (sql_exp*) m->data; - if (arg->card == CARD_ATOM) /* constants are always unique */ - continue; - else if (arg->type == e_column) { + if (arg->type == e_column) { fcmp cmp = (fcmp)&kc_column_cmp; sql_column *c = exp_find_column(rel, arg, -2); @@ -7463,7 +7461,7 @@ rel_simplify_predicates(int *changes, mv if ((is_select(rel->op) || is_join(rel->op) || is_semi(rel->op)) && rel->exps && rel->card > CARD_ATOM) { node *n; list *exps = sa_list(sql->sa); - + for (n = rel->exps->h; n; n = n->next) { sql_exp *e = n->data; @@ -7491,7 +7489,7 @@ rel_simplify_predicates(int *changes, mv if (l->type == e_func) { sql_subfunc *f = l->f; - + /* rewrite isnull(x) = TRUE/FALSE => x =/<> NULL */ if (is_select(rel->op) && !f->func->s && !strcmp(f->func->base.name, "isnull") && is_atom(r->type) && r->l) { /* direct literal */ diff --git a/sql/test/BugTracker-2019/Tests/All b/sql/test/BugTracker-2019/Tests/All --- a/sql/test/BugTracker-2019/Tests/All +++ b/sql/test/BugTracker-2019/Tests/All @@ -48,3 +48,4 @@ rank-nan.Bug-6780 index-insert-crash.Bug-6781 avg-changes-value-scale.Bug-6783 isaUUID.Bug-6784 +count-distinct.Bug-6790 diff --git a/sql/test/BugTracker-2019/Tests/count-distinct.Bug-6790.sql b/sql/test/BugTracker-2019/Tests/count-distinct.Bug-6790.sql new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2019/Tests/count-distinct.Bug-6790.sql @@ -0,0 +1,19 @@ +START TRANSACTION; +CREATE TABLE tab0(col0 INTEGER, col1 INTEGER, col2 INTEGER); +CREATE TABLE tab1(col0 INTEGER, col1 INTEGER, col2 INTEGER); +CREATE TABLE tab2(col0 INTEGER, col1 INTEGER, col2 INTEGER); +INSERT INTO tab0 VALUES (97,1,99), (15,81,47),(87,21,10); +INSERT INTO tab1 VALUES (51,14,96), (85,5,59), (91,47,68); +INSERT INTO tab2 VALUES (64,77,40), (75,67,58),(46,51,23); + +SELECT COUNT ( DISTINCT + 45 ) AS col2 FROM tab0; +SELECT DISTINCT CAST( - SUM ( DISTINCT 10 ) AS BIGINT) AS col1 FROM tab2; +SELECT DISTINCT CAST(49 * + 78 + + COUNT ( DISTINCT + 5 ) AS BIGINT) AS col0 FROM tab1 AS cor0; +SELECT CAST(72 + - + COUNT ( * ) - - - COUNT ( DISTINCT + ( - 2 ) ) * + + 57 AS BIGINT) FROM tab2; +SELECT DISTINCT - 37, - COUNT ( DISTINCT - + 96 ) col1 FROM tab2; + +SELECT DISTINCT + ( CAST ( NULL AS INTEGER ) ) AS col0, col0 FROM tab0; +SELECT DISTINCT CAST ( NULL AS INTEGER ) - - 95 AS col1, CAST(col2 * + + col1 AS BIGINT) AS col1 FROM tab2 AS cor0; +SELECT DISTINCT + 14 AS col2, + col0 - - CAST ( NULL AS INTEGER ) AS col2 FROM tab2 AS cor0; +SELECT DISTINCT col1, + col0 col1 FROM tab1; +ROLLBACK; diff --git a/sql/test/BugTracker-2019/Tests/count-distinct.Bug-6790.stable.err b/sql/test/BugTracker-2019/Tests/count-distinct.Bug-6790.stable.err new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2019/Tests/count-distinct.Bug-6790.stable.err @@ -0,0 +1,30 @@ +stderr of test 'count-distinct.Bug-6790` in directory 'sql/test/BugTracker-2019` itself: + + +# 10:33:38 > +# 10:33:38 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=30367" "--set" "mapi_usock=/var/tmp/mtest-125811/.s.monetdb.30367" "--forcemito" "--dbpath=/home/ferreira/repositories/MonetDB-Nov2019/BUILD/var/MonetDB/mTests_sql_test_BugTracker-2019" "--set" "embedded_c=true" +# 10:33:38 > + +# builtin opt gdk_dbpath = /home/ferreira/repositories/MonetDB-Nov2019/BUILD/var/monetdb5/dbfarm/demo +# builtin opt mapi_port = 50000 +# builtin opt mapi_open = false +# builtin opt mapi_ipv6 = 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 = 30367 +# cmdline opt mapi_usock = /var/tmp/mtest-125811/.s.monetdb.30367 +# cmdline opt gdk_dbpath = /home/ferreira/repositories/MonetDB-Nov2019/BUILD/var/MonetDB/mTests_sql_test_BugTracker-2019 +# cmdline opt embedded_c = true + +# 10:33:39 > +# 10:33:39 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-125811" "--port=30367" +# 10:33:39 > + + +# 10:33:39 > +# 10:33:39 > "Done." +# 10:33:39 > + diff --git a/sql/test/BugTracker-2019/Tests/count-distinct.Bug-6790.stable.out b/sql/test/BugTracker-2019/Tests/count-distinct.Bug-6790.stable.out new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2019/Tests/count-distinct.Bug-6790.stable.out @@ -0,0 +1,139 @@ +stdout of test 'count-distinct.Bug-6790` in directory 'sql/test/BugTracker-2019` itself: + + +# 10:33:38 > +# 10:33:38 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=30367" "--set" "mapi_usock=/var/tmp/mtest-125811/.s.monetdb.30367" "--forcemito" "--dbpath=/home/ferreira/repositories/MonetDB-Nov2019/BUILD/var/MonetDB/mTests_sql_test_BugTracker-2019" "--set" "embedded_c=true" +# 10:33:38 > + +# MonetDB 5 server v11.35.2 (hg id: ccacebde5b21) +# This is an unreleased version +# Serving database 'mTests_sql_test_BugTracker-2019', using 8 threads +# Compiled for x86_64-pc-linux-gnu/64bit with 128bit integers +# Found 15.504 GiB available main-memory of which we use 12.635 GiB +# Copyright (c) 1993 - July 2008 CWI. +# Copyright (c) August 2008 - 2019 MonetDB B.V., all rights reserved +# Visit https://www.monetdb.org/ for further information +# Listening for connection requests on mapi:monetdb://localhost.localdomain:30367/ +# Listening for UNIX domain connection requests on mapi:monetdb:///var/tmp/mtest-125811/.s.monetdb.30367 +# MonetDB/GIS module loaded +# SQL catalog created, loading sql scripts once +# loading sql script: 09_like.sql +# loading sql script: 10_math.sql +# loading sql script: 12_url.sql +# loading sql script: 13_date.sql +# loading sql script: 14_inet.sql +# loading sql script: 15_querylog.sql +# loading sql script: 16_tracelog.sql +# loading sql script: 17_temporal.sql +# loading sql script: 18_index.sql +# loading sql script: 20_vacuum.sql +# loading sql script: 21_dependency_views.sql +# loading sql script: 22_clients.sql +# loading sql script: 23_skyserver.sql +# loading sql script: 25_debug.sql +# loading sql script: 26_sysmon.sql +# loading sql script: 27_rejects.sql +# loading sql script: 39_analytics.sql +# loading sql script: 39_analytics_hge.sql +# loading sql script: 40_geom.sql +# loading sql script: 40_json.sql +# loading sql script: 40_json_hge.sql +# loading sql script: 41_md5sum.sql +# loading sql script: 45_uuid.sql +# loading sql script: 46_profiler.sql +# loading sql script: 51_sys_schema_extension.sql +# loading sql script: 60_wlcr.sql +# loading sql script: 61_wlcr.sql +# loading sql script: 72_fits.sql +# loading sql script: 74_netcdf.sql +# loading sql script: 75_lidar.sql +# loading sql script: 75_shp.sql +# loading sql script: 75_storagemodel.sql +# loading sql script: 80_statistics.sql +# loading sql script: 80_udf.sql +# loading sql script: 80_udf_hge.sql +# loading sql script: 85_bam.sql +# loading sql script: 90_generator.sql +# loading sql script: 90_generator_hge.sql +# loading sql script: 99_system.sql +# MonetDB/SQL module loaded + +# 10:33:39 > +# 10:33:39 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-125811" "--port=30367" +# 10:33:39 > + +#START TRANSACTION; +#CREATE TABLE tab0(col0 INTEGER, col1 INTEGER, col2 INTEGER); +#CREATE TABLE tab2(col0 INTEGER, col1 INTEGER, col2 INTEGER); +#INSERT INTO tab0 VALUES (97,1,99), (15,81,47),(87,21,10); +[ 3 ] +#INSERT INTO tab1 VALUES (51,14,96), (85,5,59), (91,47,68); +[ 3 ] +#INSERT INTO tab2 VALUES (64,77,40), (75,67,58),(46,51,23); +[ 3 ] +#SELECT COUNT ( DISTINCT + 45 ) AS col2 FROM tab0; +% .%1 # table_name +% col2 # name +% bigint # type +% 1 # length +[ 1 ] +#SELECT DISTINCT CAST( - SUM ( DISTINCT 10 ) AS BIGINT) AS col1 FROM tab2; +% .%3 # table_name +% col1 # name +% bigint # type +% 3 # length +[ -10 ] +#SELECT DISTINCT CAST(49 * + 78 + + COUNT ( DISTINCT + 5 ) AS BIGINT) AS col0 FROM tab1 AS cor0; +% .%3 # table_name +% col0 # name +% bigint # type +% 4 # length +[ 3823 ] +#SELECT CAST(72 + - + COUNT ( * ) - - - COUNT ( DISTINCT + ( - 2 ) ) * + + 57 AS BIGINT) FROM tab2; +% .%3 # table_name +% %3 # name +% bigint # type +% 2 # length +[ 12 ] +#SELECT DISTINCT - 37, - COUNT ( DISTINCT - + 96 ) col1 FROM tab2; +% .%2, .%3 # table_name +% %2, col1 # name +% tinyint, bigint # type +% 3, 2 # length +[ -37, -1 ] +#SELECT DISTINCT + ( CAST ( NULL AS INTEGER ) ) AS col0, col0 FROM tab0; +% sys.tab0, sys.tab0 # table_name +% col0, col0 # name +% int, int # type +% 2, 2 # length +[ NULL, 97 ] +[ NULL, 15 ] +[ NULL, 87 ] +#SELECT DISTINCT CAST ( NULL AS INTEGER ) - - 95 AS col1, CAST(col2 * + + col1 AS BIGINT) AS col1 FROM tab2 AS cor0; +% sys.%4, sys.%4 # table_name +% col1, col1 # name +% bigint, bigint # type +% 4, 4 # length +[ NULL, 3080 ] +[ NULL, 3886 ] +[ NULL, 1173 ] +#SELECT DISTINCT + 14 AS col2, + col0 - - CAST ( NULL AS INTEGER ) AS col2 FROM tab2 AS cor0; +% sys.%3, sys.%3 # table_name +% col2, col2 # name +% bigint, bigint # type +% 1, 1 # length +[ 14, NULL ] +#SELECT DISTINCT col1, + col0 col1 FROM tab1; +% sys.tab1, sys.tab1 # table_name +% col1, col1 # name +% int, int # type +% 2, 2 # length +[ 14, 51 ] +[ 5, 85 ] +[ 47, 91 ] +#ROLLBACK; + +# 10:33:39 > +# 10:33:39 > "Done." +# 10:33:39 > + _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list