Changeset: 0d8fd1c7710c for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0d8fd1c7710c Added Files: sql/test/mergetables/Tests/sqlsmith.Bug-6459.sql sql/test/mergetables/Tests/sqlsmith.Bug-6459.stable.err sql/test/mergetables/Tests/sqlsmith.Bug-6459.stable.out Modified Files: sql/benchmarks/tpch/fileleak/Tests/leaks.stable.out sql/benchmarks/tpch/fileleak/Tests/leaks.stable.out.Windows sql/server/rel_optimizer.c sql/server/rel_select.c sql/test/BugTracker-2015/Tests/crash.Bug-3736.stable.out sql/test/BugTracker-2017/Tests/caching_stats_bug.6374.stable.out sql/test/BugTracker/Tests/jdbc_no_debug.SF-1739356.stable.out sql/test/leaks/Tests/check1.stable.out.int128 sql/test/mergetables/Tests/All Branch: Jul2017 Log Message:
fixed bug 6459 and bug 6456 diffs (truncated from 578 to 300 lines): diff --git a/sql/benchmarks/tpch/fileleak/Tests/leaks.stable.out b/sql/benchmarks/tpch/fileleak/Tests/leaks.stable.out --- a/sql/benchmarks/tpch/fileleak/Tests/leaks.stable.out +++ b/sql/benchmarks/tpch/fileleak/Tests/leaks.stable.out @@ -25,22 +25,22 @@ Ready. # 16:01:26 > "/usr/bin/python2" "leaks.SQL.py" "leaks" # 16:01:26 > -(u'l_comment', 262144, 0) -(u'l_commitdate', 262144, 0) -(u'l_discount', 524288, 0) -(u'l_extendedprice', 524288, 0) -(u'l_linenumber', 262144, 0) +(u'l_comment', 65536, 0) +(u'l_commitdate', 65536, 0) +(u'l_discount', 65536, 0) +(u'l_extendedprice', 65536, 0) +(u'l_linenumber', 65536, 0) (u'l_linestatus', 0, 0) -(u'l_orderkey', 262144, 0) -(u'l_partkey', 262144, 0) -(u'l_quantity', 524288, 0) -(u'l_receiptdate', 262144, 0) +(u'l_orderkey', 65536, 0) +(u'l_partkey', 65536, 0) +(u'l_quantity', 65536, 0) +(u'l_receiptdate', 65536, 0) (u'l_returnflag', 0, 0) -(u'l_shipdate', 262144, 0) +(u'l_shipdate', 65536, 0) (u'l_shipinstruct', 0, 0) (u'l_shipmode', 0, 0) -(u'l_suppkey', 262144, 0) -(u'l_tax', 524288, 0) +(u'l_suppkey', 65536, 0) +(u'l_tax', 65536, 0) # 16:01:26 > # 16:01:26 > "Done." diff --git a/sql/benchmarks/tpch/fileleak/Tests/leaks.stable.out.Windows b/sql/benchmarks/tpch/fileleak/Tests/leaks.stable.out.Windows --- a/sql/benchmarks/tpch/fileleak/Tests/leaks.stable.out.Windows +++ b/sql/benchmarks/tpch/fileleak/Tests/leaks.stable.out.Windows @@ -25,22 +25,22 @@ Ready. # 16:01:26 > "/usr/bin/python2" "leaks.SQL.py" "leaks" # 16:01:26 > -(u'l_comment', 262144, 0) -(u'l_commitdate', 262144, 0) -(u'l_discount', 524288, 0) -(u'l_extendedprice', 524288, 0) -(u'l_linenumber', 262144, 0) +(u'l_comment', 65536, 0) +(u'l_commitdate', 65536, 0) +(u'l_discount', 65536, 0) +(u'l_extendedprice', 65536, 0) +(u'l_linenumber', 65536, 0) (u'l_linestatus', 0, 0) -(u'l_orderkey', 262144, 0) -(u'l_partkey', 262144, 0) -(u'l_quantity', 524288, 0) -(u'l_receiptdate', 262144, 0) +(u'l_orderkey', 65536, 0) +(u'l_partkey', 65536, 0) +(u'l_quantity', 65536, 0) +(u'l_receiptdate', 65536, 0) (u'l_returnflag', 0, 0) -(u'l_shipdate', 262144, 0) +(u'l_shipdate', 65536, 0) (u'l_shipinstruct', 0, 0) (u'l_shipmode', 0, 0) -(u'l_suppkey', 262144, 0) -(u'l_tax', 524288, 0) +(u'l_suppkey', 65536, 0) +(u'l_tax', 65536, 0) # 16:01:26 > # 16:01:26 > "Done." 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 @@ -3729,7 +3729,7 @@ rel_push_aggr_down(int *changes, mvc *sq set_has_nil(e); e = exp_column(sql->sa, exp_find_rel_name(e), exp_name(e), exp_subtype(e), e->card, has_nil(e), is_intern(e)); ne = exp_aggr1(sql->sa, e, a, need_distinct(e), 1, e->card, 1); - if (cnt) + if (0 && cnt) ne->p = prop_create(sql->sa, PROP_COUNT, ne->p); } else { ne = exp_copy(sql->sa, oa); @@ -5387,7 +5387,7 @@ exps_remove_dictexps(mvc *sql, list *exp static sql_rel * rel_remove_join(int *changes, mvc *sql, sql_rel *rel) { - if (is_join(rel->op) && !is_outerjoin(rel->op)) { + if (is_join(rel->op) && !is_outerjoin(rel->op) && 0) { sql_rel *l = rel->l; sql_rel *r = rel->r; int lconst = 0, rconst = 0; @@ -9153,11 +9153,56 @@ static sql_rel * return rel; } +static void +rel_reset_subquery(sql_rel *rel) +{ + if (!rel) + return; + + rel->subquery = 0; + switch(rel->op){ + case op_basetable: + case op_table: + case op_ddl: + + case op_insert: + case op_update: + case op_delete: + break; + case op_select: + case op_topn: + case op_sample: + + case op_project: + case op_groupby: + if (rel->l) + rel_reset_subquery(rel->l); + break; + case op_join: + case op_left: + case op_right: + case op_full: + case op_apply: + case op_semi: + case op_anti: + + case op_union: + case op_inter: + case op_except: + if (rel->l) + rel_reset_subquery(rel->l); + if (rel->r) + rel_reset_subquery(rel->r); + } + +} + sql_rel * rel_optimizer(mvc *sql, sql_rel *rel) { int level = 0, changes = 1; + rel_reset_subquery(rel); for( ;rel && level < 20 && changes; level++) rel = _rel_optimizer(sql, rel, &changes, level); return rel; diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c --- a/sql/server/rel_select.c +++ b/sql/server/rel_select.c @@ -2008,6 +2008,7 @@ rel_logical_value_exp(mvc *sql, sql_rel } } else if (r) { sql_rel *l = *rel; + sql_exp *rls = ls; if (!l) { l = *rel = rel_project(sql->sa, NULL, new_exp_list(sql->sa)); @@ -2017,7 +2018,7 @@ rel_logical_value_exp(mvc *sql, sql_rel l->exps = list_merge(l->exps, rel_projections(sql, l->l, NULL, 1, 1), (fdup)NULL); l->exps = list_distinct(l->exps, (fcmp)exp_equal, (fdup)NULL); } - if (!rel_find_exp(l, ls)) + if (!(rls = rel_find_exp(l, ls)) || rls == ls /* constant atom */) rel_project_add_exp(sql, l, ls); } rs = rel_lastexp(sql, r); diff --git a/sql/test/BugTracker-2015/Tests/crash.Bug-3736.stable.out b/sql/test/BugTracker-2015/Tests/crash.Bug-3736.stable.out --- a/sql/test/BugTracker-2015/Tests/crash.Bug-3736.stable.out +++ b/sql/test/BugTracker-2015/Tests/crash.Bug-3736.stable.out @@ -75,7 +75,7 @@ project ( | | | select ( | | | | group by ( | | | | | join ( -| | | | | | table(sys.bidder) [ "bidder"."id" NOT NULL HASHCOL as "b2a"."id", "bidder"."open_auction_id" NOT NULL as "b2a"."open_auction_id", "bidder"."%TID%" NOT NULL as "L32"."%TID%" ] COUNT , +| | | | | | table(sys.bidder) [ "bidder"."id" NOT NULL HASHCOL as "b2a"."id", "bidder"."open_auction_id" NOT NULL as "b2a"."open_auction_id" ] COUNT , | | | | | | project ( | | | | | | | crossproduct ( | | | | | | | | project ( @@ -90,24 +90,24 @@ project ( | | | | | | | | | | | | | | | | | table(sys.open_auctions) [ "open_auctions"."id" NOT NULL HASHCOL as "o"."id", "open_auctions"."open_auction_id" NOT NULL as "o"."open_auction_id" ] COUNT , | | | | | | | | | | | | | | | | | table(sys.bidder) [ "bidder"."id" NOT NULL HASHCOL as "b"."id", "bidder"."open_auction_id" NOT NULL as "b"."open_auction_id", "bidder"."date" NOT NULL as "b"."date", "bidder"."time" NOT NULL as "b"."time", "bidder"."personref" NOT NULL as "b"."personref", "bidder"."increase" NOT NULL as "b"."increase" ] COUNT | | | | | | | | | | | | | | | | ) [ "o"."open_auction_id" NOT NULL = "b"."open_auction_id" NOT NULL ] -| | | | | | | | | | | | | | | ) [ "o"."id" NOT NULL HASHCOL , "o"."open_auction_id" NOT NULL, "b"."id" NOT NULL HASHCOL , "b"."open_auction_id" NOT NULL, "b"."date" NOT NULL, "b"."time" NOT NULL, "b"."personref" NOT NULL, "b"."increase" NOT NULL, sys.identity("o"."id" NOT NULL) HASHCOL as "L53"."L53" ], +| | | | | | | | | | | | | | | ) [ "o"."id" NOT NULL HASHCOL , "o"."open_auction_id" NOT NULL, "b"."id" NOT NULL HASHCOL , "b"."open_auction_id" NOT NULL, "b"."date" NOT NULL, "b"."time" NOT NULL, "b"."personref" NOT NULL, "b"."increase" NOT NULL, sys.identity("o"."id" NOT NULL) HASHCOL as "L51"."L51" ], | | | | | | | | | | | | | | | table(sys.bidder) [ "bidder"."id" NOT NULL HASHCOL as "b3"."id", "bidder"."increase" NOT NULL as "b3"."increase" ] COUNT | | | | | | | | | | | | | | ) [ ] -| | | | | | | | | | | | | ) [ "L53"."L53" HASHCOL , "o"."id" NOT NULL HASHCOL , "o"."open_auction_id" NOT NULL, "b"."id" NOT NULL HASHCOL , "b"."open_auction_id" NOT NULL, "b"."date" NOT NULL, "b"."time" NOT NULL, "b"."personref" NOT NULL, "b"."increase" NOT NULL, "b3"."id" NOT NULL HASHCOL , "b3"."increase" NOT NULL, sys.identity("o"."id" NOT NULL) HASHCOL as "L41"."L41" ], +| | | | | | | | | | | | | ) [ "L51"."L51" HASHCOL , "o"."id" NOT NULL HASHCOL , "o"."open_auction_id" NOT NULL, "b"."id" NOT NULL HASHCOL , "b"."open_auction_id" NOT NULL, "b"."date" NOT NULL, "b"."time" NOT NULL, "b"."personref" NOT NULL, "b"."increase" NOT NULL, "b3"."id" NOT NULL HASHCOL , "b3"."increase" NOT NULL, sys.identity("o"."id" NOT NULL) HASHCOL as "L37"."L37" ], | | | | | | | | | | | | | table(sys.bidder) [ "bidder"."id" NOT NULL HASHCOL as "b3a"."id", "bidder"."open_auction_id" NOT NULL as "b3a"."open_auction_id" ] COUNT | | | | | | | | | | | | ) [ "b3a"."open_auction_id" NOT NULL = "o"."open_auction_id" NOT NULL ] -| | | | | | | | | | | ) [ "L41"."L41", "L53"."L53" ] [ "L53"."L53" HASHCOL , "o"."id" NOT NULL HASHCOL , "o"."open_auction_id" NOT NULL, "b"."id" NOT NULL HASHCOL , "b"."open_auction_id" NOT NULL, "b"."date" NOT NULL, "b"."time" NOT NULL, "b"."personref" NOT NULL, "b"."increase" NOT NULL, "b3"."id" NOT NULL HASHCOL , "b3"."increase" NOT NULL, "L41"."L41" HASHCOL , sys.min no nil ("b3a"."id" NOT NULL HASHCOL ) NOT NULL as "L10"."L10" ] +| | | | | | | | | | | ) [ "L37"."L37", "L51"."L51" ] [ "L51"."L51" HASHCOL , "o"."id" NOT NULL HASHCOL , "o"."open_auction_id" NOT NULL, "b"."id" NOT NULL HASHCOL , "b"."open_auction_id" NOT NULL, "b"."date" NOT NULL, "b"."time" NOT NULL, "b"."personref" NOT NULL, "b"."increase" NOT NULL, "b3"."id" NOT NULL HASHCOL , "b3"."increase" NOT NULL, "L37"."L37" HASHCOL , sys.min no nil ("b3a"."id" NOT NULL HASHCOL ) NOT NULL as "L10"."L10" ] | | | | | | | | | | ) [ "b3"."id" NOT NULL HASHCOL = "L10" NOT NULL ] | | | | | | | | | ) [ "o"."id" NOT NULL HASHCOL , "o"."open_auction_id" NOT NULL, "b"."id" NOT NULL HASHCOL , "b"."open_auction_id" NOT NULL, "b"."date" NOT NULL, "b"."time" NOT NULL, "b"."personref" NOT NULL, "b"."increase" NOT NULL, "b3"."increase" NOT NULL as "L13"."L13" ] -| | | | | | | | ) [ "o"."id" NOT NULL HASHCOL , "o"."open_auction_id" NOT NULL, "b"."id" NOT NULL HASHCOL , "b"."open_auction_id" NOT NULL, "b"."date" NOT NULL, "b"."time" NOT NULL, "b"."personref" NOT NULL, "b"."increase" NOT NULL, "L13"."L13" NOT NULL, sys.identity("o"."id" NOT NULL) HASHCOL as "L72"."L72" ], -| | | | | | | | table(sys.bidder) [ "bidder"."id" NOT NULL HASHCOL as "b2"."id", "bidder"."increase" NOT NULL as "b2"."increase", "bidder"."%TID%" NOT NULL as "L32"."%TID%" ] COUNT +| | | | | | | | ) [ "o"."id" NOT NULL HASHCOL , "o"."open_auction_id" NOT NULL, "b"."id" NOT NULL HASHCOL , "b"."open_auction_id" NOT NULL, "b"."date" NOT NULL, "b"."time" NOT NULL, "b"."personref" NOT NULL, "b"."increase" NOT NULL, "L13"."L13" NOT NULL, sys.identity("o"."id" NOT NULL) HASHCOL as "L70"."L70" ], +| | | | | | | | table(sys.bidder) [ "bidder"."id" NOT NULL HASHCOL as "b2"."id", "bidder"."increase" NOT NULL as "b2"."increase" ] COUNT | | | | | | | ) [ ] -| | | | | | ) [ "L72"."L72" HASHCOL , "o"."id" NOT NULL HASHCOL , "o"."open_auction_id" NOT NULL, "b"."id" NOT NULL HASHCOL , "b"."open_auction_id" NOT NULL, "b"."date" NOT NULL, "b"."time" NOT NULL, "b"."personref" NOT NULL, "b"."increase" NOT NULL, "L13"."L13" NOT NULL, "b2"."id" NOT NULL HASHCOL , "b2"."increase" NOT NULL, sys.identity("o"."id" NOT NULL) HASHCOL as "L64"."L64" ] +| | | | | | ) [ "L70"."L70" HASHCOL , "o"."id" NOT NULL HASHCOL , "o"."open_auction_id" NOT NULL, "b"."id" NOT NULL HASHCOL , "b"."open_auction_id" NOT NULL, "b"."date" NOT NULL, "b"."time" NOT NULL, "b"."personref" NOT NULL, "b"."increase" NOT NULL, "L13"."L13" NOT NULL, "b2"."id" NOT NULL HASHCOL , "b2"."increase" NOT NULL, sys.identity("o"."id" NOT NULL) HASHCOL as "L62"."L62" ] | | | | | ) [ "b2a"."open_auction_id" NOT NULL = "o"."open_auction_id" NOT NULL ] -| | | | ) [ "L64"."L64", "L72"."L72" ] [ "L72"."L72" HASHCOL , "b"."id" NOT NULL HASHCOL , "b"."open_auction_id" NOT NULL, "b"."date" NOT NULL, "b"."time" NOT NULL, "b"."personref" NOT NULL, "b"."increase" NOT NULL, "L13"."L13" NOT NULL, "b2"."id" NOT NULL HASHCOL , "b2"."increase" NOT NULL, "L64"."L64" HASHCOL , sys.max no nil ("b2a"."id" NOT NULL HASHCOL ) NOT NULL as "L24"."L24" ] +| | | | ) [ "L62"."L62", "L70"."L70" ] [ "L70"."L70" HASHCOL , "b"."id" NOT NULL HASHCOL , "b"."open_auction_id" NOT NULL, "b"."date" NOT NULL, "b"."time" NOT NULL, "b"."personref" NOT NULL, "b"."increase" NOT NULL, "L13"."L13" NOT NULL, "b2"."id" NOT NULL HASHCOL , "b2"."increase" NOT NULL, "L62"."L62" HASHCOL , sys.max no nil ("b2a"."id" NOT NULL HASHCOL ) NOT NULL as "L24"."L24" ] | | | ) [ "b2"."id" NOT NULL HASHCOL = "L24"."L24" NOT NULL ] -| | ) [ "L72"."L72" HASHCOL , "b"."id" NOT NULL HASHCOL , "b"."open_auction_id" NOT NULL, "b"."date" NOT NULL, "b"."time" NOT NULL, "b"."personref" NOT NULL, "b"."increase" NOT NULL, "L13"."L13" NOT NULL, "b2"."id" NOT NULL HASHCOL , "b2"."increase" NOT NULL, "L64"."L64" HASHCOL , "L24"."L24" NOT NULL, sys.sql_mul("L13"."L13" NOT NULL, double "2.000000") as "L77"."L77", "b2"."increase" NOT NULL as "L100"."L100" ] -| ) [ "L77"."L77" <= "L100"."L100" NOT NULL ] +| | ) [ "L70"."L70" HASHCOL , "b"."id" NOT NULL HASHCOL , "b"."open_auction_id" NOT NULL, "b"."date" NOT NULL, "b"."time" NOT NULL, "b"."personref" NOT NULL, "b"."increase" NOT NULL, "L13"."L13" NOT NULL, "b2"."id" NOT NULL HASHCOL , "b2"."increase" NOT NULL, "L62"."L62" HASHCOL , "L24"."L24" NOT NULL, sys.sql_mul("L13"."L13" NOT NULL, double "2.000000") as "L75"."L75", "b2"."increase" NOT NULL as "L76"."L76" ] +| ) [ "L75"."L75" <= "L76"."L76" NOT NULL ] ) [ "b"."id" NOT NULL HASHCOL , "b"."open_auction_id" NOT NULL, "b"."date" NOT NULL, "b"."time" NOT NULL, "b"."personref" NOT NULL, "b"."increase" NOT NULL ] #Select b.* FROM open_auctions o, bidder b WHERE (select b3.INCREASE from bidder b3 where b3.id = (select min (b3a.id) from bidder b3a where b3a.open_auction_id = o.open_auction_id)) * 2 <= (Select b2.INCREASE from bidder b2 where b2.id = (SELECT MAX (b2a.id) from bidder b2a where b2a.open_auction_id = o.open_auction_id)) AND o.open_auction_id = b.open_auction_id order by date, time; % sys.b, sys.b, sys.b, sys.b, sys.b, sys.b # table_name diff --git a/sql/test/BugTracker-2017/Tests/caching_stats_bug.6374.stable.out b/sql/test/BugTracker-2017/Tests/caching_stats_bug.6374.stable.out --- a/sql/test/BugTracker-2017/Tests/caching_stats_bug.6374.stable.out +++ b/sql/test/BugTracker-2017/Tests/caching_stats_bug.6374.stable.out @@ -86,7 +86,7 @@ project ( | | | | ) [ "mt"."i" ] | | | ) [ ] [ sys.count() NOT NULL as "L3"."L3" ] | | ) [ "L3"."L3" ] -| ) [ ] [ sys.sum no nil ("L3"."L3") COUNT as "L3"."L3" ] +| ) [ ] [ sys.sum no nil ("L3"."L3") as "L3"."L3" ] ) [ "L3" NOT NULL as "L4"."L3" ] #drop table mt; #drop table sub1; diff --git a/sql/test/BugTracker/Tests/jdbc_no_debug.SF-1739356.stable.out b/sql/test/BugTracker/Tests/jdbc_no_debug.SF-1739356.stable.out --- a/sql/test/BugTracker/Tests/jdbc_no_debug.SF-1739356.stable.out +++ b/sql/test/BugTracker/Tests/jdbc_no_debug.SF-1739356.stable.out @@ -38,7 +38,7 @@ Ready. | | | | | ) [ "_tables"."id" as "tables"."id" ] | | | | | ) [ ] [ sys.count() NOT NULL as "L41"."L41" ] | | | | ) [ "L41"."L41" ] | -| | ) [ ] [ sys.sum no nil ("L41"."L41") COUNT as "L41"."L41" ] | +| | ) [ ] [ sys.sum no nil ("L41"."L41") as "L41"."L41" ] | | ) [ "L41" NOT NULL as "L42"."L41" ] | +----------------------------------------------------------------------------+ 18 rows @@ -73,28 +73,28 @@ Operation successful | X_43:lng := aggr.sum(X_42); | | sql.resultSet(".L42", "L41", "bigint", 64:int, 0:int, 7:int, X_43); | | end user.s4_1; | -| #inline actions= 0 time=1 usec | +| #inline actions= 0 time=2 usec | | #remap actions= 0 time=3 usec | | #costmodel actions= 1 time=3 usec | -| #coercion actions= 1 time=9 usec | +| #coercion actions= 1 time=10 usec | | #evaluate actions= 0 time=5 usec | | #emptybind actions= 0 time=1 usec | -| #pushselect actions= 5 time=43 usec | -| #aliases actions= 2 time=14 usec | -| #mergetable actions= 0 time=56 usec | -| #deadcode actions= 3 time=13 usec | +| #pushselect actions= 5 time=45 usec | +| #aliases actions= 2 time=13 usec | +| #mergetable actions= 0 time=63 usec | +| #deadcode actions= 3 time=14 usec | | #aliases actions= 0 time=0 usec | -| #constants actions= 1 time=11 usec | -| #commonTerms actions= 0 time=10 usec | +| #constants actions= 1 time=12 usec | +| #commonTerms actions= 0 time=9 usec | | #projectionpath actions= 0 time=6 usec | -| #reorder actions= 1 time=42 usec | +| #reorder actions= 1 time=47 usec | | #deadcode actions= 0 time=8 usec | | #matpack actions= 0 time=0 usec | | #multiplex actions= 0 time=3 usec | | #profiler actions=1 time=2 usec | | #candidates actions=1 time=2 usec | -| #garbagecollector actions= 1 time=61 usec | -| #total actions=23 time=427 usec | +| #garbagecollector actions= 1 time=80 usec | +| #total actions=23 time=480 usec | +-------------------------------------------------------------------------------------------------------+ 49 rows diff --git a/sql/test/leaks/Tests/check1.stable.out.int128 b/sql/test/leaks/Tests/check1.stable.out.int128 --- a/sql/test/leaks/Tests/check1.stable.out.int128 +++ b/sql/test/leaks/Tests/check1.stable.out.int128 @@ -316,7 +316,7 @@ Ready. % L2, L5 # name % char, bigint # type % 9, 3 # length -[ "transient", 167 ] +[ "transient", 163 ] #select 'persistent', count(*) from bbp() as bbp where kind like 'pers%'; % .L2, .L6 # table_name % L2, L5 # name diff --git a/sql/test/mergetables/Tests/All b/sql/test/mergetables/Tests/All --- a/sql/test/mergetables/Tests/All +++ b/sql/test/mergetables/Tests/All @@ -26,4 +26,5 @@ HAVE_NETCDF&HAVE_SAMTOOLS?sqlsmith.Bug-6 _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list