Changeset: 5c4381fb5a66 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5c4381fb5a66 Added Files: sql/test/BugTracker-2020/Tests/ifthenelse-crash.Bug-6815.sql sql/test/BugTracker-2020/Tests/ifthenelse-crash.Bug-6815.stable.err sql/test/BugTracker-2020/Tests/ifthenelse-crash.Bug-6815.stable.out Modified Files: sql/server/rel_dump.c sql/server/rel_optimizer.c sql/server/rel_propagate.c sql/server/rel_select.c sql/test/BugTracker-2020/Tests/All sql/test/miscellaneous/Tests/groupby_error.stable.out Branch: linear-hashing Log Message:
Merged with Nov2019 diffs (244 lines): diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c --- a/sql/server/rel_dump.c +++ b/sql/server/rel_dump.c @@ -118,7 +118,7 @@ exp_print(mvc *sql, stream *fout, sql_ex break; } case e_convert: { - char *to_type = sql_subtype_string(&e->tpe); + char *to_type = sql_subtype_string(exp_subtype(e)); mnstr_printf(fout, "%s[", to_type); exp_print(sql, fout, e->l, depth, refs, 0, 0); mnstr_printf(fout, "]"); 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 @@ -5891,10 +5891,21 @@ rel_groupby_distinct(int *changes, mvc * for (n=rel->exps->h; n; n = n->next) { sql_exp *e = n->data; if (e != distinct) { - e = exp_ref(sql->sa, e); - append(ngbe, e); - append(exps, e); - e = exp_ref(sql->sa, e); + if (e->type == e_aggr) { /* copy the arguments to the aggregate */ + list *args = e->l; + sql_exp *dargs = args->h->data; + + list_append(ngbe, exp_copy(sql, dargs)); + list_append(exps, exp_copy(sql, dargs)); + } else { + e = exp_ref(sql->sa, e); + append(ngbe, e); + append(exps, e); + } + if (e->type == e_aggr) /* aggregates must be copied */ + e = exp_copy(sql, e); + else + e = exp_ref(sql->sa, e); append(nexps, e); } } diff --git a/sql/server/rel_propagate.c b/sql/server/rel_propagate.c --- a/sql/server/rel_propagate.c +++ b/sql/server/rel_propagate.c @@ -188,11 +188,11 @@ create_range_partition_anti_rel(sql_quer sql_exp *range1, *range2; e1 = exp_copy(sql, pmin); if (subtype_cmp(exp_subtype(pmin), &tpe) != 0) - e1 = exp_convert(sql->sa, e1, &e1->tpe, &tpe); + e1 = exp_convert(sql->sa, e1, exp_subtype(e1), &tpe); e2 = exp_copy(sql, pmax); if (subtype_cmp(exp_subtype(e2), &tpe) != 0) - e2 = exp_convert(sql->sa, e2, &e2->tpe, &tpe); + e2 = exp_convert(sql->sa, e2, exp_subtype(e2), &tpe); range1 = exp_compare(sql->sa, exp_copy(sql, anti_le), e1, 3); range2 = exp_compare(sql->sa, exp_copy(sql, anti_le), e2, 1); 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 @@ -510,14 +510,15 @@ find_table_function_type(mvc *sql, sql_s for (n = exps->h, m = (*sf)->func->ops->h; n && m; n = n->next, m = m->next) { sql_arg *a = m->data; sql_exp *e = n->data; + sql_subtype *t = exp_subtype(e); if (!aa && a->type.type->eclass == EC_ANY) { - atp = &e->tpe; + atp = t; aa = a; } if (aa && a->type.type->eclass == EC_ANY && - e->tpe.type->localtype > atp->type->localtype){ - atp = &e->tpe; + t->type->localtype > atp->type->localtype){ + atp = t; aa = a; } } @@ -1855,14 +1856,15 @@ static sql_exp* for (n = exps->h, m = f->func->ops->h; n && m; n = n->next, m = m->next) { sql_arg *a = m->data; sql_exp *e = n->data; + sql_subtype *t = exp_subtype(e); if (!aa && a->type.type->eclass == EC_ANY) { - atp = &e->tpe; + atp = t; aa = a; } if (aa && a->type.type->eclass == EC_ANY && - e->tpe.type->localtype > atp->type->localtype){ - atp = &e->tpe; + t->type->localtype > atp->type->localtype){ + atp = t; aa = a; } } @@ -4174,7 +4176,7 @@ rel_order_by(sql_query *query, sql_rel * e = rel_value_exp2(query, &rel, col, f, ek, &is_last); if (e && e->card <= CARD_ATOM) { - sql_subtype *tpe = &e->tpe; + sql_subtype *tpe = exp_subtype(e); /* integer atom on the stack */ if (e->type == e_atom && tpe->type->eclass == EC_NUM) { @@ -4580,7 +4582,7 @@ rel_rankop(sql_query *query, sql_rel **r return NULL; if(is_ntile && nfargs == 1) { /* ntile first argument null handling case */ sql_subtype *empty = sql_bind_localtype("void"); - if(subtype_cmp(&(in->tpe), empty) == 0) { + if(subtype_cmp(exp_subtype(in), empty) == 0) { sql_subtype *to = sql_bind_localtype("bte"); in = exp_convert(sql->sa, in, empty, to); } @@ -4588,11 +4590,11 @@ rel_rankop(sql_query *query, sql_rel **r sql_subtype *empty = sql_bind_localtype("void"); if(subtype_cmp(&(in->tpe), empty) == 0) { sql_exp *ep = rel_first_column(sql, p); - in = exp_convert(sql->sa, in, empty, &(ep->tpe)); + in = exp_convert(sql->sa, in, empty, exp_subtype(ep)); } } else if((is_lag || is_lead) && nfargs == 2) { /* lag and lead 3rd arg must have same type as 1st arg */ sql_exp *first = (sql_exp*) fargs->h->data; - if(!(in = rel_check_type(sql, &first->tpe, p, in, type_equal))) + if(!(in = rel_check_type(sql, exp_subtype(first), p, in, type_equal))) return NULL; } if (!in) @@ -4631,7 +4633,7 @@ rel_rankop(sql_query *query, sql_rel **r sql_subtype *empty = sql_bind_localtype("void"), *bte = sql_bind_localtype("bte"); sql_exp* eo = fargs->h->data; /* corner case, if the argument is null convert it into something countable such as bte */ - if(subtype_cmp(&(eo->tpe), empty) == 0) + if(subtype_cmp(exp_subtype(eo), empty) == 0) fargs->h->data = exp_convert(sql->sa, eo, empty, bte); append(fargs, exp_atom_bool(sql->sa, 1)); /* ignore nills */ } diff --git a/sql/test/BugTracker-2020/Tests/All b/sql/test/BugTracker-2020/Tests/All --- a/sql/test/BugTracker-2020/Tests/All +++ b/sql/test/BugTracker-2020/Tests/All @@ -1,1 +1,2 @@ median_avg-nulls.Bug-6807 +ifthenelse-crash.Bug-6815 diff --git a/sql/test/BugTracker-2020/Tests/ifthenelse-crash.Bug-6815.sql b/sql/test/BugTracker-2020/Tests/ifthenelse-crash.Bug-6815.sql new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2020/Tests/ifthenelse-crash.Bug-6815.sql @@ -0,0 +1,4 @@ +start transaction; +create table t6815 (type_digits int); +select ifthenelse((type_digits > 0), '('||type_digits||')', '') as opt_len from t6815; +rollback; diff --git a/sql/test/BugTracker-2020/Tests/ifthenelse-crash.Bug-6815.stable.err b/sql/test/BugTracker-2020/Tests/ifthenelse-crash.Bug-6815.stable.err new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2020/Tests/ifthenelse-crash.Bug-6815.stable.err @@ -0,0 +1,30 @@ +stderr of test 'ifthenelse-crash.Bug-6815` in directory 'sql/test/BugTracker-2020` itself: + + +# 15:58:03 > +# 15:58:03 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=36500" "--set" "mapi_usock=/var/tmp/mtest-377911/.s.monetdb.36500" "--forcemito" "--dbpath=/home/ferreira/repositories/MonetDB-Nov2019/BUILD/var/MonetDB/mTests_sql_test_BugTracker-2020" "--set" "embedded_c=true" +# 15:58:03 > + +# 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 = 36500 +# cmdline opt mapi_usock = /var/tmp/mtest-377911/.s.monetdb.36500 +# cmdline opt gdk_dbpath = /home/ferreira/repositories/MonetDB-Nov2019/BUILD/var/MonetDB/mTests_sql_test_BugTracker-2020 +# cmdline opt embedded_c = true + +# 15:58:03 > +# 15:58:03 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-377911" "--port=36500" +# 15:58:03 > + + +# 15:58:04 > +# 15:58:04 > "Done." +# 15:58:04 > + diff --git a/sql/test/BugTracker-2020/Tests/ifthenelse-crash.Bug-6815.stable.out b/sql/test/BugTracker-2020/Tests/ifthenelse-crash.Bug-6815.stable.out new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2020/Tests/ifthenelse-crash.Bug-6815.stable.out @@ -0,0 +1,37 @@ +stdout of test 'ifthenelse-crash.Bug-6815` in directory 'sql/test/BugTracker-2020` itself: + + +# 15:58:03 > +# 15:58:03 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=36500" "--set" "mapi_usock=/var/tmp/mtest-377911/.s.monetdb.36500" "--forcemito" "--dbpath=/home/ferreira/repositories/MonetDB-Nov2019/BUILD/var/MonetDB/mTests_sql_test_BugTracker-2020" "--set" "embedded_c=true" +# 15:58:03 > + +# MonetDB 5 server v11.35.6 (hg id: 4c25f517a2d8) +# This is an unreleased version +# Serving database 'mTests_sql_test_BugTracker-2020', using 8 threads +# Compiled for x86_64-pc-linux-gnu/64bit with 128bit integers +# Found 15.496 GiB available main-memory of which we use 12.630 GiB +# Copyright (c) 1993 - July 2008 CWI. +# Copyright (c) August 2008 - 2020 MonetDB B.V., all rights reserved +# Visit https://www.monetdb.org/ for further information +# Listening for connection requests on mapi:monetdb://localhost.localdomain:36500/ +# Listening for UNIX domain connection requests on mapi:monetdb:///var/tmp/mtest-377911/.s.monetdb.36500 +# MonetDB/GIS module loaded +# MonetDB/SQL module loaded + +# 15:58:03 > +# 15:58:03 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-377911" "--port=36500" +# 15:58:03 > + +#start transaction; +#create table t6815 (type_digits int); +#select ifthenelse((type_digits > 0), '('||type_digits||')', '') as opt_len from t6815; +% sys. # table_name +% opt_len # name +% varchar # type +% 0 # length +#rollback; + +# 15:58:04 > +# 15:58:04 > "Done." +# 15:58:04 > + diff --git a/sql/test/miscellaneous/Tests/groupby_error.stable.out b/sql/test/miscellaneous/Tests/groupby_error.stable.out --- a/sql/test/miscellaneous/Tests/groupby_error.stable.out +++ b/sql/test/miscellaneous/Tests/groupby_error.stable.out @@ -72,7 +72,7 @@ stdout of test 'groupby_error` in direct #INSERT INTO tab0 VALUES(97,1,99), (15,81,47), (87,21,10); [ 3 ] #SELECT CAST(+ col1 * - col1 AS BIGINT) AS col2 FROM tab0 GROUP BY col2, col0, col1 HAVING + - col0 / - AVG ( ALL + col2 ) - - - AVG ( DISTINCT + col0 ) + col0 IS NULL; -% sys.L2 # table_name +% sys. # table_name % col2 # name % bigint # type % 1 # length _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list