Update of /cvsroot/monetdb/sql/src/backends/monet4
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18447/src/backends/monet4

Modified Files:
        sql_server.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_server.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet4/sql_server.mx,v
retrieving revision 1.195
retrieving revision 1.196
diff -u -d -r1.195 -r1.196
--- sql_server.mx       27 Feb 2008 17:51:42 -0000      1.195
+++ sql_server.mx       7 Mar 2008 09:45:31 -0000       1.196
@@ -164,10 +164,13 @@
 @:mel_round(int)@
 @:mel_round(lng)@
 
[EMAIL PROTECTED]
-       .COMMAND dec_round( flt v, flt r ) : flt = flt_dec_round_wrap; "round 
off the value v to nearests multiple of r"
[EMAIL PROTECTED] mel_fround
+       .COMMAND dec_round( @1 v, @1 r ) : @1 = @1_dec_round_wrap; "round off 
the value v to nearests multiple of r"
 
-       .COMMAND dec_round( dbl v, dbl r ) : dbl = dbl_dec_round_wrap; "round 
off the value v to nearests multiple of r"
+       .COMMAND round( @1 v, bte r ) : @1 = @1_round_wrap; "round off the 
decimal v(d,s) to r digits behind the dot (if r < 0, before the dot)"
[EMAIL PROTECTED]
+@:mel_fround(flt)@
+@:mel_fround(dbl)@
 
 @= mel_cast
  .COMMAND @1( str v ) : @1 = [EMAIL PROTECTED]; "cast to @1 and check for 
overflow"
@@ -312,6 +315,7 @@
 #include <algebra.h>
 #include "sql_storage.h"
 #include <store_sequence.h>
+#include <math.h>
 
 @-
 The code heavily depends on the (complex) data structures for
@@ -922,13 +926,15 @@
                        *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 GDK_SUCCEED;
 }
@@ -1005,6 +1011,33 @@
        *res = val;
        return GDK_SUCCEED;
 }
+
+int 
[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 GDK_SUCCEED;
+}
 @c
 @:fround(flt)@
 @:fround(dbl)@


-------------------------------------------------------------------------
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

Reply via email to