Changeset: 1ecf668eb157 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1ecf668eb157
Modified Files:
sql/backends/monet5/rel_bin.c
sql/include/sql_relation.h
sql/server/rel_optimizer.c
sql/server/rel_optimizer_private.h
sql/server/rel_statistics.c
sql/server/rel_updates.c
Branch: default
Log Message:
cleanup updates some more
diffs (156 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
@@ -5543,9 +5543,9 @@ rel2bin_insert(backend *be, sql_rel *rel
mvc *sql = be->mvc;
list *l;
stmt *inserts = NULL, *insert = NULL, *ddl = NULL, *pin = NULL,
**updates, *ret = NULL, *cnt = NULL, *pos = NULL, *returning = NULL;
- int idx_ins = 0, len = 0;
+ int len = 0;
node *n, *m, *idx_m = NULL;
- sql_rel *tr = rel->l, *prel = rel->r;
+ sql_rel *tr = rel->l;
sql_table *t = NULL;
if (tr->op == op_basetable) {
@@ -5565,9 +5565,6 @@ rel2bin_insert(backend *be, sql_rel *rel
if (!inserts)
return NULL;
- if (idx_ins)
- pin = refs_find_rel(refs, prel);
-
for (n = ol_first_node(t->keys); n; n = n->next) {
sql_key * key = n->data;
if (key->type == ckey)
@@ -6615,17 +6612,11 @@ rel2bin_update(backend *be, sql_rel *rel
mvc *sql = be->mvc;
stmt *update = NULL, **updates = NULL, *tids, *ddl = NULL, *pup = NULL;
list *l = sa_list(sql->sa), *attr = rel->attr;
- int nr_cols, updcol, idx_ups = 0;
+ int nr_cols, updcol;
node *m;
- sql_rel *tr = rel->l, *prel = rel->r;
+ sql_rel *tr = rel->l;
sql_table *t = NULL;
- if ((rel->flag&UPD_COMP)) { /* special case ! */
- idx_ups = 1;
- prel = rel->l;
- rel = rel->r;
- tr = rel->l;
- }
if (tr->op == op_basetable) {
t = tr->l;
} else {
@@ -6654,14 +6645,7 @@ rel2bin_update(backend *be, sql_rel *rel
if (!update)
return NULL;
- if (idx_ups) {
- pup = refs_find_rel(refs, prel);
- if (!pup) {
- pup = subrel_bin(be, prel, refs);
- pup = subrel_project(be, pup, refs, prel);
- }
- }
-
+ pup = update;
updates = table_update_stmts(sql, t, &nr_cols);
tids = update->op4.lval->h->data;
diff --git a/sql/include/sql_relation.h b/sql/include/sql_relation.h
--- a/sql/include/sql_relation.h
+++ b/sql/include/sql_relation.h
@@ -83,8 +83,6 @@ typedef struct expression {
#define IS_TABLE_PROD_FUNC(X) ((X & TABLE_PROD_FUNC) == TABLE_PROD_FUNC)
/* or-ed with the above TABLE_PROD_FUNC */
-#define UPD_COMP 2
-
#define REL_PARTITION 8
#define OUTER_ZERO 32
diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -638,14 +638,13 @@ run_optimizer_set(visitor *v, sql_optimi
static sql_rel *
rel_optimizer_one(mvc *sql, sql_rel *rel, int profile, int instantiate, int
value_based_opt, int storage_based_opt)
{
- global_props gp = (global_props) {.cnt = {0}, .instantiate =
(uint8_t)instantiate, .opt_cycle = 0,
-
.has_special_modify = rel && is_modify(rel->op) && rel->flag&UPD_COMP};
+ global_props gp = (global_props) {.cnt = {0}, .instantiate =
(uint8_t)instantiate, .opt_cycle = 0 };
visitor v = { .sql = sql, .value_based_opt = value_based_opt,
.storage_based_opt = storage_based_opt, .changes = 1, .data = &gp };
sql->runs = !(ATOMIC_GET(&GDKdebug) & TESTINGMASK) && profile ?
sa_zalloc(sql->sa, NSQLREWRITERS * sizeof(sql_optimizer_run)) : NULL;
for ( ;rel && gp.opt_cycle < 20 && v.changes; gp.opt_cycle++) {
v.changes = 0;
- gp = (global_props) {.cnt = {0}, .instantiate =
(uint8_t)instantiate, .opt_cycle = gp.opt_cycle, .has_special_modify =
gp.has_special_modify};
+ gp = (global_props) {.cnt = {0}, .instantiate =
(uint8_t)instantiate, .opt_cycle = gp.opt_cycle};
rel = rel_visitor_topdown(&v, rel, &rel_properties); /* collect
relational tree properties */
gp.opt_level = calculate_opt_level(sql, rel);
if (gp.opt_level == 0 && !gp.needs_mergetable_rewrite)
diff --git a/sql/server/rel_optimizer_private.h
b/sql/server/rel_optimizer_private.h
--- a/sql/server/rel_optimizer_private.h
+++ b/sql/server/rel_optimizer_private.h
@@ -23,7 +23,6 @@ typedef struct global_props {
needs_mergetable_rewrite:1,
needs_remote_replica_rewrite:1,
needs_distinct:1,
- has_special_modify:1, /* Don't prune updates as pruning will
possibly result in removing the joins which therefore cannot be used for
constraint checking */
opt_level:1, /* 0 run necessary rewriters, 1 run all optimizers
*/
recursive:1;
uint8_t opt_cycle; /* the optimization cycle number */
diff --git a/sql/server/rel_statistics.c b/sql/server/rel_statistics.c
--- a/sql/server/rel_statistics.c
+++ b/sql/server/rel_statistics.c
@@ -748,8 +748,7 @@ static sql_rel *
rel_get_statistics_(visitor *v, sql_rel *rel)
{
/* Don't prune updates as pruning will possibly result in removing the
joins which therefore cannot be used for constraint checking */
- uint8_t has_special_modify = *(uint8_t*) v->data;
- bool can_be_pruned = !has_special_modify && v->storage_based_opt;
+ bool can_be_pruned = v->storage_based_opt;
/* Don't look at the same relation twice */
if (are_statistics_gathered(rel->used))
@@ -1166,8 +1165,6 @@ static sql_rel *
rel_get_statistics(visitor *v, global_props *gp, sql_rel *rel)
{
/* Don't prune updates as pruning will possibly result in removing the
joins which therefore cannot be used for constraint checking */
- uint8_t has_special_modify = (uint8_t) gp->has_special_modify;
- v->data = &has_special_modify;
rel = rel_visitor_bottomup(v, rel, &rel_get_statistics_);
v->data = gp;
return rel;
diff --git a/sql/server/rel_updates.c b/sql/server/rel_updates.c
--- a/sql/server/rel_updates.c
+++ b/sql/server/rel_updates.c
@@ -878,8 +878,6 @@ rel_update_join_idx(mvc *sql, const char
static sql_rel *
rel_update_idxs(mvc *sql, const char *alias, sql_table *t, sql_rel *relup)
{
- sql_rel *p = relup->r;
-
if (!ol_length(t->idxs))
return relup;
@@ -903,17 +901,6 @@ rel_update_idxs(mvc *sql, const char *al
rel_update_join_idx(sql, alias, i, relup);
}
}
- if (relup->r != p) {
- sql_rel *r = rel_create(sql->sa);
- if(!r)
- return NULL;
- r->op = op_update;
- r->l = rel_dup(p);
- r->r = relup;
- r->card = relup->card;
- r->flag |= UPD_COMP; /* mark as special update */
- return r;
- }
return relup;
}
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]