Update of /cvsroot/monetdb/sql/src/server
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv18804/src/server

Modified Files:
        sql_atom.mx sql_parser.mx 
Log Message:
propagated changes of Wednesday Feb 07 2007 - Friday Feb 09 2007
from the SQL_2-16 branch to the development trunk



Index: sql_parser.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_parser.mx,v
retrieving revision 1.236
retrieving revision 1.237
diff -u -d -r1.236 -r1.237
--- sql_parser.mx       4 Feb 2007 22:55:17 -0000       1.236
+++ sql_parser.mx       9 Feb 2007 23:19:39 -0000       1.237
@@ -509,7 +509,8 @@
        opt_cache
        opt_cycle
        opt_ref_action
-       ref_on
+       ref_on_delete
+        ref_on_update
        with_or_without_data
        trigger_action_time
        opt_for_each
@@ -1561,15 +1562,20 @@
  |     SET DEFAULT             { $$ = 4; }
  ;
 
-ref_on:
-   ON UPDATE ref_action                { $$ = ($3 << 8); }
- | ON sqlDELETE ref_action     { $$ = $3; }
+ref_on_update:
+   ON UPDATE ref_action         { $$ = ($3 << 8); }
+;
+
+ref_on_delete:
+   ON sqlDELETE ref_action      { $$ = $3; }
  ;
 
 opt_ref_action:
-   /* empty */         { $$ = (2 << 8) + 2; /* defaults are RESTRICT */ }
- | ref_on              { $$ = $1; }
- | ref_on ref_on       { $$ = $1 + $2; }
+   /* empty */                          { $$ = (2 << 8) + 2; /* defaults are 
RESTRICT */ }
+ | ref_on_update                        { $$ = $1; }
+ | ref_on_delete                        { $$ = $1; }
+ | ref_on_delete ref_on_update          { $$ = $1 + $2; }
+ | ref_on_update ref_on_delete          { $$ = $1 + $2; }
  ;
 
 opt_match_type:

Index: sql_atom.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_atom.mx,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- sql_atom.mx 4 Feb 2007 22:55:17 -0000       1.51
+++ sql_atom.mx 9 Feb 2007 23:19:39 -0000       1.52
@@ -380,6 +380,27 @@
        return na;
 }
 
+static lng scales[] = {
+       1,
+       10,
+       100,
+       1000,
+       10000,
+       100000,
+       1000000,
+       10000000,
+       100000000,
+       1000000000,
+       10000000000,
+       100000000000,
+       1000000000000,
+       10000000000000,
+       100000000000000,
+       1000000000000000,
+       10000000000000000,
+       100000000000000000,
+       1000000000000000000
+};
 /* cast atom a to type tp (success == 1, fail == 0) */
 int 
 atom_cast(atom *a, sql_subtype *tp) 
@@ -419,6 +440,42 @@
                        a->data.vtype = tp->type->localtype;
                        return 1;
                }
+               if (at->type->eclass == EC_DEC && tp->type->eclass == EC_DEC &&
+                   at->type->localtype <= tp->type->localtype &&
+                   at->type->digits <= tp->type->digits &&
+                   at->type->scale <= tp->type->scale) {
+                       lng mul = 1;
+                       /* cast numerics */
+                       switch( tp->type->localtype) {
+                       case TYPE_int:
+                               if (at->type->localtype == TYPE_sht) 
+                                       a->data.val.ival = a->data.val.shval;
+                               else
+                                       return 0;
+                               break;
+                       case TYPE_lng:
+                               if (at->type->localtype == TYPE_sht) 
+                                       a->data.val.lval = a->data.val.shval;
+                               else if (at->type->localtype == TYPE_int) 
+                                       a->data.val.lval = a->data.val.ival;
+                               else
+                                       return 0;
+                               break;
+                       default:
+                               return 0;
+                       }
+                       a->tpe = *tp;
+                       a->data.vtype = tp->type->localtype;
+                       /* fix scale */
+                       mul = scales[tp->type->scale-at->type->scale];
+                       if (a->data.vtype == TYPE_lng)
+                               a->data.val.lval *= mul;
+                       else if (a->data.vtype == TYPE_int)
+                               a->data.val.ival *= mul;
+                       else if (a->data.vtype == TYPE_sht)
+                               a->data.val.shval *= mul;
+                       return 1;
+               }
                if (at->type->eclass == EC_DEC && tp->type->eclass == EC_FLT) {
                        if (a->d == dbl_nil) {
                                ptr p = &a->d;


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to