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

small cleanup (cleaner localisation of having/select and groupby)


diffs (63 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
@@ -3815,18 +3815,14 @@ static sql_exp *
        sql_rel *groupby = *rel, *sel = NULL, *gr, *og = NULL;
        list *exps = NULL;
 
-       (void)sel;
-
        /* find having select */
-       if (groupby && groupby->l && !is_processed(groupby) && 
is_sql_having(f)) { 
-               sql_rel *gl = NULL;
-
+       if (groupby && !is_processed(groupby) && is_sql_having(f)) { 
                og = groupby;
-               while(groupby->l && !is_processed(groupby) && 
!is_base(groupby->op)) {
-                       gl = groupby->l;
-                       if (is_select(gl->op))
+               while(!is_processed(groupby) && !is_base(groupby->op)) {
+                       if (is_select(groupby->op) || !groupby->l)
                                break;
-                       groupby = gl;
+                       if (groupby->l)
+                               groupby = groupby->l;
                }
                if (groupby && is_select(groupby->op) && 
!is_processed(groupby)) {
                        group = 1;
@@ -3834,27 +3830,23 @@ static sql_exp *
                        /* At the end we switch back to the old projection 
relation og. 
                         * During the partitioning and ordering we add the 
expressions to the intermediate relations. */
                }
-               if (!group)
+               if (!sel)
                        groupby = og;
-
                if (sel && sel->l)
                        groupby = sel->l;
        }
 
        /* find groupby */
-       if (groupby && groupby->l && !is_processed(groupby) && 
!is_base(groupby->op)) { 
-               sql_rel *gl = groupby->l;
-
+       if (groupby && !is_processed(groupby) && !is_base(groupby->op)) { 
                og = groupby;
-               while(groupby->l && !is_processed(groupby) && 
!is_base(groupby->op)) {
-                       gl = groupby->l;
-                       if (gl->op == op_groupby)
+               while(!is_processed(groupby) && !is_base(groupby->op)) {
+                       if (groupby->op == op_groupby || !groupby->l)
                                break;
-                       groupby = gl;
-               }
-               if (gl && gl->op == op_groupby) {
+                       if (groupby->l)
+                               groupby = groupby->l;
+               }
+               if (groupby && groupby->op == op_groupby) {
                        group = 1;
-                       groupby = gl;
                        /* At the end we switch back to the old projection 
relation og. 
                         * During the partitioning and ordering we add the 
expressions to the intermediate relations. */
                }
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to