Changeset: 9db1cd2c9335 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9db1cd2c9335
Modified Files:
        sql/server/rel_unnest.c
        sql/test/mergetables/Tests/sqlsmith-exists.stable.out
Branch: default
Log Message:

fixed push_up_join in combinations of semijoins with right outer joins


diffs (76 lines):

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
@@ -1082,24 +1082,29 @@ push_up_join(mvc *sql, sql_rel *rel, lis
                        if (ld && rd) {
                                node *m;
                                sql_rel *n, *nr, *nj;
+                               list *inner_exps = exps_copy(sql, j->exps);
+                               list *outer_exps = exps_copy(sql, rel->exps);
 
                                rel->r = rel_dup(jl);
+                               rel->exps = sa_list(sql->sa);
                                nj = rel_crossproduct(sql->sa, rel_dup(d), 
rel_dup(jr), j->op);
-                               nj->exps = exps_copy(sql, j->exps);
                                rel_destroy(j);
                                j = nj;
                                set_dependent(j);
                                n = rel_crossproduct(sql->sa, rel, j, j->op);
+                               n->exps = outer_exps;
+                               if (!n->exps)
+                                       n->exps = inner_exps;
+                               else
+                                       n->exps = list_merge(n->exps, 
inner_exps, (fdup)NULL);
                                j->op = rel->op;
                                if (is_semi(rel->op)) {
-                               //assert(!is_semi(rel->op));
                                        j->op = op_left;
                                        rel->op = op_left;
                                }
                                n->l = rel_project(sql->sa, n->l, 
rel_projections(sql, n->l, NULL, 1, 1));
                                nr = n->r;
                                nr = n->r = rel_project(sql->sa, n->r, 
is_semi(nr->op)?sa_list(sql->sa):rel_projections(sql, nr->r, NULL, 1, 1));
-                               move_join_exps(sql, n, j);
                                /* add nr->l exps with labels */ 
                                /* create jexps */
                                if (!n->exps)
diff --git a/sql/test/mergetables/Tests/sqlsmith-exists.stable.out 
b/sql/test/mergetables/Tests/sqlsmith-exists.stable.out
--- a/sql/test/mergetables/Tests/sqlsmith-exists.stable.out
+++ b/sql/test/mergetables/Tests/sqlsmith-exists.stable.out
@@ -410,6 +410,36 @@ stdout of test 'sqlsmith-exists` in dire
 % c0 # name
 % int # type
 % 1 # length
+#select 
+# subq_1.c0 as c0
+#from 
+# (select 
+# case when ((false) 
+# or (subq_0.c3 is not null)) 
+# and (true) then subq_0.c11 else subq_0.c11 end
+# as c0, 
+# case when subq_0.c0 is null then subq_0.c5 else subq_0.c5 end
+# as c1, 
+# subq_0.c6 as c2, 
+# case when true then subq_0.c3 else subq_0.c3 end
+# as c3, 
+# subq_0.c3 as c4, 
+# subq_0.c0 as c5, 
+# subq_0.c6 as c6, 
+# subq_0.c3 as c7, 
+# subq_0.c8 as c8, 
+# 42 as c9, 
+# subq_0.c6 as c10
+# from 
+# (select 
+# ref_0.col0 as c0, 
+# 85 as c1, 
+# ref_0.col1 as c2, 
+# ref_0.col2 as c3, 
+% . # table_name
+% c0 # name
+% int # type
+% 1 # length
 #ROLLBACK;
 
 # 19:56:32 >  
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to