Changeset: 6c0dd610ba59 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/6c0dd610ba59
Modified Files:
sql/backends/monet5/rel_bin.c
sql/server/rel_propagate.c
Branch: pushcands
Log Message:
Cleaning my old mess, generate the row count accumulator only when required and
don't generate empty ddl exception statements
diffs (120 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
@@ -5742,19 +5742,18 @@ rel2bin_list(backend *be, sql_rel *rel,
rel_bin_stmt *l = NULL, *r = NULL;
list *slist = sa_list(sql->sa);
- if (find_prop(rel->p, PROP_DISTRIBUTE) && be->cur_append == 0) /*
create affected rows accumulator */
- create_merge_partitions_accumulator(be);
-
if (rel->l) /* first construct the sub relation */
l = subrel_bin(be, rel->l, refs);
if (rel->r) /* first construct the sub relation */
r = subrel_bin(be, rel->r, refs);
l = subrel_project(be, l, refs, rel->l);
r = subrel_project(be, r, refs, rel->r);
- if (!l || !r)
+ if ((rel->l && !l) || (rel->r && !r))
return NULL;
- list_append(slist, l);
- list_append(slist, r);
+ if (l)
+ list_append(slist, l);
+ if (r)
+ list_append(slist, r);
return create_rel_bin_stmt(sql->sa, slist, NULL, NULL, NULL, NULL);
}
@@ -5815,10 +5814,7 @@ rel2bin_exception(backend *be, sql_rel *
{
mvc *sql = be->mvc;
rel_bin_stmt *l = NULL, *r = NULL;
- list *slist = sa_list(be->mvc->sa);
-
- if (find_prop(rel->p, PROP_DISTRIBUTE) && be->cur_append == 0) /*
create affected rows accumulator */
- create_merge_partitions_accumulator(be);
+ list *slist = sa_list(sql->sa);
if (rel->l) /* first construct the sub relation */
l = subrel_bin(be, rel->l, refs);
@@ -5829,17 +5825,13 @@ rel2bin_exception(backend *be, sql_rel *
if ((rel->l && !l) || (rel->r && !r))
return NULL;
- if (rel->exps) {
- for (node *n = rel->exps->h; n; n = n->next) {
- sql_exp *e = n->data;
- stmt *s = exp_bin(be, e, l, r, 0, 0, 0);
- if (!s)
- return NULL;
- append(slist, s);
- }
- } else { /* if there is no exception condition, just generate a
statement list */
- list_append(slist, l);
- list_append(slist, r);
+ assert(rel->exps);
+ for (node *n = rel->exps->h; n; n = n->next) {
+ sql_exp *e = n->data;
+ stmt *s = exp_bin(be, e, l, r, 0, 0, 0);
+ if (!s)
+ return NULL;
+ list_append(slist, s);
}
return create_rel_bin_stmt(sql->sa, slist, NULL, NULL, NULL, NULL);
}
@@ -6224,6 +6216,10 @@ output_rel_bin(backend *be, sql_rel *rel
be->join_idx = 0;
if (refs == NULL)
return NULL;
+
+ if (top && find_prop(rel->p, PROP_DISTRIBUTE) && be->cur_append == 0)
/* create affected rows accumulator */
+ create_merge_partitions_accumulator(be);
+
s = subrel_bin(be, rel, refs);
s = subrel_project(be, s, refs, rel);
if (!s)
@@ -6233,8 +6229,8 @@ output_rel_bin(backend *be, sql_rel *rel
if (!is_ddl(rel->op) && sql->type == Q_TABLE && stmt_output(be, s) < 0)
{
return NULL;
- } else if (top && (!is_ddl(rel->op) || rel->flag == ddl_list) &&
(sqltype == Q_UPDATE || be->cur_append)) {
- /* only call stmt_affected_rows outside functions and ddl,
however if the ddl is a list, it might be called. eg. merge statements */
+ } else if (top && (!is_ddl(rel->op) || find_prop(rel->p,
PROP_DISTRIBUTE)) && sqltype == Q_UPDATE) {
+ /* only call stmt_affected_rows outside functions and ddl,
however if PROP_DISTRIBUTE is found it might be called. eg. merge statements */
if (be->cur_append) { /* finish the output bat */
stmt *last = s->cols->t->data;
last->nr = be->cur_append;
diff --git a/sql/server/rel_propagate.c b/sql/server/rel_propagate.c
--- a/sql/server/rel_propagate.c
+++ b/sql/server/rel_propagate.c
@@ -883,10 +883,8 @@ static sql_rel*
rel_propagate_delete(mvc *sql, sql_rel *rel, sql_table *t, int *changes)
{
rel = rel_generate_subdeletes(sql, rel, t, changes);
- if (rel) {
- rel = rel_exception(sql->sa, rel, NULL, NULL);
+ if (rel)
rel->p = prop_create(sql->sa, PROP_DISTRIBUTE, rel->p);
- }
return rel;
}
@@ -924,16 +922,13 @@ rel_propagate_update(mvc *sql, sql_rel *
if (!found_partition_col) { /* easy scenario where the partitioned
column is not being updated, just propagate */
sel = rel_generate_subupdates(sql, rel, t, changes);
- if (sel) {
- sel = rel_exception(sql->sa, sel, NULL, NULL);
+ if (sel)
sel->p = prop_create(sql->sa, PROP_DISTRIBUTE, sel->p);
- }
} else { /* harder scenario, has to insert and delete across
partitions. */
/*sql_exp *exception = NULL;
sql_rel *inserts = NULL, *deletes = NULL, *anti_rel = NULL;
deletes = rel_generate_subdeletes(sql, rel, t, changes);
- deletes = rel_exception(sql->sa, deletes, NULL, NULL);
inserts = rel_generate_subinserts(query, rel, &anti_rel,
&exception, t, changes, "UPDATE", "update");
inserts = rel_exception(sql->sa, inserts, anti_rel,
list_append(new_exp_list(sql->sa), exception));
return rel_list(sql->sa, deletes, inserts);*/
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list