summaryrefslogtreecommitdiff
path: root/libmysql
diff options
context:
space:
mode:
authorunknown <georg@lmy002.wdf.sap.corp>2005-04-11 12:25:44 +0200
committerunknown <georg@lmy002.wdf.sap.corp>2005-04-11 12:25:44 +0200
commitb3a2a3d6d9c7a5af17f4d7fa3fb7e72f64edf3d0 (patch)
treef32760a58288e6c3f782899667426a64bf957a00 /libmysql
parent44dcec99b17283bd84c8333fcd70470c90160116 (diff)
downloadmariadb-git-b3a2a3d6d9c7a5af17f4d7fa3fb7e72f64edf3d0.tar.gz
Fix for verification tests: truncation of post digits should not return an error
Diffstat (limited to 'libmysql')
-rw-r--r--libmysql/libmysql.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 14517e4f770..073b330ec34 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -3656,6 +3656,7 @@ 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.
@@ -3688,7 +3689,7 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field,
*buffer= (uint8) value;
else
*buffer= (int8) value;
- *param->error= value != (param->is_unsigned ? (double) ((uint8) *buffer) :
+ *param->error= MY_TRUNC(value) != (param->is_unsigned ? (double) ((uint8) *buffer) :
(double) ((int8) *buffer));
break;
case MYSQL_TYPE_SHORT:
@@ -3702,7 +3703,7 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field,
short data= (short) value;
shortstore(buffer, data);
}
- *param->error= value != (param->is_unsigned ? (double) (*(ushort*) buffer):
+ *param->error= MY_TRUNC(value) != (param->is_unsigned ? (double) (*(ushort*) buffer):
(double) (*(short*) buffer));
break;
case MYSQL_TYPE_LONG:
@@ -3716,7 +3717,7 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field,
int32 data= (int32) value;
longstore(buffer, data);
}
- *param->error= value != (param->is_unsigned ? (double) (*(uint32*) buffer):
+ *param->error= MY_TRUNC(value) != (param->is_unsigned ? (double) (*(uint32*) buffer):
(double) (*(int32*) buffer));
break;
case MYSQL_TYPE_LONGLONG:
@@ -3730,7 +3731,7 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field,
longlong data= (longlong) value;
longlongstore(buffer, data);
}
- *param->error= value != (param->is_unsigned ?
+ *param->error= MY_TRUNC(value) != (param->is_unsigned ?
ulonglong2double(*(ulonglong*) buffer) :
(double) (*(longlong*) buffer));
break;