Update of /cvsroot/monetdb/sql/src/backends/monet5
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv3783/src/backends/monet5

Modified Files:
      Tag: Aug2009
        sql.mx 
Log Message:
fix overflow bug



U sql.mx
Index: sql.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql.mx,v
retrieving revision 1.347.2.2
retrieving revision 1.347.2.3
diff -u -d -r1.347.2.2 -r1.347.2.3
--- sql.mx      14 Aug 2009 14:19:59 -0000      1.347.2.2
+++ sql.mx      17 Sep 2009 20:28:00 -0000      1.347.2.3
@@ -669,7 +669,7 @@
 
 command calc.second_interval( v:@1, ek:int, sk:int ) :lng
 address second_interv...@1
-comment "cast @1 to a month_interval and check for overflow";
+comment "cast @1 to a second_interval and check for overflow";
 @mal
 
 @:mal_interval(str)@
@@ -678,6 +678,7 @@
 @:mal_interval(int)@
 @:mal_interval(wrd)@
 @:mal_interval(lng)@
+@:mal_interval(daytime)@
 
 command calc.rowid(v:any_1, schema:str, table:str) :oid
 address sql_rowid
@@ -1047,6 +1048,7 @@
 @:c_interval_export(int)@
 @:c_interval_export(wrd)@
 @:c_interval_export(lng)@
+@:c_interval_export(daytime)@
 @= simpleupcast_export
 sql5_export str @2...@1( @1 *res, @2 *v );
 sql5_export str b...@2_2_@1( int *res, int *v );
@@ -1323,7 +1325,6 @@
        str msg = getContext(cntxt,mb, &m, NULL);
        int *ret  = (int *) getArgReference(stk, pci, 0);
 
-       (void) cntxt;
        if (msg)
                return msg;
        *ret = 0;
@@ -1337,7 +1338,6 @@
        str msg = getContext(cntxt,mb, &m, NULL);
        int *ret  = (int *) getArgReference(stk, pci, 0);
 
-       (void) cntxt;
        if (msg)
                return msg;
        *ret = 0;
@@ -2699,7 +2699,7 @@
                        lres = (((*v + rnd)/scales[dff])*scales[dff]);
                else
                        lres = (((*v - rnd)/scales[dff])*scales[dff]);
-               assert((lng) g...@1_min <= lres && lres <= (lng) g...@1_max);
+               assert((lng) g...@1_min < lres && lres <= (lng) g...@1_max);
                *res = (@1) lres;
        } else if (*r <= 0 && -*r + *s > 0) {
                int dff = -*r + *s;
@@ -2709,7 +2709,7 @@
                        lres = (((*v + rnd)/scales[dff])*scales[dff]);
                else
                        lres = (((*v - rnd)/scales[dff])*scales[dff]);
-               assert((lng) g...@1_min <= lres && lres <= (lng) g...@1_max);
+               assert((lng) g...@1_min < lres && lres <= (lng) g...@1_max);
                *res = (@1) lres;
        } else {
                *res = *v;
@@ -3116,7 +3116,8 @@
        }
        
        /* see if the number fits in the data type */
-       if (val >= (@3) g...@1_min && val <= (@3) g...@1_max)   {
+       if ((@3)(@1)val > (@3) g...@1_min && 
+           val > (@3) g...@1_min && val <= (@3) g...@1_max)    {
                *res = (@1)val;
                return(MAL_SUCCEED);
        } else {
@@ -3564,7 +3565,7 @@
        if (scale) 
                val = (val+h)/scales[scale];
        /* see if the number fits in the data type */
-       if (val >= g...@1_min && val <= g...@1_max)     {
+       if (val > g...@1_min && val <= g...@1_max)      {
                *res = (@1)val;
                return MAL_SUCCEED;
        } else {
@@ -3602,7 +3603,7 @@
                val = (val+h)/scales[s1-s2];
 
        /* see if the number fits in the data type */
-       if (val >= g...@1_min && val <= g...@1_max)     {
+       if (val > g...@1_min && val <= g...@1_max)      {
                *res = (@1)val;
                return MAL_SUCCEED;
        } else {
@@ -3779,6 +3780,33 @@
 @:c_interval(wrd)@
 @:c_interval(lng)@
 
+str
+second_interval_daytime( lng *res, daytime *s, int *d, int *sk )
+{
+       int k = digits2sk(*d);
+       lng r = *(int*)s;
+
+       (void)sk;
+       switch(k) {
+       case isec:
+               r /= 1000;
+               break;
+       case imin:
+               r /= 60000;
+               break;
+       case ihour:
+               r /= 3600000;
+               break;
+       case iday:      
+               r /= (24*3600000);
+               break;
+       default:
+               throw(ILLARG, "calc.second_interval","illegal argument");
+       }
+       *res = r;
+       return MAL_SUCCEED;
+}
+
 /* str dump_cache(int *r); */
 str
 dump_cache(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to