Changeset: 4ce20134d011 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4ce20134d011 Modified Files: sql/server/rel_optimizer.c sql/test/mergetables/Tests/sqlsmith-exists2.stable.out Branch: Jun2020 Log Message:
Fix for sqlsmith crash, ie if a topN relation has more than one reference, it cannot be pushed down diffs (99 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 @@ -2109,7 +2109,7 @@ rel_push_topn_and_sample_down(mvc *sql, /* push topn/sample under projections */ - if (r && is_simple_project(r->op) && !need_distinct(r) && !rel_is_ref(r) && r->l && !r->r) { + if (!rel_is_ref(rel) && r && is_simple_project(r->op) && !need_distinct(r) && !rel_is_ref(r) && r->l && !r->r) { sql_rel *x = r, *px = x; while (is_simple_project(x->op) && !need_distinct(x) && !rel_is_ref(x) && x->l && !x->r) { diff --git a/sql/test/mergetables/Tests/sqlsmith-exists2.stable.out b/sql/test/mergetables/Tests/sqlsmith-exists2.stable.out --- a/sql/test/mergetables/Tests/sqlsmith-exists2.stable.out +++ b/sql/test/mergetables/Tests/sqlsmith-exists2.stable.out @@ -221,6 +221,83 @@ stdout of test 'sqlsmith-exists2` in dir [ 1 ] [ 1 ] [ 1 ] +#select +# ref_1.col3 as c0, +# ref_1.col4 as c1, +# cast(nullif(ref_0.col0, +# subq_0.c8) as int) as c2 from +# tab1 as ref_0 +# right join tbl_productsales as ref_1 +# on (exists ( +# select +# ref_1.col1 as c0, +# ref_2.col2 as c1, +# ref_0.col0 as c2, +# ref_2.col0 as c3, +# ref_2.col0 as c4, +# ref_1.col2 as c5 +# from +# tab1 as ref_2 +# where false)) +# inner join (select +# ref_4.i as c0, +# ref_3.col0 as c1, +# ref_4.i as c2, +# ref_4.i as c3, +# ref_4.i as c4, +# ref_4.i as c5, +# ref_3.col2 as c6, +# ref_4.i as c7, +# ref_3.col2 as c8, +% ., ., . # table_name +% c0, c1, c2 # name +% varchar, int, int # type +% 9, 3, 1 # length +[ "Mobo Game", 200, NULL ] +[ "Mobo Game", 200, NULL ] +[ "Mobo Game", 200, NULL ] +[ "Mobo Game", 200, NULL ] +[ "Mobo Game", 200, NULL ] +[ "Mobo Game", 200, NULL ] +[ "Mobo Game", 200, NULL ] +[ "Mobo Game", 200, NULL ] +[ "Mobo Game", 200, NULL ] +[ "PKO Game", 400, NULL ] +[ "PKO Game", 400, NULL ] +[ "PKO Game", 400, NULL ] +[ "PKO Game", 400, NULL ] +[ "PKO Game", 400, NULL ] +[ "PKO Game", 400, NULL ] +[ "PKO Game", 400, NULL ] +[ "PKO Game", 400, NULL ] +[ "PKO Game", 400, NULL ] +[ "Shirt", 500, NULL ] +[ "Shirt", 500, NULL ] +[ "Shirt", 500, NULL ] +[ "Shirt", 500, NULL ] +[ "Shirt", 500, NULL ] +[ "Shirt", 500, NULL ] +[ "Shirt", 500, NULL ] +[ "Shirt", 500, NULL ] +[ "Shirt", 500, NULL ] +[ "Shorts", 100, NULL ] +[ "Shorts", 100, NULL ] +[ "Shorts", 100, NULL ] +[ "Shorts", 100, NULL ] +[ "Shorts", 100, NULL ] +[ "Shorts", 100, NULL ] +[ "Shorts", 100, NULL ] +[ "Shorts", 100, NULL ] +[ "Shorts", 100, NULL ] +[ "Ball", 0, NULL ] +[ "Ball", 0, NULL ] +[ "Ball", 0, NULL ] +[ "Ball", 0, NULL ] +[ "Ball", 0, NULL ] +[ "Ball", 0, NULL ] +[ "Ball", 0, NULL ] +[ "Ball", 0, NULL ] +[ "Ball", 0, NULL ] #ROLLBACK; # 22:12:15 > _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list