diff options
| author | Keyur Govande <keyur@php.net> | 2015-01-07 22:50:55 +0000 |
|---|---|---|
| committer | Keyur Govande <keyur@php.net> | 2015-01-07 22:50:55 +0000 |
| commit | 90144c0d083e9ecf390fc2a08ccb3c450d14ffab (patch) | |
| tree | 8c81d140f3eeaf994cf94205e8566117e810efd1 /ext/mysqli/mysqli_api.c | |
| parent | b0a26ab8f840ed1b48011caab3411c599f4451c5 (diff) | |
| parent | 9bbd55ddc7742b74152fd9339268c3340e6a08e5 (diff) | |
| download | php-git-90144c0d083e9ecf390fc2a08ccb3c450d14ffab.tar.gz | |
Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
Add NEWS
Patch commit d9f85373e32 by moving the float_to_double function to a header file.
Fix for bugs #68114 (Build fails on OS X due to undefined symbols) and #68657 (Reading 4 byte floats with Mysqli and libmysqlclient has rounding errors).
5.5.22 now
Conflicts:
configure.in
main/php_version.h
Diffstat (limited to 'ext/mysqli/mysqli_api.c')
| -rw-r--r-- | ext/mysqli/mysqli_api.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index 309d9b9f06..3aa7b21b4c 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -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 |
