Changeset: 6511c5ec6d32 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6511c5ec6d32 Modified Files: sql/backends/monet5/rel_bin.c sql/server/rel_optimizer.c sql/test/BugTracker-2017/Tests/sqlitelogictest-hidden-alias.Bug-6495.stable.out sql/test/BugTracker-2018/Tests/sqlitelogictest-having-not-null-not-in.Bug-6557.stable.out sql/test/analytics/Tests/analytics16.stable.err sql/test/miscellaneous/Tests/groupby_error.stable.out Branch: default Log Message:
Merged with Jun2020 diffs (100 lines): diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c --- a/sql/backends/monet5/rel_bin.c +++ b/sql/backends/monet5/rel_bin.c @@ -21,6 +21,7 @@ #include "sql_optimizer.h" #include "sql_gencode.h" #include "mal_builder.h" +#include "opt_prelude.h" #define OUTER_ZERO 64 @@ -1873,7 +1874,14 @@ rel2bin_table(backend *be, sql_rel *rel, /* use a simple nested loop solution for this case, ie * output a table of (input) row-ids, the output of the table producing function */ - InstrPtr q = newStmt(be->mb, "sql", "unionfunc"); + /* make sure the input for sql.unionfunc are bats */ + if (ids) + ids = column(be, ids); + if (ops) + for (node *en = ops->h; en; en = en->next) + en->data = column(be, (stmt *) en->data); + + InstrPtr q = newStmt(be->mb, sqlRef, "unionfunc"); /* Generate output rowid column and output of function f */ for(i=0; m; m = m->next, i++) { sql_exp *e = m->data; 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 @@ -2523,7 +2523,8 @@ rel_distinct_project2groupby(mvc *sql, s if (rel->op == op_project && rel->l && !rel->r /* no order by */ && need_distinct(rel) && exps_card(rel->exps) <= CARD_ATOM) { set_nodistinct(rel); - rel->l = rel_topn(sql->sa, rel->l, append(sa_list(sql->sa), exp_atom_lng(sql->sa, 1))); + if (rel->card > CARD_ATOM) /* if the projection just contains constants, then no topN is needed */ + rel->l = rel_topn(sql->sa, rel->l, append(sa_list(sql->sa), exp_atom_lng(sql->sa, 1))); } /* rewrite distinct project [ pk ] ( select ( table ) [ e op val ]) diff --git a/sql/test/BugTracker-2017/Tests/sqlitelogictest-hidden-alias.Bug-6495.stable.out b/sql/test/BugTracker-2017/Tests/sqlitelogictest-hidden-alias.Bug-6495.stable.out --- a/sql/test/BugTracker-2017/Tests/sqlitelogictest-hidden-alias.Bug-6495.stable.out +++ b/sql/test/BugTracker-2017/Tests/sqlitelogictest-hidden-alias.Bug-6495.stable.out @@ -40,7 +40,7 @@ stdout of test 'sqlitelogictest-hidden-a % bigint # type % 1 # length #SELECT DISTINCT + MAX ( DISTINCT - col1 ) col2 FROM tab0 WHERE - col3 + + 72 IS NULL; -% . # table_name +% sys. # table_name % col2 # name % double # type % 24 # length diff --git a/sql/test/BugTracker-2018/Tests/sqlitelogictest-having-not-null-not-in.Bug-6557.stable.out b/sql/test/BugTracker-2018/Tests/sqlitelogictest-having-not-null-not-in.Bug-6557.stable.out --- a/sql/test/BugTracker-2018/Tests/sqlitelogictest-having-not-null-not-in.Bug-6557.stable.out +++ b/sql/test/BugTracker-2018/Tests/sqlitelogictest-having-not-null-not-in.Bug-6557.stable.out @@ -52,7 +52,7 @@ stdout of test 'sqlitelogictest-having-n % 3 # length [ 126 ] #SELECT DISTINCT COUNT(*) FROM tab0 WHERE NOT col2 NOT BETWEEN ( 35 ) AND ( NULL ); -% .%1 # table_name +% sys.%1 # table_name % %1 # name % bigint # type % 1 # length 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 @@ -426,6 +426,32 @@ project ( % bigint, bigint # type % 2, 3 # length [ 87, -37 ] +#SELECT DISTINCT CAST(- CAST ( CASE 81 WHEN 48 - - 3 / - - 47 - - CAST ( NULL AS INTEGER ) THEN NULL WHEN COUNT ( * ) THEN + - 91 + + 43 ELSE + - 0 END AS INTEGER ) AS BIGINT) AS col0, CAST(- 27 * + 43 AS BIGINT); +% ., . # table_name +% col0, %3 # name +% bigint, bigint # type +% 1, 5 # length +[ 0, -1161 ] +#SELECT DISTINCT CAST(66 * - + CAST ( - - COUNT ( * ) AS INTEGER ) * 54 * + CASE 68 WHEN - 56 * + CAST ( NULL AS INTEGER ) + + + 47 THEN +#- 83 ELSE + 59 + - COUNT ( * ) - 26 * ( 59 ) * 11 - - + COUNT ( * ) * - 73 END + + COUNT ( * ) / + ( 86 + 19 * 90 ) AS BIGINT); +% .%16 # table_name +% %16 # name +% bigint # type +% 8 # length +[ 60192396 ] +#SELECT DISTINCT CAST(+ - CASE + 66 WHEN - CAST ( NULL AS INTEGER ) THEN NULL ELSE COUNT ( * ) + - CASE + COUNT ( * ) WHEN - 69 - + - 28 THEN - + MIN ( + 92 ) WHEN - COUNT ( 32 ) THEN +#+ ( + 23 ) * + 17 * - 37 WHEN 63 THEN NULL ELSE + 67 * - 34 - 64 END - 31 END * - 94 AS BIGINT) AS col2; +% . # table_name +% col2 # name +% bigint # type +% 6 # length +[ 217328 ] +#SELECT DISTINCT CAST(( + CASE WHEN NOT NULL BETWEEN NULL AND NULL THEN NULL ELSE + COUNT ( * ) END ) AS BIGINT) AS col1; +% . # table_name +% col1 # name +% bigint # type +% 1 # length +[ 1 ] # 10:56:47 > # 10:56:47 > "Done." _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list