diff options
author | unknown <georg@lmy002.wdf.sap.corp> | 2005-04-12 08:51:26 +0200 |
---|---|---|
committer | unknown <georg@lmy002.wdf.sap.corp> | 2005-04-12 08:51:26 +0200 |
commit | 39ed5c447d06a94c167081bca135329923875f87 (patch) | |
tree | 4ff6d60a96aa018c1bdd24dd268275f9cfbebdc5 /libmysql | |
parent | b8188fedf3245eadaf9233b19f9cd425afda55cc (diff) | |
download | mariadb-git-39ed5c447d06a94c167081bca135329923875f87.tar.gz |
Fix for verification tests: loss of decimal places should not
return an error
Diffstat (limited to 'libmysql')
-rw-r--r-- | libmysql/libmysql.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 073b330ec34..dbdaadf86bf 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -3656,8 +3656,6 @@ static void fetch_long_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, } } -#define MY_TRUNC(val) (val < 0 ? - floor(-val) : floor(val)) - /* Convert double/float column to supplied buffer of any type. @@ -3674,6 +3672,7 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, double value, int width) { char *buffer= (char *)param->buffer; + double val64 = (value < 0 ? -floor(-value) : floor(value)); switch (param->buffer_type) { case MYSQL_TYPE_NULL: /* do nothing */ @@ -3689,8 +3688,8 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, *buffer= (uint8) value; else *buffer= (int8) value; - *param->error= MY_TRUNC(value) != (param->is_unsigned ? (double) ((uint8) *buffer) : - (double) ((int8) *buffer)); + *param->error= val64 != (param->is_unsigned ? (double)((uint8) *buffer) : + (double)((int8) *buffer)); break; case MYSQL_TYPE_SHORT: if (param->is_unsigned) @@ -3703,7 +3702,7 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, short data= (short) value; shortstore(buffer, data); } - *param->error= MY_TRUNC(value) != (param->is_unsigned ? (double) (*(ushort*) buffer): + *param->error= val64 != (param->is_unsigned ? (double) (*(ushort*) buffer): (double) (*(short*) buffer)); break; case MYSQL_TYPE_LONG: @@ -3717,7 +3716,7 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, int32 data= (int32) value; longstore(buffer, data); } - *param->error= MY_TRUNC(value) != (param->is_unsigned ? (double) (*(uint32*) buffer): + *param->error= val64 != (param->is_unsigned ? (double) (*(uint32*) buffer): (double) (*(int32*) buffer)); break; case MYSQL_TYPE_LONGLONG: @@ -3731,7 +3730,7 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, longlong data= (longlong) value; longlongstore(buffer, data); } - *param->error= MY_TRUNC(value) != (param->is_unsigned ? + *param->error= val64 != (param->is_unsigned ? ulonglong2double(*(ulonglong*) buffer) : (double) (*(longlong*) buffer)); break; |