Changeset: 3241dd9b199b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3241dd9b199b
Modified Files:
        sql/server/rel_select.c
Branch: properties
Log Message:

Cannot optimize very early, it gives issues for views


diffs (34 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
@@ -3503,8 +3503,7 @@ static sql_exp *
                *rel = res;
        }
 
-       /* count(*) case or optimize count(nonil) to count(*) */
-       if (!has_args || (strcmp(aname, "count") == 0 && !distinct && 
list_length(exps) == 1 && !has_nil((sql_exp*)exps->h->data))) {
+       if (!has_args) {        /* count(*) case */
                sql_exp *e;
 
                if (strcmp(aname, "count") != 0) {
@@ -4770,19 +4769,13 @@ rel_rankop(sql_query *query, sql_rel **r
                                append(fargs, exp_atom_bool(sql->sa, 1)); /* 
ignore nills */
                }
 
-               /* count(*), also optimize count(nonil) -> count(*) */
-               if (!nfargs || (strcmp(aname, "count") == 0 && !distinct && 
nfargs == 1 && !has_nil((sql_exp*)fargs->h->data))) {
+               if (!nfargs) { /* count(*) */
                        if (window_function->token == SQL_AGGR && strcmp(aname, 
"count") != 0) {
                                char *uaname = SA_NEW_ARRAY(sql->ta, char, 
strlen(aname) + 1);
                                return sql_error(sql, 02, SQLSTATE(42000) "%s: 
unable to perform '%s(*)'", toUpperCopy(uaname, aname), aname);
                        }
                        sql_subfunc *star = sql_bind_func(sql->sa, s, "star", 
NULL, NULL, F_FUNC);
                        in = exp_op(sql->sa, NULL, star);
-                       if (nfargs) { /* doing count(nonil) -> count(*) 
optimization, remove the current argument list */
-                               assert(list_length(fargs) == 2);
-                               list_remove_node(fargs, fargs->h);
-                               list_remove_node(fargs, fargs->h);
-                       }
                        append(fargs, in);
                        append(fargs, exp_atom_bool(sql->sa, 0)); /* don't 
ignore nills */
                }
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to