com php-src: fix precision when fetching float through mysqlnd: ext/mysqlnd/mysqlnd_ps_codec.c

From: Date: Wed, 10 Sep 2014 17:29:11 +0000
Subject: com php-src: fix precision when fetching float through mysqlnd: ext/mysqlnd/mysqlnd_ps_codec.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-81496@lists.php.net to get a copy of this message
Commit: dff820cea3d51d3bfb925bd1a09cbb2ee741e2b3 Author: Anatol Belski <ab@php.net> Wed, 10 Sep 2014 19:29:11 +0200 Parents: 3b78a24ee987d8b99f9647b3695ee82dc5cbebe8 Branches: PHP-5.5 PHP-5.6 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=dff820cea3d51d3bfb925bd1a09cbb2ee741e2b3 Log: fix precision when fetching float through mysqlnd fixes failing ext/mysqli/tests/010.phpt Changed paths: M ext/mysqlnd/mysqlnd_ps_codec.c Diff: diff --git a/ext/mysqlnd/mysqlnd_ps_codec.c b/ext/mysqlnd/mysqlnd_ps_codec.c index fa4ed9d..d960912 100644 --- a/ext/mysqlnd/mysqlnd_ps_codec.c +++ b/ext/mysqlnd/mysqlnd_ps_codec.c @@ -200,17 +200,27 @@ ps_fetch_float(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_l /* The following cast is guaranteed to do the right thing */ dval = (double) d32val; } +#elif defined(PHP_WIN32) + { + /* float datatype on Winows is already 4 byte but has a precision of 7 digits */ + char num_buf[2048]; + (void)_gcvt_s(num_buf, 2048, fval, field->decimals >= 31 ? 7 : field->decimals); + dval = zend_strtod(num_buf, NULL); + } #else { char num_buf[2048]; /* Over allocated */ char *s; +#ifndef FLT_DIG +# define FLT_DIG 6 +#endif /* Convert to string. Ignoring localization, etc. * Following MySQL's rules. If precision is undefined (NOT_FIXED_DEC i.e. 31) * or larger than 31, the value is limited to 6 (FLT_DIG).. */ s = php_gcvt(fval, - field->decimals >= 31 ? 6 : field->decimals, + field->decimals >= 31 ? FLT_DIG : field->decimals, '.', 'e', num_buf);

« previous php.cvs (#81496) next »