diff options
Diffstat (limited to 'ext/mysqli')
-rw-r--r-- | ext/mysqli/mysqli.c | 2 | ||||
-rw-r--r-- | ext/mysqli/mysqli_api.c | 31 | ||||
-rw-r--r-- | ext/mysqli/mysqli_driver.c | 2 | ||||
-rw-r--r-- | ext/mysqli/mysqli_embedded.c | 2 | ||||
-rw-r--r-- | ext/mysqli/mysqli_exception.c | 2 | ||||
-rw-r--r-- | ext/mysqli/mysqli_fe.c | 2 | ||||
-rw-r--r-- | ext/mysqli/mysqli_fe.h | 2 | ||||
-rw-r--r-- | ext/mysqli/mysqli_libmysql.h | 2 | ||||
-rw-r--r-- | ext/mysqli/mysqli_nonapi.c | 2 | ||||
-rw-r--r-- | ext/mysqli/mysqli_priv.h | 2 | ||||
-rw-r--r-- | ext/mysqli/mysqli_prop.c | 2 | ||||
-rw-r--r-- | ext/mysqli/mysqli_report.c | 2 | ||||
-rw-r--r-- | ext/mysqli/mysqli_result_iterator.c | 2 | ||||
-rw-r--r-- | ext/mysqli/mysqli_warning.c | 2 | ||||
-rw-r--r-- | ext/mysqli/php_mysqli.h | 2 | ||||
-rw-r--r-- | ext/mysqli/php_mysqli_structs.h | 2 | ||||
-rw-r--r-- | ext/mysqli/tests/010.phpt | 6 | ||||
-rw-r--r-- | ext/mysqli/tests/bug67839.phpt | 18 |
18 files changed, 59 insertions, 26 deletions
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index f13958897..91a7ee768 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2014 The PHP Group | + | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index 309d9b9f0..72c029ebc 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2014 The PHP Group | + | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -33,6 +33,7 @@ #include "ext/standard/php_smart_str.h" #include "php_mysqli_structs.h" #include "mysqli_priv.h" +#include "ext/mysqlnd/mysql_float_to_double.h" #if !defined(MYSQLI_USE_MYSQLND) @@ -413,10 +414,20 @@ mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval ***args, unsigned int argc, col_type = (stmt->stmt->fields) ? stmt->stmt->fields[ofs].type : MYSQL_TYPE_STRING; switch (col_type) { - case MYSQL_TYPE_DOUBLE: case MYSQL_TYPE_FLOAT: convert_to_double_ex(args[i]); stmt->result.buf[ofs].type = IS_DOUBLE; + stmt->result.buf[ofs].buflen = sizeof(float); + + stmt->result.buf[ofs].val = (char *)emalloc(sizeof(float)); + bind[ofs].buffer_type = MYSQL_TYPE_FLOAT; + bind[ofs].buffer = stmt->result.buf[ofs].val; + bind[ofs].is_null = &stmt->result.is_null[ofs]; + break; + + case MYSQL_TYPE_DOUBLE: + convert_to_double_ex(args[i]); + stmt->result.buf[ofs].type = IS_DOUBLE; stmt->result.buf[ofs].buflen = sizeof(double); /* allocate buffer for double */ @@ -1053,8 +1064,22 @@ void mysqli_stmt_fetch_libmysql(INTERNAL_FUNCTION_PARAMETERS) } break; case IS_DOUBLE: - ZVAL_DOUBLE(stmt->result.vars[i], *(double *)stmt->result.buf[i].val); + { + double dval; + if (stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_FLOAT) { +#ifndef NOT_FIXED_DEC +# define NOT_FIXED_DEC 31 +#endif + dval = mysql_float_to_double(*(float *)stmt->result.buf[i].val, + (stmt->stmt->fields[i].decimals >= NOT_FIXED_DEC) ? -1 : + stmt->stmt->fields[i].decimals); + } else { + dval = *((double *)stmt->result.buf[i].val); + } + + ZVAL_DOUBLE(stmt->result.vars[i], dval); break; + } case IS_STRING: if (stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_LONGLONG #if MYSQL_VERSION_ID > 50002 diff --git a/ext/mysqli/mysqli_driver.c b/ext/mysqli/mysqli_driver.c index d90d37c2e..05d5adf19 100644 --- a/ext/mysqli/mysqli_driver.c +++ b/ext/mysqli/mysqli_driver.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2014 The PHP Group | + | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqli/mysqli_embedded.c b/ext/mysqli/mysqli_embedded.c index e56e936f6..c81a043e5 100644 --- a/ext/mysqli/mysqli_embedded.c +++ b/ext/mysqli/mysqli_embedded.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2014 The PHP Group | + | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqli/mysqli_exception.c b/ext/mysqli/mysqli_exception.c index 82cf5cd7b..8409c20e1 100644 --- a/ext/mysqli/mysqli_exception.c +++ b/ext/mysqli/mysqli_exception.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2014 The PHP Group | + | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqli/mysqli_fe.c b/ext/mysqli/mysqli_fe.c index e099fe719..6c2c3822f 100644 --- a/ext/mysqli/mysqli_fe.c +++ b/ext/mysqli/mysqli_fe.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2014 The PHP Group | + | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqli/mysqli_fe.h b/ext/mysqli/mysqli_fe.h index 9a9f85124..95da5d6bb 100644 --- a/ext/mysqli/mysqli_fe.h +++ b/ext/mysqli/mysqli_fe.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2014 The PHP Group | + | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqli/mysqli_libmysql.h b/ext/mysqli/mysqli_libmysql.h index 5e7f730ae..6e3486b83 100644 --- a/ext/mysqli/mysqli_libmysql.h +++ b/ext/mysqli/mysqli_libmysql.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2014 The PHP Group | + | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c index de5cd567b..2ee6c9eee 100644 --- a/ext/mysqli/mysqli_nonapi.c +++ b/ext/mysqli/mysqli_nonapi.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2014 The PHP Group | + | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqli/mysqli_priv.h b/ext/mysqli/mysqli_priv.h index b1bfb56a8..18295f3da 100644 --- a/ext/mysqli/mysqli_priv.h +++ b/ext/mysqli/mysqli_priv.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2014 The PHP Group | + | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqli/mysqli_prop.c b/ext/mysqli/mysqli_prop.c index 2d3633637..7d77fd9bf 100644 --- a/ext/mysqli/mysqli_prop.c +++ b/ext/mysqli/mysqli_prop.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2014 The PHP Group | + | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqli/mysqli_report.c b/ext/mysqli/mysqli_report.c index bdd3adaf5..a679bef68 100644 --- a/ext/mysqli/mysqli_report.c +++ b/ext/mysqli/mysqli_report.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2014 The PHP Group | + | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqli/mysqli_result_iterator.c b/ext/mysqli/mysqli_result_iterator.c index a84060316..d1834b382 100644 --- a/ext/mysqli/mysqli_result_iterator.c +++ b/ext/mysqli/mysqli_result_iterator.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2014 The PHP Group | + | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqli/mysqli_warning.c b/ext/mysqli/mysqli_warning.c index 7a35a7e8c..60d15bfe7 100644 --- a/ext/mysqli/mysqli_warning.c +++ b/ext/mysqli/mysqli_warning.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2014 The PHP Group | + | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqli/php_mysqli.h b/ext/mysqli/php_mysqli.h index e036cf42b..3d22104c3 100644 --- a/ext/mysqli/php_mysqli.h +++ b/ext/mysqli/php_mysqli.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2014 The PHP Group | + | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqli/php_mysqli_structs.h b/ext/mysqli/php_mysqli_structs.h index 0f3eb64d3..d061bfb21 100644 --- a/ext/mysqli/php_mysqli_structs.h +++ b/ext/mysqli/php_mysqli_structs.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2014 The PHP Group | + | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysqli/tests/010.phpt b/ext/mysqli/tests/010.phpt index 83a43e06b..b1712ca2a 100644 --- a/ext/mysqli/tests/010.phpt +++ b/ext/mysqli/tests/010.phpt @@ -62,7 +62,7 @@ mysqli_close($link); --EXPECT-- array(7) { [0]=> - float(3.141593) + float(3.14159) [1]=> float(-1.0E-6) [2]=> @@ -70,10 +70,10 @@ array(7) { [3]=> float(1.0E+12) [4]=> - float(0.5646425) + float(0.564642) [5]=> float(1) [6]=> - float(8.888889E+14) + float(8.88889E+14) } done! diff --git a/ext/mysqli/tests/bug67839.phpt b/ext/mysqli/tests/bug67839.phpt index b2821a21b..aadce9310 100644 --- a/ext/mysqli/tests/bug67839.phpt +++ b/ext/mysqli/tests/bug67839.phpt @@ -36,19 +36,27 @@ mysqli_float_handling - ensure 4 byte float is handled correctly die(); } - if (!mysqli_stmt_execute($stmt)) { + $id = null; + $fp4 = null; + $fp8 = null; + + if (!mysqli_stmt_bind_result($stmt, $id, $fp4, $fp8)) { printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); die(); } - - if (!($result = mysqli_stmt_get_result($stmt))) { + if (!mysqli_stmt_execute($stmt)) { printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); die(); } - $data = mysqli_fetch_assoc($result); - print $data['id'] . ": " . $data['fp4'] . ": " . $data['fp8'] . "\n"; + + if (!(mysqli_stmt_fetch($stmt))) { + printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + die(); + } + + print $id . ": " . $fp4 . ": " . $fp8 . "\n"; ?> --CLEAN-- <?php |