diff options
author | Alexey Kopytov <Alexey.Kopytov@sun.com> | 2009-01-28 20:59:08 +0300 |
---|---|---|
committer | Alexey Kopytov <Alexey.Kopytov@sun.com> | 2009-01-28 20:59:08 +0300 |
commit | 30ac49019d5feb98747d0fc880afe9296397d6b7 (patch) | |
tree | 962a3f82ee7d0566806f3cb9f83f5b70d6ca86a6 /libmysql | |
parent | 2048bd711797c6197233fa8d36598d0c8d0ef593 (diff) | |
download | mariadb-git-30ac49019d5feb98747d0fc880afe9296397d6b7.tar.gz |
Fix for bug #21205: Different number of digits for float/double/real in --ps-protocol
Various parts of code used different 'precision' arguments for sprintf("%g") when converting
floating point numbers to a string. This led to differences in results in some cases
depending on whether the text-based or prepared statements protocol is used for a query.
Fixed by changing arguments to sprintf("%g") to always be 15 (DBL_DIG) so that results are
consistent regardless of the protocol.
This patch will be null-merged to 6.0 as the problem does not exists there (fixed by the
patch for WL#2934).
Diffstat (limited to 'libmysql')
-rw-r--r-- | libmysql/libmysql.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index dd66a325169..2a5e1cc657b 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -3786,13 +3786,13 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, #undef NOT_FIXED_DEC { /* - The 14 below is to ensure that the server and client has the same + DBL_DIG below is to ensure that the server and client has the same precisions. This will ensure that on the same machine you get the same value as a string independent of the protocol you use. */ sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1, param->buffer_length), - min(14,width), value); + min(DBL_DIG, width), value); end= strcend(buff, ' '); *end= 0; } |