Changeset: 26960937a4c9 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=26960937a4c9 Modified Files: sql/server/rel_optimizer.c sql/test/miscellaneous/Tests/groupby_error.sql sql/test/miscellaneous/Tests/groupby_error.stable.out Branch: Nov2019 Log Message:
Defensive line, an aggregate might not have arguments diffs (41 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 @@ -5917,9 +5917,10 @@ rel_groupby_distinct(int *changes, mvc * 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->sa, dargs)); - list_append(exps, exp_copy(sql->sa, dargs)); + if (args) { + list_append(ngbe, exp_copy(sql->sa, dargs)); + list_append(exps, exp_copy(sql->sa, dargs)); + } } else { e = exp_ref(sql->sa, e); append(ngbe, e); diff --git a/sql/test/miscellaneous/Tests/groupby_error.sql b/sql/test/miscellaneous/Tests/groupby_error.sql --- a/sql/test/miscellaneous/Tests/groupby_error.sql +++ b/sql/test/miscellaneous/Tests/groupby_error.sql @@ -10,4 +10,5 @@ START TRANSACTION; CREATE TABLE tab0(col0 INTEGER, col1 INTEGER, col2 INTEGER); INSERT INTO tab0 VALUES(97,1,99), (15,81,47), (87,21,10); 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; +SELECT DISTINCT + 40 / + + col0 AS col2 FROM tab0 GROUP BY col0, col0, col2 HAVING NOT ( NOT + - 80 BETWEEN NULL AND + - 73 ) OR NOT ( + col0 >= - COUNT ( * ) + - COUNT ( DISTINCT - col0 ) ); ROLLBACK; 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 @@ -76,6 +76,11 @@ stdout of test 'groupby_error` in direct % col2 # name % bigint # type % 1 # length +#SELECT DISTINCT + 40 / + + col0 AS col2 FROM tab0 GROUP BY col0, col0, col2 HAVING NOT ( NOT + - 80 BETWEEN NULL AND + - 73 ) OR NOT ( + col0 >= - COUNT ( * ) + - COUNT ( DISTINCT - col0 ) ); +% .L1 # table_name +% col2 # name +% int # type +% 1 # length #ROLLBACK; # 10:56:47 > _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list