Changeset: a99d546f149f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a99d546f149f
Modified Files:
        clients/Tests/MAL-signatures.stable.out
        clients/Tests/MAL-signatures.stable.out.int128
        monetdb5/optimizer/opt_mergetable.c
        sql/server/rel_optimizer.c
        
sql/test/BugTracker-2009/Tests/segfault_when_quitting_debugger.SF-2538837.stable.out
        sql/test/bugs/Tests/select_select_bug.stable.out
        sql/test/mergetables/Tests/part-elim.stable.out
Branch: default
Log Message:

Merge heads.


diffs (239 lines):

diff --git a/clients/Tests/MAL-signatures.stable.out 
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -23926,34 +23926,18 @@ command bat.mirror(b:bat[:any_2]):bat[:o
 address BKCmirror;
 comment Returns the head-mirror image of a BAT (two head columns).
 
-pattern bat.new_persistent(ht:oid,tt:any_1,size:lng):bat[:any_1] 
-address CMDBATnew_persistent;
-comment Creates a new BAT in the persistent farm and allocate space.
-
-pattern bat.new_persistent(ht:oid,tt:any_1,size:int):bat[:any_1] 
-address CMDBATnew_persistent;
-pattern bat.new_persistent(ht:oid,tt:any_1):bat[:any_1] 
-address CMDBATnew_persistent;
-comment Creates a new empty transient BAT in the persistent farm, with head- 
and tail-types as indicated.
-
-pattern bat.new(ht:oid,tt:any_1,size:lng):bat[:any_1] 
+pattern bat.new(tt:any_1,size:lng):bat[:any_1] 
 address CMDBATnew;
-comment Creates a new BAT with sufficient space.
-
-pattern bat.new(ht:oid,tt:any_1,size:int):bat[:any_1] 
+comment Creates a new empty transient BAT, with tail-types as indicated.
+
+pattern bat.new(tt:any_1,size:int,persist:bit):bat[:any_1] 
 address CMDBATnew;
-pattern bat.new(ht:oid,tt:any_1):bat[:any_1] 
+pattern bat.new(tt:any_1,size:lng,persist:bit):bat[:any_1] 
 address CMDBATnew;
-comment Creates a new empty transient BAT, with head- and tail-types as 
indicated.
-
-pattern bat.new(tt:any_1,size:lng):bat[:any_1] 
-address CMDBATnewColumn;
-comment Creates a new empty transient BAT, with tail-types as indicated.
-
 pattern bat.new(tt:any_1,size:int):bat[:any_1] 
-address CMDBATnewColumn;
+address CMDBATnew;
 pattern bat.new(tt:any_1):bat[:any_1] 
-address CMDBATnewColumn;
+address CMDBATnew;
 pattern bat.orderidx(bv:bat[:any_1],l:bat[:any_1]...):void 
 address OIDXmerge;
 comment Consolidates the OID index arrangement
diff --git a/clients/Tests/MAL-signatures.stable.out.int128 
b/clients/Tests/MAL-signatures.stable.out.int128
--- a/clients/Tests/MAL-signatures.stable.out.int128
+++ b/clients/Tests/MAL-signatures.stable.out.int128
@@ -31785,34 +31785,18 @@ command bat.mirror(b:bat[:any_2]):bat[:o
 address BKCmirror;
 comment Returns the head-mirror image of a BAT (two head columns).
 
-pattern bat.new_persistent(ht:oid,tt:any_1,size:lng):bat[:any_1] 
-address CMDBATnew_persistent;
-comment Creates a new BAT in the persistent farm and allocate space.
-
-pattern bat.new_persistent(ht:oid,tt:any_1,size:int):bat[:any_1] 
-address CMDBATnew_persistent;
-pattern bat.new_persistent(ht:oid,tt:any_1):bat[:any_1] 
-address CMDBATnew_persistent;
-comment Creates a new empty transient BAT in the persistent farm, with head- 
and tail-types as indicated.
-
-pattern bat.new(ht:oid,tt:any_1,size:lng):bat[:any_1] 
+pattern bat.new(tt:any_1,size:lng):bat[:any_1] 
 address CMDBATnew;
-comment Creates a new BAT with sufficient space.
-
-pattern bat.new(ht:oid,tt:any_1,size:int):bat[:any_1] 
+comment Creates a new empty transient BAT, with tail-types as indicated.
+
+pattern bat.new(tt:any_1,size:int,persist:bit):bat[:any_1] 
 address CMDBATnew;
-pattern bat.new(ht:oid,tt:any_1):bat[:any_1] 
+pattern bat.new(tt:any_1,size:lng,persist:bit):bat[:any_1] 
 address CMDBATnew;
-comment Creates a new empty transient BAT, with head- and tail-types as 
indicated.
-
-pattern bat.new(tt:any_1,size:lng):bat[:any_1] 
-address CMDBATnewColumn;
-comment Creates a new empty transient BAT, with tail-types as indicated.
-
 pattern bat.new(tt:any_1,size:int):bat[:any_1] 
-address CMDBATnewColumn;
+address CMDBATnew;
 pattern bat.new(tt:any_1):bat[:any_1] 
-address CMDBATnewColumn;
+address CMDBATnew;
 pattern bat.orderidx(bv:bat[:any_1],l:bat[:any_1]...):void 
 address OIDXmerge;
 comment Consolidates the OID index arrangement
diff --git a/monetdb5/optimizer/opt_mergetable.c 
b/monetdb5/optimizer/opt_mergetable.c
--- a/monetdb5/optimizer/opt_mergetable.c
+++ b/monetdb5/optimizer/opt_mergetable.c
@@ -1859,7 +1859,8 @@ cleanup:
     }
     /* keep all actions taken as a post block comment */
     snprintf(buf,256,"%-20s actions=%2d time=" LLFMT " 
usec","mergetable",actions,GDKusec() - usec);
-    newComment(mb,buf);
+    if ( mb->errors == 0) 
+        newComment(mb,buf);
 
        return actions;
 }
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
@@ -1847,6 +1847,32 @@ rel_push_topn_down(int *changes, mvc *sq
 
                if (r && r->op == op_project && need_distinct(r)) 
                        return rel;
+               /* duplicate topn direct under union */
+
+               if (r && r->exps && r->op == op_union && !(rel_is_ref(r)) && 
r->l) {
+                       sql_rel *u = r, *x;
+                       sql_rel *ul = u->l;
+                       sql_rel *ur = u->r;
+
+                       /* only push topn once */
+                       x = ul;
+                       while(x->op == op_project && x->l)
+                               x = x->l;
+                       if (x && x->op == op_topn)
+                               return rel;
+                       x = ur;
+                       while(x->op == op_project && x->l)
+                               x = x->l;
+                       if (x && x->op == op_topn)
+                               return rel;
+
+                       ul = rel_topn(sql->sa, ul, sum_limit_offset(sql, 
rel->exps));
+                       ur = rel_topn(sql->sa, ur, sum_limit_offset(sql, 
rel->exps));
+                       u->l = ul;
+                       u->r = ur;
+                       (*changes)++;
+                       return rel;
+               }
                /* duplicate topn + [ project-order ] under union */
                if (r)
                        rp = r->l;
diff --git 
a/sql/test/BugTracker-2009/Tests/segfault_when_quitting_debugger.SF-2538837.stable.out
 
b/sql/test/BugTracker-2009/Tests/segfault_when_quitting_debugger.SF-2538837.stable.out
--- 
a/sql/test/BugTracker-2009/Tests/segfault_when_quitting_debugger.SF-2538837.stable.out
+++ 
b/sql/test/BugTracker-2009/Tests/segfault_when_quitting_debugger.SF-2538837.stable.out
@@ -22,7 +22,7 @@ Ready.
 
 #debug select * from tables;
 mdb>#X_1=0@0:void := user.s1_1();
-mdb>#X_159=0@0:void := querylog.define("debug select * from 
tables;","default_pipe",631);
+mdb>#X_159=0@0:void := querylog.define("debug select * from 
tables;","default_pipe",375);
 
 # 16:24:01 >  
 # 16:24:01 >  "Done."
diff --git a/sql/test/bugs/Tests/select_select_bug.stable.out 
b/sql/test/bugs/Tests/select_select_bug.stable.out
--- a/sql/test/bugs/Tests/select_select_bug.stable.out
+++ b/sql/test/bugs/Tests/select_select_bug.stable.out
@@ -29,7 +29,7 @@ Ready.
 #SELECT (SELECT current_timestamp), count(DISTINCT mmsi) FROM vessels;
 % .L1, sys.L2 # table_name
 % L1,  L2 # name
-% tinyint,     wrd # type
+% tinyint,     bigint # type
 % 1,   1 # length
 [ 1,   0       ]
 #drop table vessels;
diff --git a/sql/test/mergetables/Tests/part-elim.stable.out 
b/sql/test/mergetables/Tests/part-elim.stable.out
--- a/sql/test/mergetables/Tests/part-elim.stable.out
+++ b/sql/test/mergetables/Tests/part-elim.stable.out
@@ -79,6 +79,72 @@ project (
 | | table(sys.mt2) [ test.id, test.posx, test.%TID% NOT NULL ] COUNT 
 | ) [ bigint "1" <= test.id <= bigint "1000" ]
 ) [ test.id, test.posx ]
+#declare l integer;
+#set l = 1;
+#declare h integer;
+#set h = 10000;
+#plan select * from test where id between l and h;
+% .plan # table_name
+% rel # name
+% clob # type
+% 106 # length
+union (
+| project (
+| | select (
+| | | table(sys.mt1) [ mt1.id as test.id, mt1.posx as test.posx, mt1.%TID% NOT 
NULL as test.%TID% ] COUNT 
+| | ) [ bigint[l] <= test.id <= bigint[h] ]
+| ) [ test.id, test.posx ],
+| project (
+| | select (
+| | | table(sys.mt2) [ mt2.id as test.id, mt2.posx as test.posx, mt2.%TID% NOT 
NULL as test.%TID% ] COUNT 
+| | ) [ bigint[l] <= test.id <= bigint[h] ]
+| ) [ test.id, test.posx ]
+) [ test.id, test.posx ]
+#set h = 1000;
+#plan select * from test where id between l and h;
+% .plan # table_name
+% rel # name
+% clob # type
+% 69 # length
+project (
+| select (
+| | table(sys.mt2) [ test.id, test.posx, test.%TID% NOT NULL ] COUNT 
+| ) [ bigint[l] <= test.id <= bigint[h] ]
+) [ test.id, test.posx ]
+#plan select * from test where id between 1 and 1000*10;
+% .plan # table_name
+% rel # name
+% clob # type
+% 106 # length
+union (
+| project (
+| | select (
+| | | table(sys.mt1) [ mt1.id as test.id, mt1.posx as test.posx, mt1.%TID% NOT 
NULL as test.%TID% ] COUNT 
+| | ) [ bigint "1" <= test.id <= bigint[sys.sql_mul(smallint "1000", tinyint 
"10")] ]
+| ) [ test.id, test.posx ],
+| project (
+| | select (
+| | | table(sys.mt2) [ mt2.id as test.id, mt2.posx as test.posx, mt2.%TID% NOT 
NULL as test.%TID% ] COUNT 
+| | ) [ bigint "1" <= test.id <= bigint[sys.sql_mul(smallint "1000", tinyint 
"10")] ]
+| ) [ test.id, test.posx ]
+) [ test.id, test.posx ]
+#plan select * from test where id between 1 and 100*10;
+% .plan # table_name
+% rel # name
+% clob # type
+% 106 # length
+union (
+| project (
+| | select (
+| | | table(sys.mt1) [ mt1.id as test.id, mt1.posx as test.posx, mt1.%TID% NOT 
NULL as test.%TID% ] COUNT 
+| | ) [ bigint "1" <= test.id <= bigint[sys.sql_mul(smallint "100", tinyint 
"10")] ]
+| ) [ test.id, test.posx ],
+| project (
+| | select (
+| | | table(sys.mt2) [ mt2.id as test.id, mt2.posx as test.posx, mt2.%TID% NOT 
NULL as test.%TID% ] COUNT 
+| | ) [ bigint "1" <= test.id <= bigint[sys.sql_mul(smallint "100", tinyint 
"10")] ]
+| ) [ test.id, test.posx ]
+) [ test.id, test.posx ]
 #drop table test;
 #drop table mt1;
 #drop table mt2;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to