Changeset: 47c5d40bdbac for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=47c5d40bdbac
Modified Files:
        sql/benchmarks/tpcds/Tests/95.stable.out
        sql/benchmarks/tpcds/Tests/95.stable.out.int128
        sql/server/rel_dump.c
        sql/server/rel_exp.c
        sql/server/rel_exp.h
        sql/server/rel_optimizer.c
        sql/server/rel_unnest.c
        sql/test/Tests/window_functions.stable.out
Branch: sq2default
Log Message:

fixing crash in tpcds


diffs (201 lines):

diff --git a/sql/benchmarks/tpcds/Tests/95.stable.out 
b/sql/benchmarks/tpcds/Tests/95.stable.out
--- a/sql/benchmarks/tpcds/Tests/95.stable.out
+++ b/sql/benchmarks/tpcds/Tests/95.stable.out
@@ -35,7 +35,11 @@ stdout of test '95` in directory 'sql/be
 #       sum(ws_ext_ship_cost) AS "total shipping cost" ,
 #       sum(ws_net_profit) AS "total net profit"
 #FROM web_sales ws1 ,
-% .L26,        .L31,   .L34 # table_name
+#     date_dim ,
+#     customer_address ,
+#     web_site
+#WHERE d_date BETWEEN '1999-02-01' AND cast('1999-04-02' AS date)
+% .%4, .%5,    .%6 # table_name
 % "order count",       "total shipping cost",  "total net profit" # name
 % bigint,      decimal,        decimal # type
 % 2,   20,     20 # length
diff --git a/sql/benchmarks/tpcds/Tests/95.stable.out.int128 
b/sql/benchmarks/tpcds/Tests/95.stable.out.int128
--- a/sql/benchmarks/tpcds/Tests/95.stable.out.int128
+++ b/sql/benchmarks/tpcds/Tests/95.stable.out.int128
@@ -35,7 +35,11 @@ stdout of test '95` in directory 'sql/be
 #       sum(ws_ext_ship_cost) AS "total shipping cost" ,
 #       sum(ws_net_profit) AS "total net profit"
 #FROM web_sales ws1 ,
-% .L26,        .L31,   .L34 # table_name
+#     date_dim ,
+#     customer_address ,
+#     web_site
+#WHERE d_date BETWEEN '1999-02-01' AND cast('1999-04-02' AS date)
+% .%4, .%5,    .%6 # table_name
 % "order count",       "total shipping cost",  "total net profit" # name
 % bigint,      decimal,        decimal # type
 % 2,   40,     40 # length
diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c
--- a/sql/server/rel_dump.c
+++ b/sql/server/rel_dump.c
@@ -1155,6 +1155,15 @@ exp_read(mvc *sql, sql_rel *lrel, sql_re
        }
        skipWS(r, pos);
        switch(r[*pos]) {
+       case 'a':
+               if (strncmp(r+*pos, "any =",  strlen("any =")) == 0) {
+                       (*pos)+= (int) strlen("any =");
+                       f = mark_in;
+               } else if (strncmp(r+*pos, "all <>",  strlen("all <>")) == 0) {
+                       (*pos)+= (int) strlen("all <>");
+                       f = mark_notin;
+               }
+               break;
        case 'n':
                if (strncmp(r+*pos, "notin",  strlen("notin")) == 0) {
                        (*pos)+= (int) strlen("notin");
diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c
--- a/sql/server/rel_exp.c
+++ b/sql/server/rel_exp.c
@@ -588,7 +588,9 @@ exp_column(sql_allocator *sa, const char
 sql_exp *
 exp_propagate(sql_allocator *sa, sql_exp *ne, sql_exp *oe)
 {
-       if (has_label(oe) && oe->alias.rname == ne->alias.rname && 
oe->alias.name == ne->alias.name)
+       if (has_label(oe) && 
+          (oe->alias.rname == ne->alias.rname || (oe->alias.rname && 
ne->alias.rname && strcmp(oe->alias.rname, ne->alias.rname) == 0)) &&
+          (oe->alias.name == ne->alias.name || (oe->alias.name && 
ne->alias.name && strcmp(oe->alias.name, ne->alias.name) == 0)))
                ne->alias.label = oe->alias.label;
        if (is_intern(oe))
                set_intern(ne);
@@ -1528,27 +1530,6 @@ rel_find_exp( sql_rel *rel, sql_exp *e)
        return ne;
 }
 
-int 
-exp_is_correlation(sql_exp *e, sql_rel *r )
-{
-       if (e->type == e_cmp && !is_complex_exp(e->flag)) {
-               sql_exp *le = rel_find_exp(r->l, e->l);
-               sql_exp *re = rel_find_exp(r->r, e->r);
-
-               if (le && re)
-                       return 0;
-               le = rel_find_exp(r->r, e->l);
-               re = rel_find_exp(r->l, e->r);
-               if (le && re) {
-                       /* for future processing we depend on 
-                          the correct order of the expression, ie swap here */
-                       exp_swap(e);
-                       return 0;
-               }
-       }
-       return -1;
-}
-
 int
 exp_is_true(mvc *sql, sql_exp *e) 
 {
diff --git a/sql/server/rel_exp.h b/sql/server/rel_exp.h
--- a/sql/server/rel_exp.h
+++ b/sql/server/rel_exp.h
@@ -135,7 +135,6 @@ extern int exps_match_col_exps( sql_exp 
 extern int exp_match_list( list *l, list *r);
 extern int exp_is_join(sql_exp *e, list *rels);
 extern int exp_is_eqjoin(sql_exp *e);
-extern int exp_is_correlation(sql_exp *e, sql_rel *r );
 extern int exp_is_join_exp(sql_exp *e);
 extern int exp_is_atom(sql_exp *e);
 extern int exp_is_true(mvc *sql, sql_exp *e);
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
@@ -3788,7 +3788,7 @@ rel_project_cse(int *changes, mvc *sql, 
                                        if (exp_name(e2) && exp_match_exp(e1, 
e2)) {
                                                sql_exp *ne = 
exp_alias(sql->sa, exp_relname(e1), exp_name(e1), exp_relname(e2), 
exp_name(e2), exp_subtype(e2), e2->card, has_nil(e2), is_intern(e1));
 
-                                               ne = exp_propagate(sql->sa, ne, 
e2);
+                                               ne = exp_propagate(sql->sa, ne, 
e1);
                                                e1 = ne;
                                                break;
                                        }
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
@@ -2099,6 +2099,33 @@ rewrite_join2semi(mvc *sql, sql_rel *rel
 
                if (!j || (!is_join(j->op) && !is_semi(j->op)) || 
!list_empty(j->exps))
                        return rel;
+               /* if needed first push select exps down under the join */
+               for(node *n = rel->exps->h; n && !needed; n = n->next) {
+                       sql_exp *e = n->data;
+                       sql_subfunc *sf = e->f;
+
+                       if (is_func(e->type) && is_anyequal_func(sf) && 
rel_has_all_exps(j->l, e->l))
+                               needed = 1;
+               }
+               if (needed) {
+                       list *exps = sa_list(sql->sa), *jexps = 
sa_list(sql->sa);
+                       sql_rel *l = j->l = rel_select(sql->sa, j->l, NULL);
+
+                       for(node *n = rel->exps->h; n; n = n->next) {
+                               sql_exp *e = n->data;
+                               sql_subfunc *sf = e->f;
+
+                               if (is_func(e->type) && is_anyequal_func(sf) && 
rel_has_all_exps(j->l, e->l))
+                                       append(exps, e);
+                               else
+                                       append(jexps, e);
+                       }
+                       rel->exps = jexps;
+                       l->exps = exps;
+                       j->l = rewrite_join2semi(sql, j->l);
+               }
+
+               needed = 0;
                for(node *n = rel->exps->h; n && !needed; n = n->next) {
                        sql_exp *e = n->data;
                        sql_subfunc *sf = e->f;
diff --git a/sql/test/Tests/window_functions.stable.out 
b/sql/test/Tests/window_functions.stable.out
--- a/sql/test/Tests/window_functions.stable.out
+++ b/sql/test/Tests/window_functions.stable.out
@@ -204,7 +204,7 @@ stdout of test 'window_functions` in dir
 #SELECT duration_seconds,
 #       cast(SUM(duration_seconds) OVER (ORDER BY start_time) as bigint) AS 
running_total
 #  FROM tutorial.dc_bikeshare_q1_2012;
-% tutorial.dc_bikeshare_q1_2012,       tutorial. # table_name
+% tutorial.dc_bikeshare_q1_2012,       tutorial.%6 # table_name
 % duration_seconds,    running_total # name
 % int, bigint # type
 % 3,   3 # length
@@ -221,7 +221,7 @@ stdout of test 'window_functions` in dir
 #         AS running_total
 #  FROM tutorial.dc_bikeshare_q1_2012
 # WHERE start_time < '2012-01-08';
-% tutorial.dc_bikeshare_q1_2012,       tutorial.dc_bikeshare_q1_2012,  
tutorial. # table_name
+% tutorial.dc_bikeshare_q1_2012,       tutorial.dc_bikeshare_q1_2012,  
tutorial.%7 # table_name
 % start_terminal,      duration_seconds,       running_total # name
 % varchar,     int,    bigint # type
 % 6,   3,      3 # length
@@ -237,7 +237,7 @@ stdout of test 'window_functions` in dir
 #         (PARTITION BY start_terminal) as bigint) AS start_terminal_total
 #  FROM tutorial.dc_bikeshare_q1_2012
 # WHERE start_time < '2012-01-08';
-% tutorial.dc_bikeshare_q1_2012,       tutorial.dc_bikeshare_q1_2012,  
tutorial. # table_name
+% tutorial.dc_bikeshare_q1_2012,       tutorial.dc_bikeshare_q1_2012,  
tutorial.%7 # table_name
 % start_terminal,      duration_seconds,       start_terminal_total # name
 % varchar,     int,    bigint # type
 % 6,   3,      3 # length
@@ -257,7 +257,7 @@ stdout of test 'window_functions` in dir
 #         (PARTITION BY start_terminal) AS running_avg
 #  FROM tutorial.dc_bikeshare_q1_2012
 # WHERE start_time < '2012-01-08';
-% tutorial.dc_bikeshare_q1_2012,       tutorial.dc_bikeshare_q1_2012,  
tutorial.,      tutorial.,      tutorial. # table_name
+% tutorial.dc_bikeshare_q1_2012,       tutorial.dc_bikeshare_q1_2012,  
tutorial.%13,   tutorial.%14,   tutorial.%15 # table_name
 % start_terminal,      duration_seconds,       running_total,  running_count,  
running_avg # name
 % varchar,     int,    bigint, bigint, double # type
 % 6,   3,      3,      1,      24 # length
@@ -280,7 +280,7 @@ stdout of test 'window_functions` in dir
 #         AS running_avg
 #  FROM tutorial.dc_bikeshare_q1_2012
 # WHERE start_time < '2012-01-08';
-% tutorial.dc_bikeshare_q1_2012,       tutorial.dc_bikeshare_q1_2012,  
tutorial.,      tutorial.,      tutorial. # table_name
+% tutorial.dc_bikeshare_q1_2012,       tutorial.dc_bikeshare_q1_2012,  
tutorial.%13,   tutorial.%14,   tutorial.%15 # table_name
 % start_terminal,      duration_seconds,       running_total,  running_count,  
running_avg # name
 % varchar,     int,    bigint, bigint, double # type
 % 6,   3,      3,      1,      24 # length
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to