Changeset: 0d4861649c31 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0d4861649c31
Modified Files:
        sql/server/rel_optimizer.c
        tools/merovingian/client/monetdb.c
Branch: default
Log Message:

Merged with oscar


diffs (118 lines):

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
@@ -4658,43 +4658,6 @@ rel_push_select_down_join(visitor *v, sq
        return rel;
 }
 
-static bool
-find_simple_projection_for_join2semi(sql_rel *rel)
-{
-       if (is_project(rel->op) && list_length(rel->exps) == 1) {
-               sql_exp *e = rel->exps->h->data;
-
-               if (rel->card < CARD_AGGR) /* const or groupby without group by 
exps */
-                       return true;
-               /* a single group by column in the projection list from a group 
by relation is guaranteed to be unique, but not an aggregate */
-               if (e->type == e_column) {
-                       sql_rel *res = NULL;
-                       sql_exp *found = NULL;
-                       bool underjoin = false;
-
-                       if (is_groupby(rel->op) || need_distinct(rel) || 
find_prop(e->p, PROP_HASHCOL))
-                               return true;
-
-                       found = rel_find_exp_and_corresponding_rel(rel->l, e, 
&res, &underjoin); /* grouping column on inner relation */
-                       if (found && !underjoin) {
-                               if (find_prop(found->p, PROP_HASHCOL)) /* 
primary key always unique */
-                                       return true;
-                               if (found->type == e_column && found->card <= 
CARD_AGGR) {
-                                       if (!(is_groupby(res->op) || 
need_distinct(res)) && list_length(res->exps) != 1)
-                                               return false;
-                                       for (node *n = res->exps->h ; n ; n = 
n->next) { /* must be the single column in the group by expression list */
-                                               sql_exp *e = n->data;
-                                               if (e != found && e->type == 
e_column)
-                                                       return false;
-                                       }
-                                       return true;
-                               }
-                       }
-               }
-       }
-       return false;
-}
-
 /*
  * Push {semi}joins down, pushes the joins through group by expressions.
  * When the join is on the group by columns, we can push the joins left
@@ -4713,13 +4676,13 @@ rel_push_join_down(visitor *v, sql_rel *
 {
        list *exps = NULL;
 
-       if (!rel_is_ref(rel) && ((is_join(rel->op) || is_semi(rel->op)) && 
rel->l && rel->exps)) {
+       if (!rel_is_ref(rel) && ((is_left(rel->op) || rel->op == op_join || 
is_semi(rel->op)) && rel->l && rel->exps)) {
                sql_rel *gb = rel->r, *ogb = gb, *l = NULL, *rell = rel->l;
 
                if (gb->op == op_project)
                        gb = gb->l;
 
-               if (rel_is_ref(rell) || 
!find_simple_projection_for_join2semi(rell))
+               if (rel_is_ref(rell))
                        return rel;
 
                exps = rel->exps;
@@ -5304,6 +5267,43 @@ rel_remove_empty_join(visitor *v, sql_re
        return rel;
 }
 
+static bool
+find_simple_projection_for_join2semi(sql_rel *rel)
+{
+       if (is_project(rel->op) && list_length(rel->exps) == 1) {
+               sql_exp *e = rel->exps->h->data;
+
+               if (rel->card < CARD_AGGR) /* const or groupby without group by 
exps */
+                       return true;
+               /* a single group by column in the projection list from a group 
by relation is guaranteed to be unique, but not an aggregate */
+               if (e->type == e_column) {
+                       sql_rel *res = NULL;
+                       sql_exp *found = NULL;
+                       bool underjoin = false;
+
+                       if (is_groupby(rel->op) || need_distinct(rel) || 
find_prop(e->p, PROP_HASHCOL))
+                               return true;
+
+                       found = rel_find_exp_and_corresponding_rel(rel->l, e, 
&res, &underjoin); /* grouping column on inner relation */
+                       if (found && !underjoin) {
+                               if (find_prop(found->p, PROP_HASHCOL)) /* 
primary key always unique */
+                                       return true;
+                               if (found->type == e_column && found->card <= 
CARD_AGGR) {
+                                       if (!(is_groupby(res->op) || 
need_distinct(res)) && list_length(res->exps) != 1)
+                                               return false;
+                                       for (node *n = res->exps->h ; n ; n = 
n->next) { /* must be the single column in the group by expression list */
+                                               sql_exp *e = n->data;
+                                               if (e != found && e->type == 
e_column)
+                                                       return false;
+                                       }
+                                       return true;
+                               }
+                       }
+               }
+       }
+       return false;
+}
+
 static sql_rel *
 find_candidate_join2semi(sql_rel *rel, bool *swap)
 {
diff --git a/tools/merovingian/client/monetdb.c 
b/tools/merovingian/client/monetdb.c
--- a/tools/merovingian/client/monetdb.c
+++ b/tools/merovingian/client/monetdb.c
@@ -1510,6 +1510,7 @@ command_get(int argc, char *argv[])
                free(value);
        msab_freeStatus(&orig);
        free(props);
+       freeConfFile(defprops);
        free(defprops);
        return fails > 0;
 }
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to