Changeset: a8ed813d5c81 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a8ed813d5c81 Added Files: 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_select.c Branch: Nov2019 Log Message:
Fix for bug 6815, ie call exp_subtype to get the type of an expression instead of differentiating the 'tpe' field, because for e_func and e_aggr, it's not stored in there diffs (161 lines): 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 @@ -579,14 +579,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; } } @@ -2016,14 +2017,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; } } @@ -4882,7 +4884,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) { @@ -5439,20 +5441,20 @@ 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); } } else if(is_nth_value && nfargs == 1) { //nth_value second 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_rel *lr = p->l; sql_exp *ep = lr->exps->h->data; - 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; } in = opt_groupby_add_exp(sql, p, pp, in); @@ -5506,7 +5508,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/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.L1 # table_name +% opt_len # name +% varchar # type +% 0 # length +#rollback; + +# 15:58:04 > +# 15:58:04 > "Done." +# 15:58:04 > + _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list