Update of /cvsroot/monetdb/sql/src/backends/monet5
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18447/src/backends/monet5
Modified Files:
sql.mx
Log Message:
propagated changes of Thursday Mar 06 2008 - Friday Mar 07 2008
from the SQL_2-22 branch to the development trunk
===================================================================
2008/03/06 - nielsnes: src/backends/monet4/sql_server.mx,1.189.2.6
src/backends/monet5/sql.mx,1.251.2.4
fixed bug [ 1907063 ] ms_round....
The round function for dbl, bte was missing
===================================================================
2008/03/06 - nielsnes: src/server/sql_mvc.mx,1.195.2.2
fixed bug [ 1907858 ] declaration of the second table in the function body
cased columns sometimes have no schema defined (declared tables). So we
cannot reuse the schema from it.
===================================================================
2008/03/06 - nielsnes: src/server/sql_psm.mx,1.50.2.1
src/server/sql_select.mx,1.219.2.6
fixes for the bugs
[ 1907905 ] coalesce = coalesce...
(added some more checks for semantic problems)
and
[ 1907006 ] range select....
Properly interpret 0<id>10 as a boolean (0<id) followed by the selection
criteria (bool > 10).
===================================================================
2008/03/06 - nielsnes: src/Tests/sigs.stable.out,1.75.2.1
approved output after new round function was added
===================================================================
Index: sql.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql.mx,v
retrieving revision 1.258
retrieving revision 1.259
diff -u -d -r1.258 -r1.259
--- sql.mx 5 Mar 2008 00:02:16 -0000 1.258
+++ sql.mx 7 Mar 2008 09:45:31 -0000 1.259
@@ -334,50 +334,34 @@
The aggregate operations work on doubles by default.
This calls for casting values around in the process.
+
@= mal_round
-command dec_round( v:@1, r:@1 ) :@1
+command sql.dec_round( v:@1, r:@1 ) :@1
address @1_dec_round_wrap
comment "round off the value v to nearests multiple of r";
-
-command round( v:@1, d:int, s:int, r:bte) :@1
+command sql.round( v:@1, d:int, s:int, r:bte) :@1
address @1_round_wrap
comment "round off the decimal v(d,s) to r digits behind the dot (if r < 0,
before the dot)";
[EMAIL PROTECTED]
[EMAIL PROTECTED]
-command dec_round( v:@1, r:dbl ) :@1
-address @1_dbl_dec_round_wrap
-comment "round off the value v to nearests multiple of r";
-command dec_round( v:@1, r:int ) :@1
-address @1_int_dec_round_wrap
-comment "round off the value v to nearests multiple of r";
[EMAIL PROTECTED]
[EMAIL PROTECTED]
-
-command aggr.exist(b:bat[:any_1,:any_2], h:any_1):bit
-address ALGexist;
[EMAIL PROTECTED]
@:mal_round(bte)@
@:mal_round(sht)@
@:mal_round(int)@
@:mal_round(lng)@
-command dec_round( v:flt, r:flt ) :flt
-address flt_flt_dec_round_wrap
[EMAIL PROTECTED] mal_fround
+command sql.dec_round( v:@1, r:@1 ) :@1
+address @1_dec_round_wrap
comment "round off the value v to nearests multiple of r";
-command dec_round( v:dbl, r:dbl ) :dbl
-address dbl_dbl_dec_round_wrap
-comment "round off the value v to nearests multiple of r";
[EMAIL PROTECTED]
[EMAIL PROTECTED]
-command dec_round( v:flt, r:int ) :flt
-address flt_int_dec_round_wrap
-comment "round off the value v to nearests multiple of r";
-command dec_round( v:dbl, r:int ) :dbl
-address dbl_int_dec_round_wrap
-comment "round off the value v to nearests multiple of r";
[EMAIL PROTECTED]
+command sql.round( v:@1, r:bte) :@1
+address @1_round_wrap
+comment "round off the floating point v to r digits behind the dot (if r < 0,
before the dot)";
+
[EMAIL PROTECTED]
+@:mal_fround(flt)@
+@:mal_fround(dbl)@
@= mal_cast
command [EMAIL PROTECTED]( v:str ) :@1
@@ -568,6 +552,9 @@
address sql_dense_rank
comment "return the densely ranked bat";
+command aggr.exist(b:bat[:any_1,:any_2], h:any_1):bit
+address ALGexist;
+
function batcalc.mark_grp( b:bat[:oid,:any_1], a:bat[:any_2,:any_3],
g:bat[:oid,:oid]) :bat[:oid,:int];
x := algebra.mark_grp(a,g,1:oid);
return batcalc.int(x);
@@ -764,8 +751,6 @@
sql5_export str dump_opt_stats(int *r);
@= round_export
sql5_export str @1_dec_round_wrap( @1 *res, @1 *v, @1 *r );
-sql5_export str @1_dbl_dec_round_wrap( @1 *res, @1 *v, dbl *r );
-sql5_export str @1_int_dec_round_wrap( @1 *res, @1 *v, int *r );
sql5_export str @1_round_wrap( @1 *res, @1 *v, int *d, int *s, bte *r );
sql5_export str [EMAIL PROTECTED]( @1 *res, str *val, int *d, int *sc );
sql5_export str [EMAIL PROTECTED]( @1 *res, str *v, int *len );
@@ -796,12 +781,11 @@
sql5_export str SQLstr_cast(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
sql5_export str SQLbatstr_cast(int *r, int *eclass, int *d1, int *s1, int
*has_tz, int *v, int *digits );
@= fround_export
-sql5_export str @[EMAIL PROTECTED]( @1 *res, @1 *v, @2 *r );
+sql5_export str @1_dec_round_wrap( @1 *res, @1 *v, @1 *r );
+sql5_export str @1_round_wrap( @1 *res, @1 *v, bte *r );
@h
-@:fround_export(flt,flt)@
-@:fround_export(flt,int)@
-@:fround_export(dbl,dbl)@
-@:fround_export(dbl,int)@
+@:fround_export(flt)@
+@:fround_export(dbl)@
@= c_interval_export
sql5_export str [EMAIL PROTECTED]( int *ret, @1 *s, int *ek, int *sk );
sql5_export str [EMAIL PROTECTED]( lng *res, @1 *s, int *ek, int *sk );
@@ -897,6 +881,7 @@
#include <sql_datetime.h>
#include <rel_optimizer.h>
#include <rel_bin.h>
+#include <math.h>
backend *
backend_reset(backend *b)
@@ -2071,31 +2056,19 @@
*res = (((*v + rnd)/scales[dff])*scales[dff]);
else
*res = (((*v - rnd)/scales[dff])*scales[dff]);
- } else if (*r <= 0) {
+ } else if (*r <= 0 && -*r + *s > 0) {
int dff = -*r + *s;
lng rnd = scales[dff]>>1;
if (*v > 0)
*res = (((*v + rnd)/scales[dff])*scales[dff]);
else
*res = (((*v - rnd)/scales[dff])*scales[dff]);
+ } else {
+ *res = *v;
}
return MAL_SUCCEED;
}
-str
[EMAIL PROTECTED]( @1 *res, @1 *v, dbl *r )
-{
- @1 add = *r; /* lossy conversion */
- return @1_dec_round_wrap(res,v, &add);
-}
-
-str
[EMAIL PROTECTED]( @1 *res, @1 *v, int *r )
-{
- @1 add = *r; /* lossy conversion */
- return @1_dec_round_wrap(res,v, &add);
-}
-
str
[EMAIL PROTECTED]( @1 *res, str *val, int *d, int *sc )
{
@@ -2212,7 +2185,7 @@
@= fround
str
[EMAIL PROTECTED]@2_dec_round_wrap( @1 *res, @1 *v, @2 *r )
[EMAIL PROTECTED]( @1 *res, @1 *v, @1 *r )
{
@1 val = *v;
@@ -2223,11 +2196,37 @@
*res = val;
return MAL_SUCCEED;
}
+
+str
[EMAIL PROTECTED]( @1 *res, @1 *v, bte *r )
+{
+ /* shortcut nil */
+ if (*v == @1_nil) {
+ *res = @1_nil;
+ } else if (*r < 0) {
+ int d = -*r;
+ @1 rnd = scales[d]>>1;
+
+ if (*v > 0)
+ *res = (floor(((*v +
rnd)/((@1)(scales[d]))))*scales[d]);
+ else
+ *res = (floor(((*v +
rnd)/((@1)(scales[d]))))*scales[d]);
+ } else if (*r > 0) {
+ int d = *r;
+
+ if (*v > 0)
+ *res = (floor(*v*(@1)scales[d]+.5)/scales[d]);
+ else
+ *res = (floor(*v*(@1)scales[d]+.5)/scales[d]);
+ } else {
+ *res = *v;
+ }
+ return MAL_SUCCEED;
+}
+
@c
-@:fround(flt,flt)@
-@:fround(flt,int)@
-@:fround(dbl,dbl)@
-@:fround(dbl,int)@
+@:fround(flt)@
+@:fround(dbl)@
@= cast
str
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins