summaryrefslogtreecommitdiff
path: root/ext/mysqli/mysqli_api.c
diff options
context:
space:
mode:
authorKeyur Govande <keyur@php.net>2015-01-07 23:23:26 +0000
committerKeyur Govande <keyur@php.net>2015-01-07 23:23:26 +0000
commit961da40809a8a01d76a52f93f6c20a4d6e5aeec2 (patch)
tree28a818161d667985c4f8a96118b0ff9136d7ca58 /ext/mysqli/mysqli_api.c
parent3e826c97366044991ae3c892e00d607449f69d66 (diff)
parent39f8960b17f658dd0af340e972e632833d2640f9 (diff)
downloadphp-git-961da40809a8a01d76a52f93f6c20a4d6e5aeec2.tar.gz
Merge branch 'PHP-5.6'
* PHP-5.6: Add NEWS 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: ext/mysqli/mysqli_api.c
Diffstat (limited to 'ext/mysqli/mysqli_api.c')
-rw-r--r--ext/mysqli/mysqli_api.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c
index 698e6bb5ba..7ea4d6a1a0 100644
--- a/ext/mysqli/mysqli_api.c
+++ b/ext/mysqli/mysqli_api.c
@@ -33,6 +33,7 @@
#include "zend_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,9 +414,18 @@ mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval *args, unsigned int argc, un
col_type = (stmt->stmt->fields) ? stmt->stmt->fields[ofs].type : MYSQL_TYPE_STRING;
switch (col_type) {
- case MYSQL_TYPE_DOUBLE:
case MYSQL_TYPE_FLOAT:
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:
+ stmt->result.buf[ofs].type = IS_DOUBLE;
stmt->result.buf[ofs].buflen = sizeof(double);
/* allocate buffer for double */
@@ -1021,8 +1031,22 @@ void mysqli_stmt_fetch_libmysql(INTERNAL_FUNCTION_PARAMETERS)
}
break;
case IS_DOUBLE:
- ZVAL_DOUBLE(result, *(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(result, dval);
break;
+ }
case IS_STRING:
if (stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_LONGLONG
#if MYSQL_VERSION_ID > 50002