Changeset: fb6948a8c9ec for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/fb6948a8c9ec
Modified Files:
        sql/include/sql_relation.h
        sql/server/rel_distribute.c
        sql/server/rel_optimize_proj.c
        sql/server/rel_unnest.c
        sql/server/rel_updates.c
        sql/test/astro/Tests/astro.test
Branch: default
Log Message:

more cleanup MERGE_LEFT no longer needed (merge is rewritten into normal 
update, delete and inserts)


diffs (113 lines):

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
@@ -86,7 +86,6 @@ typedef struct expression {
 #define UPD_COMP               2
 
 #define REL_PARTITION          8
-#define MERGE_LEFT             16 /* used by merge statements */
 #define OUTER_ZERO             32
 
 /* We need bit wise exclusive numbers as we merge the level also in the flag */
diff --git a/sql/server/rel_distribute.c b/sql/server/rel_distribute.c
--- a/sql/server/rel_distribute.c
+++ b/sql/server/rel_distribute.c
@@ -228,7 +228,7 @@ replica_rewrite(visitor *v, sql_table *t
 static bool
 eliminate_remote_or_replica_refs(visitor *v, sql_rel **rel)
 {
-       if (rel_is_ref(*rel) && !((*rel)->flag&MERGE_LEFT)) {
+       if (rel_is_ref(*rel)) {
                if (has_remote_or_replica(*rel)) {
                        sql_rel *nrel = rel_copy(v->sql, *rel, 1);
                        rel_destroy(*rel);
@@ -411,9 +411,6 @@ rel_rewrite_remote_(visitor *v, sql_rel 
        case op_update:
        case op_delete:
 
-               if (rel->flag&MERGE_LEFT) /* search for any remote tables but 
don't propagate over to this relation */
-                       return rel;
-
                /* if both subtrees have REMOTE property with the common uri 
then pull it up */
                if (l && (pl = find_prop(l->p, PROP_REMOTE)) != NULL &&
                        r && (pr = find_prop(r->p, PROP_REMOTE)) != NULL) {
diff --git a/sql/server/rel_optimize_proj.c b/sql/server/rel_optimize_proj.c
--- a/sql/server/rel_optimize_proj.c
+++ b/sql/server/rel_optimize_proj.c
@@ -515,7 +515,6 @@ rel_push_project_up_(visitor *v, sql_rel
                if (!l || rel_is_ref(l) || is_topn(l->op) || is_sample(l->op) ||
                   (is_join(rel->op) && !list_empty(rel->attr)) ||
                   (is_join(rel->op) && (!r || rel_is_ref(r))) ||
-                  (is_left(rel->op) && (rel->flag&MERGE_LEFT) /* can't push 
projections above merge statements left joins */) ||
                   (is_select(rel->op) && l->op != op_project) ||
                   (is_join(rel->op) && ((l->op != op_project && r->op != 
op_project) || is_topn(r->op) || is_sample(r->op))) ||
                  ((l->op == op_project && (!l->l || l->r || project_unsafe(l, 
is_select(rel->op)))) ||
diff --git a/sql/server/rel_unnest.c b/sql/server/rel_unnest.c
--- a/sql/server/rel_unnest.c
+++ b/sql/server/rel_unnest.c
@@ -4247,7 +4247,7 @@ add_null_projects(visitor *v, sql_rel *p
 static sql_rel *
 rewrite_outer2inner_union(visitor *v, sql_rel *rel)
 {
-       if (is_outerjoin(rel->op) && rel->flag != MERGE_LEFT) {
+       if (is_outerjoin(rel->op)) {
                int nrcols = rel->nrcols;
 
                nrcols = include_tid(rel->l);
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
@@ -202,7 +202,8 @@ rel_insert_join_idx(mvc *sql, const char
        }
 
        pexps = rel_projections(sql, ins, NULL, 1, 1);
-       ins = rel_crossproduct(sql->sa, ins, rt, op_left/*op_join*/);
+       ins = rel_crossproduct(sql->sa, ins, rt, op_left);
+       set_single(ins);
        ins->exps = join_exps;
        ins = rel_project(sql->sa, ins, pexps);
        /* add row numbers */
@@ -850,7 +851,8 @@ rel_update_join_idx(mvc *sql, const char
        }
 
        pexps = rel_projections(sql, ups, NULL, 1, 1);
-       ups = rel_crossproduct(sql->sa, ups, rt, op_left/*op_join*/);
+       ups = rel_crossproduct(sql->sa, ups, rt, op_left);
+       set_single(ups);
        ups->exps = join_exps;
        ups = rel_project(sql->sa, ups, pexps);
        /* add row numbers */
@@ -1046,7 +1048,6 @@ update_generate_assignments(sql_query *q
                                        reset_processed(rel_val);
                                }
                                r = rel_crossproduct(sql->sa, r, rel_val, 
op_left);
-                               r->flag |= MERGE_LEFT;
                                set_dependent(r);
                                set_processed(r);
                                if (single) {
@@ -1554,7 +1555,6 @@ merge_into_table(sql_query *query, dlist
 
        if (!join_rel)
                return sql_error(sql, 02, SQLSTATE(42000) "MERGE: an insert or 
update or delete clause is required");
-       join_rel->flag |= MERGE_LEFT;
        if (processed == (MERGE_UPDATE_DELETE | MERGE_INSERT)) {
                res = rel_merge(sql, rel_dup(join_rel), upd_del, insert);
        } else if ((processed & MERGE_UPDATE_DELETE) == MERGE_UPDATE_DELETE) {
diff --git a/sql/test/astro/Tests/astro.test b/sql/test/astro/Tests/astro.test
--- a/sql/test/astro/Tests/astro.test
+++ b/sql/test/astro/Tests/astro.test
@@ -79,11 +79,9 @@ group by (
 | | | | | | ) [ ("cm_flux"."active" NOT NULL UNIQUE) = (boolean(1) "true"), 
(varchar(1)["cm_flux"."filter" NOT NULL UNIQUE] NOT NULL) = (varchar(1) "g") ]
 | | | | | ) [ "cm_flux"."runcat" NOT NULL UNIQUE, "cm_flux"."filter" NOT NULL 
UNIQUE ]
 | | | | ) [ ("cm_flux"."runcat" NOT NULL UNIQUE) = ("fluxz"."runcat" NOT NULL 
UNIQUE), ("cm_flux"."filter" NOT NULL UNIQUE) = ("fluxz"."filter" NOT NULL 
UNIQUE) ],
-| | | | single project (
-| | | | | select (
-| | | | | | table("sys"."cm_flux") [ "cm_flux"."runcat" NOT NULL UNIQUE, 
"cm_flux"."filter" NOT NULL UNIQUE, "cm_flux"."f_datapoints" NOT NULL UNIQUE, 
"cm_flux"."active" NOT NULL UNIQUE, "cm_flux"."avg_flux" NOT NULL UNIQUE, 
"cm_flux"."avg_fluxsq" NOT NULL UNIQUE, "cm_flux"."avg_w" NOT NULL UNIQUE, 
"cm_flux"."avg_wflux" NOT NULL UNIQUE, "cm_flux"."avg_wfluxsq" NOT NULL UNIQUE, 
"cm_flux"."avg_dec_zone_deg" NOT NULL UNIQUE ]
-| | | | | ) [ ("cm_flux"."active" NOT NULL UNIQUE) = (boolean(1) "true"), 
(varchar(1)["cm_flux"."filter" NOT NULL UNIQUE] NOT NULL) = (varchar(1) "g") ]
-| | | | ) [ "cm_flux"."filter" NOT NULL UNIQUE, "cm_flux"."f_datapoints" NOT 
NULL UNIQUE, "cm_flux"."avg_flux" NOT NULL UNIQUE, "cm_flux"."avg_fluxsq" NOT 
NULL UNIQUE, "cm_flux"."avg_w" NOT NULL UNIQUE, "cm_flux"."avg_wflux" NOT NULL 
UNIQUE, "cm_flux"."avg_wfluxsq" NOT NULL UNIQUE, "cm_flux"."avg_dec_zone_deg" 
NOT NULL UNIQUE, "cm_flux"."runcat" NOT NULL UNIQUE ]
+| | | | select (
+| | | | | table("sys"."cm_flux") [ "cm_flux"."runcat" NOT NULL UNIQUE, 
"cm_flux"."filter" NOT NULL UNIQUE, "cm_flux"."f_datapoints" NOT NULL UNIQUE, 
"cm_flux"."active" NOT NULL UNIQUE, "cm_flux"."avg_flux" NOT NULL UNIQUE, 
"cm_flux"."avg_fluxsq" NOT NULL UNIQUE, "cm_flux"."avg_w" NOT NULL UNIQUE, 
"cm_flux"."avg_wflux" NOT NULL UNIQUE, "cm_flux"."avg_wfluxsq" NOT NULL UNIQUE, 
"cm_flux"."avg_dec_zone_deg" NOT NULL UNIQUE ]
+| | | | ) [ ("cm_flux"."active" NOT NULL UNIQUE) = (boolean(1) "true"), 
(varchar(1)["cm_flux"."filter" NOT NULL UNIQUE] NOT NULL) = (varchar(1) "g") ]
 | | | ) [ ("fluxz"."runcat" NOT NULL UNIQUE) = ("cm_flux"."runcat" NOT NULL 
UNIQUE), ("fluxz"."filter" NOT NULL UNIQUE) = ("cm_flux"."filter" NOT NULL 
UNIQUE) ]
 | | ) [ "fluxz"."%TID%" NOT NULL, "cm_flux"."filter" UNIQUE as 
"fluxz"."filter", "cm_flux"."f_datapoints" as "fluxz"."f_datapoints", 
"cm_flux"."avg_flux" as "fluxz"."avg_flux", "cm_flux"."avg_fluxsq" as 
"fluxz"."avg_fluxsq", "cm_flux"."avg_w" as "fluxz"."avg_w", 
"cm_flux"."avg_wflux" as "fluxz"."avg_wflux", "cm_flux"."avg_wfluxsq" as 
"fluxz"."avg_wfluxsq", "cm_flux"."avg_dec_zone_deg" as 
"fluxz"."avg_dec_zone_deg" ]
 | ) [ "fluxz"."%TID%" NOT NULL UNIQUE, "fluxz"."filter" NOT NULL, 
"fluxz"."f_datapoints" NOT NULL, "fluxz"."avg_flux" NOT NULL, 
"fluxz"."avg_fluxsq" NOT NULL, "fluxz"."avg_w" NOT NULL, "fluxz"."avg_wflux" 
NOT NULL, "fluxz"."avg_wfluxsq" NOT NULL, "fluxz"."avg_dec_zone_deg" NOT NULL ]
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to