MonetDB: Oct2014 - fixed reuse

Stefan Manegold Stefan.Manegold at cwi.nl
Tue Aug 26 11:23:29 CEST 2014


Niels,

this checkin adds "div_by_zero_in_return.Bug-3555"
(in addition to "orderby_on_constant.Bug-3554")
to sql/test/BugTracker-2014/Tests/All
but does not add the respective files (div_by_zero_in_return.Bug-3555.*).

Do you have these files ready, or should we remove 
"div_by_zero_in_return.Bug-3555" from sql/test/BugTracker-2014/Tests/All ?

The respective bug report is still open:
https://www.monetdb.org/bugzilla/show_bug.cgi?id=3555

Thanks!

Stefan

----- Original Message -----
> Changeset: 6c4080d30b3e for MonetDB
> URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6c4080d30b3e
> 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/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: Oct2014
> Log Message:
> 
> fixed reuse
> 
> fixed bug 3554, ie make sure single value order by /limit work
> 
> 
> diffs (254 lines):
> 
> 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
> @@ -2198,9 +2198,9 @@ 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 == bidx) {		\
>  					bidx--;							\
> -					ol--;q--;						\
> +					q--;						\
>  				}									\
>  				*r++ = *(--q);						\
>  				o += (o < ol);						\
> @@ -2241,9 +2241,10 @@ BKCreuseBAT(int *ret, int *bid, int *did
>  		throw(MAL, "bat.reuse", MAL_MALLOC_FAIL );
>  	}
>  
> -	bidx= BUNlast(b)-1;
> +	oidx = b->hseqbase;
> +	bidx = oidx + BUNlast(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;
> @@ -2262,15 +2263,16 @@ BKCreuseBAT(int *ret, int *bid, int *did
>  
>  			for (;p<q; oidx++, p++) {
>  				if ( *o == oidx ){
> -					while ( *ol == bidx && ol>o) {
> +					while ( ol > o && *--ol == bidx) {
>  						bidx--;
> -						ol--;q--;
> +						q--;
>  					}
>  					BUNappend(bn, BUNtail(bi, --q), FALSE);
>  					o += (o < ol);
>  					bidx--;
> -				} else
> +				} else {
>  					BUNappend(bn, BUNtail(bi, p), FALSE);
> +				}
>  			}
>  		} else {
>  			switch( b->T->width){
> @@ -2298,6 +2300,7 @@ BKCreuseBAT(int *ret, int *bid, int *did
>  	BBPkeepref(*ret= bn->batCacheid);
>  	return MAL_SUCCEED;
>  }
> +
>  str
>  BKCreuseBATmap(int *ret, int *bid, int *did)
>  {
> @@ -2330,10 +2333,11 @@ 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 + BUNlast(b)-1;
> +    	o  = (oid*)Tloc(bs, BUNfirst(bs));
> +    	ol = (oid*)Tloc(bs, BUNlast(bs));
> +    	r  = (oid*)Tloc(bn, BUNfirst(bn));
>  
>  	for (;oidx<bidx; oidx++) {
>  		if ( *o == oidx ){
> @@ -2343,8 +2347,9 @@ BKCreuseBATmap(int *ret, int *bid, int *
>  			*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
> @@ -4136,6 +4136,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;
> @@ -4163,6 +4168,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++) {
> @@ -4245,13 +4251,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
> @@ -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
> checkin-list at monetdb.org
> https://www.monetdb.org/mailman/listinfo/checkin-list
> 

-- 
| Stefan.Manegold at CWI.nl | DB Architectures   (DA) |
| www.CWI.nl/~manegold/  | Science Park 123 (L321) |
| +31 (0)20 592-4212     | 1098 XG Amsterdam  (NL) |




More information about the developers-list mailing list