Update of /cvsroot/monetdb/sql/src/server
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv17567
Modified Files:
Tag: SQL_2-16
sql_atom.mx
Log Message:
check (inplace) conversion of decimal types. THis solves the prepare
with decimals bug.
Index: sql_atom.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_atom.mx,v
retrieving revision 1.50.2.1
retrieving revision 1.50.2.2
diff -u -d -r1.50.2.1 -r1.50.2.2
--- sql_atom.mx 4 Feb 2007 17:03:16 -0000 1.50.2.1
+++ sql_atom.mx 9 Feb 2007 21:07:40 -0000 1.50.2.2
@@ -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