Changeset: 781dfc8f4295 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=781dfc8f4295
Added Files:
sql/test/BugTracker-2014/Tests/orderby_on_constant.Bug-3554.sql
sql/test/BugTracker-2014/Tests/orderby_on_constant.Bug-3554.stable.err
sql/test/BugTracker-2014/Tests/orderby_on_constant.Bug-3554.stable.out
Modified Files:
monetdb5/mal/Tests/tst866.stable.out
monetdb5/modules/kernel/bat5.c
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_statement.c
sql/test/BugTracker-2014/Tests/All
Branch: default
Log Message:
Merge with Oct2014 branch.
diffs (300 lines):
diff --git a/monetdb5/mal/Tests/tst866.stable.out
b/monetdb5/mal/Tests/tst866.stable.out
--- a/monetdb5/mal/Tests/tst866.stable.out
+++ b/monetdb5/mal/Tests/tst866.stable.out
@@ -74,7 +74,7 @@ end main;
#-----------------#
[ 0@0, 0@0 ]
[ 1@0, 8@0 ]
-[ 2@0, 7@0 ]
+[ 2@0, 6@0 ]
[ 3@0, 3@0 ]
[ 4@0, 4@0 ]
[ 5@0, 5@0 ]
diff --git a/monetdb5/modules/kernel/bat5.c b/monetdb5/modules/kernel/bat5.c
--- a/monetdb5/modules/kernel/bat5.c
+++ b/monetdb5/modules/kernel/bat5.c
@@ -2204,9 +2204,10 @@ BKCshrinkBATmap(int *ret, int *bid, int
Type *r = (Type*)Tloc(bn, BUNfirst(bn)); \
for (;p<q; oidx++, p++) {
\
if ( *o == oidx ){
\
- while ( *ol == bidx && ol>o) { \
+ while ( ol>o && ol[-1] == bidx) { \
bidx--;
\
- ol--;q--;
\
+ q--;
\
+ ol--;
\
}
\
*r++ = *(--q);
\
o += (o < ol);
\
@@ -2233,7 +2234,7 @@ BKCreuseBAT(int *ret, int *bid, int *did
BBPreleaseref(b->batCacheid);
throw(MAL, "bat.reuse", RUNTIME_OBJECT_MISSING);
}
- bn= BATnew(b->htype, b->ttype, BATcount(b) - BATcount(d) , TRANSIENT);
+ bn= BATnew(b->htype, b->ttype, BATcount(b) - BATcount(d), TRANSIENT);
if (bn == NULL) {
BBPreleaseref(b->batCacheid);
BBPreleaseref(d->batCacheid);
@@ -2247,9 +2248,10 @@ BKCreuseBAT(int *ret, int *bid, int *did
throw(MAL, "bat.reuse", MAL_MALLOC_FAIL );
}
- bidx= BUNlast(b)-1;
+ oidx = b->hseqbase;
+ bidx = oidx + BATcount(b)-1;
o = (oid*)Tloc(bs, BUNfirst(bs));
- ol= (oid*)Tloc(bs, BUNlast(bs))-1;
+ ol= (oid*)Tloc(bs, BUNlast(bs));
switch(ATOMstorage(b->ttype) ){
case TYPE_bte: reuseloop(bte); break;
@@ -2271,15 +2273,17 @@ BKCreuseBAT(int *ret, int *bid, int *did
for (;p<q; oidx++, p++) {
if ( *o == oidx ){
- while ( *ol == bidx && ol>o) {
+ while ( ol > o && ol[-1] == bidx) {
bidx--;
- ol--;q--;
+ q--;
+ ol--;
}
BUNappend(bn, BUNtail(bi, --q), FALSE);
o += (o < ol);
bidx--;
- } else
+ } else {
BUNappend(bn, BUNtail(bi, p), FALSE);
+ }
}
} else {
switch( b->T->width){
@@ -2310,6 +2314,7 @@ BKCreuseBAT(int *ret, int *bid, int *did
BBPkeepref(*ret= bn->batCacheid);
return MAL_SUCCEED;
}
+
str
BKCreuseBATmap(int *ret, int *bid, int *did)
{
@@ -2328,7 +2333,7 @@ BKCreuseBATmap(int *ret, int *bid, int *
BBPreleaseref(b->batCacheid);
throw(MAL, "bat.shrinkMap", RUNTIME_OBJECT_MISSING);
}
- bn= BATnew(TYPE_void, TYPE_oid, BATcount(b) , TRANSIENT);
+ bn= BATnew(TYPE_void, TYPE_oid, BATcount(b) - BATcount(d), TRANSIENT);
if (bn == NULL) {
BBPreleaseref(b->batCacheid);
BBPreleaseref(d->batCacheid);
@@ -2342,21 +2347,24 @@ BKCreuseBATmap(int *ret, int *bid, int *
throw(MAL, "bat.shrinkMap", MAL_MALLOC_FAIL );
}
- bidx= BUNlast(b)-1;
- o = (oid*)Tloc(bs, BUNfirst(bs));
- ol= (oid*)Tloc(bs, BUNlast(bs));
- r = (oid*)Tloc(bn, BUNfirst(bn));
+ oidx = b->hseqbase;
+ bidx = oidx + BATcount(b)-1;
+ o = (oid*)Tloc(bs, BUNfirst(bs));
+ ol = (oid*)Tloc(bs, BUNlast(bs));
+ r = (oid*)Tloc(bn, BUNfirst(bn));
- for (;oidx<bidx; oidx++) {
+ for (; oidx <= bidx; oidx++) {
if ( *o == oidx ){
- while ( ol > o && *--ol == bidx) {
+ while ( ol > o && ol[-1] == bidx) {
bidx--;
+ ol--;
}
*r++ = bidx;
o += (o < ol);
bidx--;
- } else
+ } else {
*r++ = oidx;
+ }
}
BATsetcount(bn, BATcount(b)-BATcount(bs));
diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -2306,6 +2306,8 @@ rel2bin_project( mvc *sql, sql_rel *rel,
if (!orderbycolstmt)
return NULL;
+ /* handle constants */
+ orderbycolstmt = column(sql->sa, orderbycolstmt);
if (!limit) { /* topn based on a single column */
limit = stmt_limit(sql->sa, orderbycolstmt,
stmt_atom_wrd(sql->sa, 0), l, LIMIT_FLAG(distinct, is_ascending(orderbycole),
last, 1));
} else { /* topn based on 2 columns */
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -4193,6 +4193,11 @@ vacuum(Client cntxt, MalBlkPtr mb, MalSt
/* get the deletions BAT */
del = mvc_bind_dbat(m, *sch, *tbl, RD_INS);
+ if (BATcount(del) == 0) {
+ BBPreleaseref(del->batCacheid);
+ return MAL_SUCCEED;
+ }
+
i = 0;
bids[i] = 0;
@@ -4220,6 +4225,7 @@ vacuum(Client cntxt, MalBlkPtr mb, MalSt
BBPdecref(bids[i], TRUE);
throw(SQL, name, "Too many columns to handle, use copy
instead");
}
+ BBPreleaseref(del->batCacheid);
mvc_clear_table(m, t);
for (o = t->columns.set->h, i = 0; o; o = o->next, i++) {
@@ -4302,13 +4308,15 @@ SQLvacuum(Client cntxt, MalBlkPtr mb, Ma
/* get the deletions BAT */
del = mvc_bind_dbat(m, *sch, *tbl, RD_INS);
- /* now decide on the algorithm */
- if (ordered) {
- if (BATcount(del) > cnt / 20)
- SQLshrink(cntxt, mb, stk, pci);
- } else
- SQLreuse(cntxt, mb, stk, pci);
-
+ if (BATcount(del) > 0) {
+ /* now decide on the algorithm */
+ if (ordered) {
+ if (BATcount(del) > cnt / 20)
+ SQLshrink(cntxt, mb, stk, pci);
+ } else {
+ SQLreuse(cntxt, mb, stk, pci);
+ }
+ }
BBPreleaseref(del->batCacheid);
return MAL_SUCCEED;
}
diff --git a/sql/backends/monet5/sql_statement.c
b/sql/backends/monet5/sql_statement.c
--- a/sql/backends/monet5/sql_statement.c
+++ b/sql/backends/monet5/sql_statement.c
@@ -1719,6 +1719,9 @@ const_column(sql_allocator *sa, stmt *va
s->op1 = val;
s->op4.typeval = *ct;
s->nrcols = 1;
+
+ s->tname = val->tname;
+ s->cname = val->cname;
return s;
}
diff --git a/sql/test/BugTracker-2014/Tests/All
b/sql/test/BugTracker-2014/Tests/All
--- a/sql/test/BugTracker-2014/Tests/All
+++ b/sql/test/BugTracker-2014/Tests/All
@@ -22,7 +22,7 @@ local-temp-2.Bug-3468
select_in_crash.Bug-3491
boolean_not.Bug-3505
varchar_conversion_crash.Bug-3506
-bug_in_cse.Bug-3511
+HAVE_GEOM?bug_in_cse.Bug-3511
stringfloatshtcompare.Bug-3512
oid-table-assert.Bug-3514
round-properties.Bug-3515
@@ -36,3 +36,5 @@ round.Bug-3542
number_4_4.Bug-3543
ifthenelse.Bug-3546
subselect-reverse.Bug-3552
+orderby_on_constant.Bug-3554
+div_by_zero_in_return.Bug-3555
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
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2014/Tests/orderby_on_constant.Bug-3554.sql
@@ -0,0 +1,1 @@
+select a+b from (select 1 as a,1 as b) as q order by a limit 1;
diff --git
a/sql/test/BugTracker-2014/Tests/orderby_on_constant.Bug-3554.stable.err
b/sql/test/BugTracker-2014/Tests/orderby_on_constant.Bug-3554.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2014/Tests/orderby_on_constant.Bug-3554.stable.err
@@ -0,0 +1,37 @@
+stderr of test 'orderby_on_constant.Bug-3554` in directory
'sql/test/BugTracker-2014` itself:
+
+
+# 19:40:06 >
+# 19:40:06 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=31986" "--set"
"mapi_usock=/var/tmp/mtest-21225/.s.monetdb.31986" "--set" "monet_prompt="
"--forcemito" "--set" "mal_listing=2"
"--dbpath=/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2014"
"--set" "mal_listing=0" "--set" "embedded_r=yes"
+# 19:40:06 >
+
+# builtin opt gdk_dbpath =
/home/niels/scratch/rc-monetdb/Linux-x86_64/var/monetdb5/dbfarm/demo
+# builtin opt gdk_debug = 0
+# builtin opt gdk_vmtrim = no
+# builtin opt monet_prompt = >
+# builtin opt monet_daemon = no
+# builtin opt mapi_port = 50000
+# builtin opt mapi_open = false
+# builtin opt mapi_autosense = false
+# builtin opt sql_optimizer = default_pipe
+# builtin opt sql_debug = 0
+# cmdline opt gdk_nr_threads = 0
+# cmdline opt mapi_open = true
+# cmdline opt mapi_port = 31986
+# cmdline opt mapi_usock = /var/tmp/mtest-21225/.s.monetdb.31986
+# cmdline opt monet_prompt =
+# cmdline opt mal_listing = 2
+# cmdline opt gdk_dbpath =
/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2014
+# cmdline opt mal_listing = 0
+# cmdline opt embedded_r = yes
+# cmdline opt gdk_debug = 536870922
+
+# 19:40:07 >
+# 19:40:07 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-21225" "--port=31986"
+# 19:40:07 >
+
+
+# 19:40:07 >
+# 19:40:07 > "Done."
+# 19:40:07 >
+
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
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2014/Tests/orderby_on_constant.Bug-3554.stable.out
@@ -0,0 +1,38 @@
+stdout of test 'orderby_on_constant.Bug-3554` in directory
'sql/test/BugTracker-2014` itself:
+
+
+# 19:40:06 >
+# 19:40:06 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=31986" "--set"
"mapi_usock=/var/tmp/mtest-21225/.s.monetdb.31986" "--set" "monet_prompt="
"--forcemito" "--set" "mal_listing=2"
"--dbpath=/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2014"
"--set" "mal_listing=0" "--set" "embedded_r=yes"
+# 19:40:06 >
+
+# MonetDB 5 server v11.19.0
+# This is an unreleased version
+# Serving database 'mTests_sql_test_BugTracker-2014', using 4 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs dynamically
linked
+# Found 7.334 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2014 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://localhost.nes.nl:31986/
+# Listening for UNIX domain connection requests on
mapi:monetdb:///var/tmp/mtest-21225/.s.monetdb.31986
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+# MonetDB/R module loaded
+
+Ready.
+
+# 19:40:07 >
+# 19:40:07 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-21225" "--port=31986"
+# 19:40:07 >
+
+#select a+b from (select 1 as a,1 as b) as q order by a limit 1;
+% .L1 # table_name
+% L1 # name
+% smallint # type
+% 1 # length
+[ 2 ]
+
+# 19:40:07 >
+# 19:40:07 > "Done."
+# 19:40:07 >
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list