Changeset: d3a1eddca24b for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d3a1eddca24b Modified Files: sql/backends/monet5/rel_bin.c Branch: Jan2014 Log Message:
fixed bug 3498, make sure we have a table (not a single row) before we do the topn. fixed bug 3489, distinct with order by, use the proper extend directly for the possible order by columns (which are not part of the output) diffs (74 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 @@ -1768,7 +1768,7 @@ rel2bin_semijoin( mvc *sql, sql_rel *rel } static stmt * -rel2bin_distinct(mvc *sql, stmt *s) +rel2bin_distinct(mvc *sql, stmt *s, stmt **distinct) { node *n; stmt *g = NULL, *grp = NULL, *ext = NULL, *cnt = NULL; @@ -1808,6 +1808,8 @@ rel2bin_distinct(mvc *sql, stmt *s) list_append(rl, stmt_project(sql->sa, ext, t)); } + if (distinct) + *distinct = ext; s = stmt_list(sql->sa, rl); return s; } @@ -1869,7 +1871,7 @@ rel2bin_union( mvc *sql, sql_rel *rel, l } if (need_distinct(rel)) - sub = rel2bin_distinct(sql, sub); + sub = rel2bin_distinct(sql, sub, NULL); return sub; } @@ -2008,7 +2010,7 @@ rel2bin_except( mvc *sql, sql_rel *rel, } if (need_distinct(rel)) - sub = rel2bin_distinct(sql, sub); + sub = rel2bin_distinct(sql, sub, NULL); return sub; } @@ -2134,7 +2136,7 @@ rel2bin_inter( mvc *sql, sql_rel *rel, l } if (need_distinct(rel)) - sub = rel2bin_distinct(sql, sub); + sub = rel2bin_distinct(sql, sub, NULL); return sub; } @@ -2232,7 +2234,10 @@ rel2bin_project( mvc *sql, sql_rel *rel, assert(0); return NULL; } - if (sub && sub->nrcols >= 1 && s->nrcols == 0) + /* single value with limit */ + if (topn && rel->r && sub && sub->nrcols == 0) + s = const_column(sql->sa, s); + else if (sub && sub->nrcols >= 1 && s->nrcols == 0) s = stmt_const(sql->sa, bin_first_column(sql->sa, sub), s); s = stmt_rename(sql, rel, exp, s); @@ -2288,11 +2293,11 @@ rel2bin_project( mvc *sql, sql_rel *rel, sub = stmt_list(sql->sa, npl); } if (need_distinct(rel)) { - psub = rel2bin_distinct(sql, psub); + stmt *distinct = NULL; + psub = rel2bin_distinct(sql, psub, &distinct); /* also rebuild sub as multiple orderby expressions may use the sub table (ie aren't part of the result columns) */ if (sub) { list *npl = sa_list(sql->sa); - stmt *distinct = stmt_mirror(sql->sa, psub->op4.lval->h->data); pl = sub->op4.lval; for ( n=pl->h ; n; n = n->next) _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list