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

fixed handling of latest sqlsmith-exits problem (ie right join/semijoin rewrite)


diffs (124 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
@@ -1061,7 +1061,6 @@ push_up_join(mvc *sql, sql_rel *rel, lis
 
                /* left of rel should be a set */ 
                if (d && is_distinct_set(sql, d, ad) && j && (is_join(j->op) || 
is_semi(j->op))) {
-                       int crossproduct = 0;
                        sql_rel *jl = j->l, *jr = j->r;
                        /* op_join if F(jl) intersect A(D) = empty -> jl join 
(D djoin jr) 
                         *            F(jr) intersect A(D) = empty -> (D djoin 
jl) join jr
@@ -1074,7 +1073,6 @@ push_up_join(mvc *sql, sql_rel *rel, lis
                                rel->r = j = push_up_select_l(sql, j);
                                return rel; /* ie try again */
                        }
-                       crossproduct = list_empty(j->exps);
                        rd = (j->op != op_full && j->op != 
op_right)?rel_dependent_var(sql, d, jr):(list*)1;
                        ld = ((j->op == op_join || j->op == 
op_right))?rel_dependent_var(sql, d, jl):(list*)1;
 
@@ -1135,37 +1133,16 @@ push_up_join(mvc *sql, sql_rel *rel, lis
                                move_join_exps(sql, j, rel);
                                return j;
                        }
-                       if (/* DISABLES CODE */ (0) && !ld && is_left(rel->op) 
&& crossproduct) {
-                               sql_exp *l = exp_atom_int(sql->sa, 1);
-                               sql_exp *r = exp_atom_int(sql->sa, 1);
-                               rel->r = jr;
-                               j->l = rel;
-                               j->r = jl;
-
-                               assert(!rel_is_ref(j));
-                               if (!is_simple_project(jr->op))
-                                       rel->r = jr = rel_project(sql->sa, jr, 
rel_projections(sql, jr, NULL, 1, 1));
-                               if (!is_simple_project(jl->op))
-                                       j->r = jl = rel_project(sql->sa, jl, 
rel_projections(sql, jl, NULL, 1, 1));
-                               l = exp_label(sql->sa, l, ++sql->label);
-                               r = exp_label(sql->sa, r, ++sql->label);
-                               append(jl->exps, l);
-                               append(jr->exps, r);
-                               l = exp_ref(sql->sa, l);
-                               r = exp_ref(sql->sa, r);
-                               l = exp_compare(sql->sa, r, l, cmp_equal_nil);
-                               j->op = rel->op;
-                               move_join_exps(sql, j, rel);
-                               if (!j->exps)
-                                       j->exps = sa_list(sql->sa);
-                               append(j->exps, l);
-                               return j;
-                       } else if (!ld) {
+                       if (!ld) {
                                rel->r = rel_dup(jr);
                                sql_rel *nj = rel_crossproduct(sql->sa, 
rel_dup(jl), rel, j->op);
                                nj->exps = exps_copy(sql, j->exps);
                                rel_destroy(j);
                                j = nj; 
+                               if (is_semi(rel->op)) {
+                               //assert(!is_semi(rel->op));
+                                       rel->op = op_left;
+                               }
                                move_join_exps(sql, j, rel);
                                return j;
                        }
diff --git a/sql/test/BugTracker-2012/Tests/querycache.Bug-3212.stable.out 
b/sql/test/BugTracker-2012/Tests/querycache.Bug-3212.stable.out
--- a/sql/test/BugTracker-2012/Tests/querycache.Bug-3212.stable.out
+++ b/sql/test/BugTracker-2012/Tests/querycache.Bug-3212.stable.out
@@ -49,12 +49,12 @@ stdout of test 'querycache.Bug-3212` in 
 % .%1, .%1 # table_name
 % query,       count # name
 % clob,        int # type
-% 78,  1 # length
+% 70,  1 # length
 [ "select * from querycache();",       1       ]
-[ "select i, s from qrys where i = 3 and s = \\'new\\';",      1       ]
-[ "select i, s from qrys where i = 2 and s = \\'brave\\';",    1       ]
-[ "select i, s from qrys where i = 1 and s = \\'hello\\';",    1       ]
-[ "insert into qrys values 
(1,\\'hello\\'),(2,\\'brave\\'),(3,\\'new\\'),(4,\\'world\\');",    1       ]
+[ "select i, s from qrys where i = 3 and s = 'new';",  1       ]
+[ "select i, s from qrys where i = 2 and s = 'brave';",        1       ]
+[ "select i, s from qrys where i = 1 and s = 'hello';",        1       ]
+[ "insert into qrys values (1,'hello'),(2,'brave'),(3,'new'),(4,'world');",    
1       ]
 #drop table qrys;
 
 # 04:47:44 >  
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
@@ -492,6 +492,37 @@ stdout of test 'sqlsmith-exists` in dire
 % c0,  c1,     c2,     c3,     c4 # name
 % int, int,    int,    int,    int # type
 % 1,   1,      1,      1,      1 # length
+#select 
+# 34 as c0, 
+# ref_7.col1 as c1
+#from 
+# (select 
+# cast(nullif(ref_1.bb,
+# ref_0.col1) as int) as c0, 
+# ref_1.bb as c1, 
+# ref_0.col2 as c2, 
+# ref_1.bb as c3, 
+# ref_0.col2 as c4, 
+# cast(nullif(ref_0.col0,
+# ref_1.bb) as int) as c5, 
+# ref_0.col1 as c6, 
+# ref_1.bb as c7, 
+# ref_0.col2 as c8, 
+# ref_0.col0 as c9, 
+# ref_1.cc as c10, 
+# ref_0.col0 as c11, 
+# ref_1.aa as c12
+# from 
+# tab0 as ref_0
+# inner join analytics as ref_1
+# on (((ref_1.aa is null) 
+# or ((ref_1.bb is null) 
+# or ((63 is null) 
+# or ((ref_1.bb is not null) 
+% .,   . # table_name
+% c0,  c1 # name
+% tinyint,     int # type
+% 1,   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