Changeset: 1ac1c7d162fd for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1ac1c7d162fd
Modified Files:
        sql/backends/monet5/rel_bin.c
Branch: pushcands
Log Message:

The 'push' flag needs to comeback. Fixed some places where the 'reduce' and 
'push' flags were not correctly passed on


diffs (truncated from 679 to 300 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
@@ -26,7 +26,7 @@
 
 #define OUTER_ZERO 64
 
-static stmt * exp_bin(backend *be, sql_exp *e, rel_bin_stmt *left, 
rel_bin_stmt *right, int depth, int reduce);
+static stmt * exp_bin(backend *be, sql_exp *e, rel_bin_stmt *left, 
rel_bin_stmt *right, int depth, int reduce, int push);
 static rel_bin_stmt * rel_bin(backend *be, sql_rel *rel);
 static rel_bin_stmt * subrel_bin(backend *be, sql_rel *rel, list *refs);
 
@@ -332,7 +332,7 @@ row2cols(backend *be, rel_bin_stmt *sub)
 }
 
 static stmt *
-distinct_value_list(backend *be, list *vals, stmt **last_null_value)
+distinct_value_list(backend *be, list *vals, stmt **last_null_value, int 
depth, int push)
 {
        list *l = sa_list(be->mvc->sa);
        stmt *s;
@@ -340,7 +340,7 @@ distinct_value_list(backend *be, list *v
        /* create bat append values */
        for (node *n = vals->h; n; n = n->next) {
                sql_exp *e = n->data;
-               stmt *i = exp_bin(be, e, NULL, NULL, 0, 0);
+               stmt *i = exp_bin(be, e, NULL, NULL, depth+1, 0, push);
 
                if (exp_is_null(e))
                        *last_null_value = i;
@@ -388,7 +388,7 @@ subrel_project( backend *be, rel_bin_stm
 }
 
 static stmt *
-handle_in_exps(backend *be, sql_exp *ce, list *nl, rel_bin_stmt *left, 
rel_bin_stmt *right, bool in, int use_r, int depth, int reduce)
+handle_in_exps(backend *be, sql_exp *ce, list *nl, rel_bin_stmt *left, 
rel_bin_stmt *right, bool in, int depth, int reduce, int push)
 {
        mvc *sql = be->mvc;
        stmt *s = NULL, *c, *lcand = NULL;
@@ -397,7 +397,7 @@ handle_in_exps(backend *be, sql_exp *ce,
                lcand = left->cand;
                left->cand = NULL;
        }
-       c = exp_bin(be, ce, left, right, depth+1, 0);
+       c = exp_bin(be, ce, left, right, depth+1, 0, push);
        if (!c) {
                if (left)
                        left->cand = lcand;
@@ -418,7 +418,7 @@ handle_in_exps(backend *be, sql_exp *ce,
                for( node *n = nl->h; n; n = n->next) {
                        sql_exp *e = n->data;
 
-                       stmt *i = exp_bin(be, use_r?e->r:e, left, right, 
depth+1, 0);
+                       stmt *i = exp_bin(be, e, left, right, depth+1, 0, push);
                        if (!i) {
                                if (left)
                                        left->cand = lcand;
@@ -443,7 +443,7 @@ handle_in_exps(backend *be, sql_exp *ce,
                for( node *n = nl->h; n; n = n->next) {
                        sql_exp *e = n->data;
 
-                       stmt *i = exp_bin(be, use_r?e->r:e, left, right, 
depth+1, 0);
+                       stmt *i = exp_bin(be, e, left, right, depth+1, 0, push);
                        if (!i) {
                                if (left)
                                        left->cand = lcand;
@@ -468,7 +468,7 @@ handle_in_exps(backend *be, sql_exp *ce,
                stmt* last_null_value = NULL;  /* CORNER CASE ALERT: See 
description below. */
 
                /* The actual in-value-list should not contain duplicates to 
ensure that final join results are unique. */
-               s = distinct_value_list(be, nl, &last_null_value);
+               s = distinct_value_list(be, nl, &last_null_value, depth+1, 
push);
                if (!s) {
                        if (left)
                                left->cand = lcand;
@@ -522,7 +522,7 @@ value_list(backend *be, list *vals, rel_
        /* create bat append values */
        for (node *n = vals->h; n; n = n->next) {
                sql_exp *e = n->data;
-               stmt *i = exp_bin(be, e, left, NULL, 0, 0);
+               stmt *i = exp_bin(be, e, left, NULL, 0, 0, 0);
 
                if (!i)
                        return NULL;
@@ -544,7 +544,7 @@ exp_list(backend *be, list *exps, rel_bi
 
        for(node *n = exps->h; n; n = n->next) {
                sql_exp *e = n->data;
-               stmt *i = exp_bin(be, e, left, right, 0, 0);
+               stmt *i = exp_bin(be, e, left, right, 0, 0, 0);
                if(!i)
                        return NULL;
 
@@ -574,7 +574,7 @@ exp_count_no_nil_arg( sql_exp *e, stmt *
 }
 
 static stmt *
-exp_bin_or(backend *be, sql_exp *e, rel_bin_stmt *left, rel_bin_stmt *right, 
int depth, bool reduce)
+exp_bin_or(backend *be, sql_exp *e, rel_bin_stmt *left, rel_bin_stmt *right, 
int depth, int reduce, int push)
 {
        sql_subtype *bt = sql_bind_localtype("bit");
        list *l = e->l;
@@ -592,7 +592,7 @@ exp_bin_or(backend *be, sql_exp *e, rel_
                /* propagate the anti flag */
                if (anti)
                        set_anti(c);
-               s = exp_bin(be, c, left, right, depth+1, reduce);
+               s = exp_bin(be, c, left, right, depth+1, reduce, push);
                if (!s) {
                        if (left)
                                left->cand = ocand;
@@ -626,7 +626,7 @@ exp_bin_or(backend *be, sql_exp *e, rel_
                /* propagate the anti flag */
                if (anti)
                        set_anti(c);
-               s = exp_bin(be, c, left, right, depth+1, reduce);
+               s = exp_bin(be, c, left, right, depth+1, reduce, push);
                if (!s) {
                        if (left)
                                left->cand = ocand;
@@ -715,7 +715,7 @@ exp2bin_case(backend *be, sql_exp *fe, r
                }
                if (left)
                        left->cand = nsel;
-               stmt *es = exp_bin(be, e, left, right, depth+1, 0);
+               stmt *es = exp_bin(be, e, left, right, depth+1, 0, 1);
 
                if (!es) {
                        if (left)
@@ -844,7 +844,7 @@ exp2bin_casewhen(backend *be, sql_exp *f
 
        if (left)
                left->cand = !single_value?isel:NULL;
-       stmt *case_when = exp_bin(be, e, left, right, depth+1, 0);
+       stmt *case_when = exp_bin(be, e, left, right, depth+1, 0, 1);
        if (!case_when) {
                if (left)
                        left->cand = isel;
@@ -888,7 +888,7 @@ exp2bin_casewhen(backend *be, sql_exp *f
                }
                if (left)
                        left->cand = nsel;
-               stmt *es = exp_bin(be, e, left, right, depth+1, 0);
+               stmt *es = exp_bin(be, e, left, right, depth+1, 0, 1);
 
                if (!es) {
                        if (left)
@@ -1046,7 +1046,7 @@ exp2bin_coalesce(backend *be, sql_exp *f
                }
                if (left)
                        left->cand = nsel;
-               stmt *es = exp_bin(be, e, left, right, depth+1, 0);
+               stmt *es = exp_bin(be, e, left, right, depth+1, 0, 1);
 
                if (!es) {
                        if (left)
@@ -1140,7 +1140,7 @@ exp2bin_coalesce(backend *be, sql_exp *f
 }
 
 stmt *
-exp_bin(backend *be, sql_exp *e, rel_bin_stmt *left, rel_bin_stmt *right, int 
depth, int reduce)
+exp_bin(backend *be, sql_exp *e, rel_bin_stmt *left, rel_bin_stmt *right, int 
depth, int reduce, int push)
 {
        mvc *sql = be->mvc;
        stmt *s = NULL;
@@ -1156,7 +1156,7 @@ exp_bin(backend *be, sql_exp *e, rel_bin
        switch(e->type) {
        case e_psm:
                if (e->flag & PSM_SET) {
-                       stmt *r = exp_bin(be, e->l, left, right, 0, 0);
+                       stmt *r = exp_bin(be, e->l, left, right, depth+1, 0, 
push);
                        if(!r)
                                return NULL;
                        if (e->card <= CARD_ATOM && r->nrcols > 0) /* single 
value, get result from bat */
@@ -1169,7 +1169,7 @@ exp_bin(backend *be, sql_exp *e, rel_bin
                                s = stmt_var(be, exp_relname(e), exp_name(e), 
&e->tpe, 1, GET_PSM_LEVEL(e->flag));
                } else if (e->flag & PSM_RETURN) {
                        sql_exp *l = e->l;
-                       stmt *r = exp_bin(be, l, left, right, 0, 0);
+                       stmt *r = exp_bin(be, l, left, right, depth+1, 0, push);
 
                        if (!r)
                                return NULL;
@@ -1197,7 +1197,7 @@ exp_bin(backend *be, sql_exp *e, rel_bin
                        /* while is a if - block true with leave statement
                         * needed because the condition needs to be inside this 
outer block */
                        stmt *ifstmt = stmt_cond(be, stmt_bool(be, 1), NULL, 0, 
0);
-                       stmt *cond = exp_bin(be, e->l, left, right, 0, 0);
+                       stmt *cond = exp_bin(be, e->l, left, right, depth+1, 0, 
push);
                        stmt *wstmt;
 
                        if(!cond)
@@ -1209,7 +1209,7 @@ exp_bin(backend *be, sql_exp *e, rel_bin
                        (void)stmt_control_end(be, wstmt);
                        s = stmt_control_end(be, ifstmt);
                } else if (e->flag & PSM_IF) {
-                       stmt *cond = exp_bin(be, e->l, left, right, 0, 0);
+                       stmt *cond = exp_bin(be, e->l, left, right, depth+1, 0, 
push);
                        stmt *ifstmt, *res;
 
                        if(!cond)
@@ -1234,7 +1234,7 @@ exp_bin(backend *be, sql_exp *e, rel_bin
                                return NULL;
                        s = stmt_table(be, r, 1);
                } else if (e->flag & PSM_EXCEPTION) {
-                       stmt *cond = exp_bin(be, e->l, left, right, 0, 0);
+                       stmt *cond = exp_bin(be, e->l, left, right, depth+1, 0, 
push);
                        if (!cond)
                                return NULL;
                        s = stmt_exception(be, cond, (const char *) e->r, 0);
@@ -1264,7 +1264,7 @@ exp_bin(backend *be, sql_exp *e, rel_bin
                if (from->type->localtype == 0) {
                        l = stmt_atom(be, atom_general(sql->sa, to, NULL));
                } else {
-                       l = exp_bin(be, e->l, left, right, depth+1, 0);
+                       l = exp_bin(be, e->l, left, right, depth+1, 0, push);
                }
                if (!l)
                        return NULL;
@@ -1306,7 +1306,7 @@ exp_bin(backend *be, sql_exp *e, rel_bin
                        assert(list_length(exps) == list_length(f->func->ops) 
|| f->func->type == F_ANALYTIC || f->func->type == F_LOADER || f->func->vararg 
|| f->func->varres);
                        for (en = exps->h; en; en = en->next) {
                                sql_exp *e = en->data;
-                               stmt *es = exp_bin(be, e, left, right, depth+1, 
0);
+                               stmt *es = exp_bin(be, e, left, right, depth+1, 
0, push);
 
                                if (!es)
                                        return NULL;
@@ -1343,9 +1343,9 @@ exp_bin(backend *be, sql_exp *e, rel_bin
                        for (en = attr->h; en; en = en->next) {
                                sql_exp *at = en->data;
 
-                               as = exp_bin(be, at, left, /*right*/NULL, 
depth+1, 0);
+                               as = exp_bin(be, at, left, /*right*/NULL, 
depth+1, 0, push);
                                if (!as)
-                                       as = exp_bin(be, at, left, right, 
depth+1, 0);
+                                       as = exp_bin(be, at, left, right, 
depth+1, 0, push);
 
                                if (as && as->nrcols <= 0 && left)
                                        as = stmt_const(be, 
bin_find_smallest_column(be, left), NULL, as);
@@ -1450,10 +1450,10 @@ exp_bin(backend *be, sql_exp *e, rel_bin
                                oldvid = be->mb->vid;
                                s = NULL;
                                if (!swapped)
-                                       s = exp_bin(be, n->data, left, NULL, 
depth+1, 0);
+                                       s = exp_bin(be, n->data, left, NULL, 
depth+1, 0, push);
                                if (!s && (first || swapped)) {
                                        clean_mal_statements(be, oldstop, 
oldvtop, oldvid);
-                                       s = exp_bin(be, n->data, right, NULL, 
depth+1, 0);
+                                       s = exp_bin(be, n->data, right, NULL, 
depth+1, 0, push);
                                        swapped = 1;
                                }
                                if (!s)
@@ -1469,7 +1469,7 @@ exp_bin(backend *be, sql_exp *e, rel_bin
                        ops = sa_list(sql->sa);
                        args = e->r;
                        for( n = args->h; n; n = n->next ) {
-                               s = exp_bin(be, n->data, (swapped || 
!right)?left:right, NULL, depth+1, 0);
+                               s = exp_bin(be, n->data, (swapped || 
!right)?left:right, NULL, depth+1, 0, push);
                                if (!s)
                                        return s;
                                list_append(ops, s);
@@ -1489,9 +1489,9 @@ exp_bin(backend *be, sql_exp *e, rel_bin
                        return s;
                }
                if (e->flag == cmp_in || e->flag == cmp_notin)
-                       return handle_in_exps(be, e->l, e->r, left, right, 
(e->flag == cmp_in), 0, depth, reduce);
+                       return handle_in_exps(be, e->l, e->r, left, right, 
(e->flag == cmp_in), depth, reduce, push);
                if (e->flag == cmp_or && (!right || right->nrcols == 1))
-                       return exp_bin_or(be, e, left, right, depth, reduce);
+                       return exp_bin_or(be, e, left, right, depth, reduce, 
push);
                if (e->flag == cmp_or && right) /* join */
                        assert(0);
 
@@ -1503,12 +1503,12 @@ exp_bin(backend *be, sql_exp *e, rel_bin
                oldstop = be->mb->stop;
                oldvid = be->mb->vid;
                if (!l) {
-                       l = exp_bin(be, e->l, left, (!reduce)?right:NULL, 
depth+1, 0);
+                       l = exp_bin(be, e->l, left, (!reduce)?right:NULL, 
depth+1, 0, push);
                        swapped = 0;
                }
                if (!l && right) {
                        clean_mal_statements(be, oldstop, oldvtop, oldvid);
-                       l = exp_bin(be, e->l, right, NULL, depth+1, 0);
+                       l = exp_bin(be, e->l, right, NULL, depth+1, 0, push);
                        swapped = 1;
                }
 
@@ -1516,21 +1516,21 @@ exp_bin(backend *be, sql_exp *e, rel_bin
                oldstop = be->mb->stop;
                oldvid = be->mb->vid;
                if (swapped || !right || !reduce)
-                       r = exp_bin(be, re, left, (!reduce)?right:NULL, 
depth+1, 0);
+                       r = exp_bin(be, re, left, (!reduce)?right:NULL, 
depth+1, 0, push);
                else
-                       r = exp_bin(be, re, right, NULL, depth+1, 0);
+                       r = exp_bin(be, re, right, NULL, depth+1, 0, push);
                if (!r && !swapped) {
                        clean_mal_statements(be, oldstop, oldvtop, oldvid);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to