Changeset: 617e10d1b5fa for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=617e10d1b5fa
Modified Files:
        sql/src/server/rel_bin.c
Branch: default
Log Message:

in case of distinct and orderby we need to reduce the orderby column/expressions
with the distinct result (in case not al orderby columns are in the result set)


diffs (24 lines):

diff -r d161ef0ae733 -r 617e10d1b5fa sql/src/server/rel_bin.c
--- a/sql/src/server/rel_bin.c  Sun Dec 05 10:50:02 2010 +0100
+++ b/sql/src/server/rel_bin.c  Sun Dec 05 14:08:55 2010 +0100
@@ -1512,8 +1512,19 @@
                }
                sub = stmt_list(sql->sa, npl);
        }
-       if (need_distinct(rel))
+       if (need_distinct(rel)) {
                psub = rel2bin_distinct(sql, psub);
+               /* also rebuild sub as multiple orderby expressions may use the 
sub table (ie aren't part of the result columns) */
+               if (sub) {
+                       list *npl = list_new(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) 
+                               list_append(npl, stmt_project(sql->sa, 
distinct, column(sql->sa, n->data))); 
+                       sub = stmt_list(sql->sa, npl);
+               }
+       }
        if ((!topn || need_distinct(rel)) && rel->r) {
                list *oexps = rel->r;
                stmt *orderby = NULL;
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to