Changeset: a07ae318c930 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a07ae318c930 Modified Files: sql/server/rel_optimizer.c sql/test/BugTracker-2014/Tests/orderby_on_constant.Bug-3554.sql sql/test/BugTracker-2014/Tests/orderby_on_constant.Bug-3554.stable.out Branch: Oct2014 Log Message:
fixed second part of bug 3554, ie handle topn push down properly diffs (50 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 @@ -1777,7 +1777,7 @@ rel_push_topn_down(int *changes, mvc *sq ur->r = exps_copy(sql->sa, r->r); ur = rel_topn(sql->sa, ur, sum_limit_offset(sql, rel->exps)); u = rel_setop(sql->sa, ul, ur, op_union); - u->exps = exps_copy(sql->sa, r->exps); + u->exps = exps_alias(sql->sa, r->exps); /* possibly add order by column */ if (add_r) u->exps = list_merge(u->exps, exps_copy(sql->sa, r->r), NULL); @@ -1785,7 +1785,11 @@ rel_push_topn_down(int *changes, mvc *sq rel_no_rename_exps(u->exps); rel_destroy(ou); - r->l = u; + ur = rel_project(sql->sa, u, exps_alias(sql->sa, r->exps)); + ur->r = r->r; + r->l = NULL; + rel_destroy(r); + rel->l = ur; (*changes)++; return rel; } diff --git a/sql/test/BugTracker-2014/Tests/orderby_on_constant.Bug-3554.sql b/sql/test/BugTracker-2014/Tests/orderby_on_constant.Bug-3554.sql --- a/sql/test/BugTracker-2014/Tests/orderby_on_constant.Bug-3554.sql +++ b/sql/test/BugTracker-2014/Tests/orderby_on_constant.Bug-3554.sql @@ -1,1 +1,4 @@ select a+b from (select 1 as a,1 as b) as q order by a limit 1; +select a+b from (select 1 as a,1 as b union select 1,1) as q order by a limit +1; + diff --git a/sql/test/BugTracker-2014/Tests/orderby_on_constant.Bug-3554.stable.out b/sql/test/BugTracker-2014/Tests/orderby_on_constant.Bug-3554.stable.out --- a/sql/test/BugTracker-2014/Tests/orderby_on_constant.Bug-3554.stable.out +++ b/sql/test/BugTracker-2014/Tests/orderby_on_constant.Bug-3554.stable.out @@ -31,6 +31,13 @@ Ready. % smallint # type % 1 # length [ 2 ] +#select a+b from (select 1 as a,1 as b union select 1,1) as q order by a limit +#1; +% .L3 # table_name +% L3 # name +% smallint # type +% 1 # length +[ 2 ] # 19:40:07 > # 19:40:07 > "Done." _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list