summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2014-08-16 11:16:56 +0200
committerAnatol Belski <ab@php.net>2014-08-16 11:16:56 +0200
commitf790043e30513c56f108289ec44ea6eb493f7773 (patch)
treedb11d035d21d7b099dbd3a122fc9822b8c6bbd14
parent8ee2a4a9b5de682c0b37670e1f4f86242b1650ce (diff)
parentd790eceb01009489358c3781c94ebea3b3400f67 (diff)
downloadphp-git-f790043e30513c56f108289ec44ea6eb493f7773.tar.gz
Merge branch 'master' of git.php.net:php-src
# By Keyur Govande (6) and Xinchen Hui (4) # Via Keyur Govande (5) and Xinchen Hui (2) * 'master' of git.php.net:php-src: Fixed version id Update NEWS Update NEWS Fix another failing test Add NEWS Better version checking Better version checking Better version checking Fix failing tests Patch for bug #67839 (mysqli does not handle 4-byte floats correctly)
-rw-r--r--ext/intl/collator/collator_convert.c2
-rw-r--r--ext/mysqli/mysqli.c2
-rw-r--r--ext/mysqli/tests/010.phpt12
-rw-r--r--ext/mysqli/tests/011.phpt4
-rw-r--r--ext/mysqli/tests/012.phpt4
-rw-r--r--ext/mysqli/tests/bug67839.phpt58
-rw-r--r--ext/mysqli/tests/mysqli_change_user.phpt28
-rw-r--r--ext/mysqli/tests/mysqli_change_user_old.phpt10
-rw-r--r--ext/mysqli/tests/mysqli_change_user_oo.phpt7
-rw-r--r--ext/mysqli/tests/mysqli_real_escape_string_gbk.phpt2
-rw-r--r--ext/mysqli/tests/table.inc7
-rw-r--r--ext/mysqlnd/config9.m426
-rw-r--r--ext/mysqlnd/mysqlnd_ps_codec.c49
-rw-r--r--ext/pdo/pdo_dbh.c2
-rwxr-xr-xext/phar/phar_object.c2
15 files changed, 191 insertions, 24 deletions
diff --git a/ext/intl/collator/collator_convert.c b/ext/intl/collator/collator_convert.c
index 1d8681582c..7d8bf0bbc8 100644
--- a/ext/intl/collator/collator_convert.c
+++ b/ext/intl/collator/collator_convert.c
@@ -28,7 +28,7 @@
#include <unicode/ustring.h>
#include <php.h>
-#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION <= 1)
+#if PHP_VERSION_ID <= 50100
#define CAST_OBJECT_SHOULD_FREE ,0
#else
#define CAST_OBJECT_SHOULD_FREE
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c
index fb93095c42..02e6898f7f 100644
--- a/ext/mysqli/mysqli.c
+++ b/ext/mysqli/mysqli.c
@@ -585,7 +585,7 @@ PHP_MINIT_FUNCTION(mysqli)
mysqli_object_handlers.write_property = mysqli_write_property;
mysqli_object_handlers.get_property_ptr_ptr = std_hnd->get_property_ptr_ptr;
mysqli_object_handlers.has_property = mysqli_object_has_property;
-#if PHP_VERSION_ID >= 53000
+#if PHP_VERSION_ID >= 50300
mysqli_object_handlers.get_debug_info = mysqli_object_get_debug_info;
#endif
memcpy(&mysqli_object_driver_handlers, &mysqli_object_handlers, sizeof(zend_object_handlers));
diff --git a/ext/mysqli/tests/010.phpt b/ext/mysqli/tests/010.phpt
index 60ff8eac19..83a43e06b6 100644
--- a/ext/mysqli/tests/010.phpt
+++ b/ext/mysqli/tests/010.phpt
@@ -62,18 +62,18 @@ mysqli_close($link);
--EXPECT--
array(7) {
[0]=>
- float(3.14159274101)
+ float(3.141593)
[1]=>
- float(-9.99999997475E-7)
+ float(-1.0E-6)
[2]=>
float(0)
[3]=>
- float(999999995904)
+ float(1.0E+12)
[4]=>
- float(0.564642488956)
+ float(0.5646425)
[5]=>
float(1)
[6]=>
- float(8.88888914608E+14)
+ float(8.888889E+14)
}
-done! \ No newline at end of file
+done!
diff --git a/ext/mysqli/tests/011.phpt b/ext/mysqli/tests/011.phpt
index db03abac83..b14516ff78 100644
--- a/ext/mysqli/tests/011.phpt
+++ b/ext/mysqli/tests/011.phpt
@@ -67,7 +67,7 @@ array(8) {
[3]=>
int(4999999)
[4]=>
- float(2345.60009766)
+ float(2345.6)
[5]=>
float(5678.89563)
[6]=>
@@ -75,4 +75,4 @@ array(8) {
[7]=>
%unicode|string%(11) "mysql rulez"
}
-done! \ No newline at end of file
+done!
diff --git a/ext/mysqli/tests/012.phpt b/ext/mysqli/tests/012.phpt
index 7cc34b0c00..91abae4850 100644
--- a/ext/mysqli/tests/012.phpt
+++ b/ext/mysqli/tests/012.phpt
@@ -66,7 +66,7 @@ array(8) {
[3]=>
int(54)
[4]=>
- float(2.59999990463)
+ float(2.6)
[5]=>
float(58.89)
[6]=>
@@ -74,4 +74,4 @@ array(8) {
[7]=>
%unicode|string%(3) "6.7"
}
-done! \ No newline at end of file
+done!
diff --git a/ext/mysqli/tests/bug67839.phpt b/ext/mysqli/tests/bug67839.phpt
new file mode 100644
index 0000000000..b2821a21bc
--- /dev/null
+++ b/ext/mysqli/tests/bug67839.phpt
@@ -0,0 +1,58 @@
+--TEST--
+mysqli_float_handling - ensure 4 byte float is handled correctly
+--SKIPIF--
+<?php
+ require_once('skipif.inc');
+ require_once('skipifemb.inc');
+ require_once('skipifconnectfailure.inc');
+?>
+--FILE--
+<?php
+ require('connect.inc');
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ die();
+ }
+
+
+ if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) {
+ printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ die();
+ }
+
+ if (!mysqli_query($link, "CREATE TABLE test(id INT PRIMARY KEY, fp4 FLOAT, fp8 DOUBLE) ENGINE = InnoDB")) {
+ printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ die();
+ }
+
+ // Insert via string to make sure the real floating number gets to the DB
+ if (!mysqli_query($link, "INSERT INTO test(id, fp4, fp8) VALUES (1, 9.9999, 9.9999)")) {
+ printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ die();
+ }
+
+ if (!($stmt = mysqli_prepare($link, "SELECT id, fp4, fp8 FROM test"))) {
+ printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ die();
+ }
+
+ if (!mysqli_stmt_execute($stmt)) {
+ printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ die();
+ }
+
+
+ if (!($result = mysqli_stmt_get_result($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";
+?>
+--CLEAN--
+<?php
+ require_once("clean_table.inc");
+?>
+--EXPECTF--
+1: 9.9999: 9.9999
diff --git a/ext/mysqli/tests/mysqli_change_user.phpt b/ext/mysqli/tests/mysqli_change_user.phpt
index 7a4530f0d5..09009a1368 100644
--- a/ext/mysqli/tests/mysqli_change_user.phpt
+++ b/ext/mysqli/tests/mysqli_change_user.phpt
@@ -42,10 +42,34 @@ require_once('skipifconnectfailure.inc');
if (false !== ($tmp = @mysqli_change_user($link, $user, $passwd . '_unknown_really', $db)))
printf("[009] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
+ // Reconnect because after 3 failed change_user attempts, the server blocks you off.
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- printf("[010] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ printf("[009a] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
+ if (!mysqli_query($link, 'SET @mysqli_change_user_test_var=1'))
+ printf("[010] Failed to set test variable: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (!$res = mysqli_query($link, 'SELECT @mysqli_change_user_test_var AS test_var'))
+ printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ $tmp = mysqli_fetch_assoc($res);
+ mysqli_free_result($res);
+ if (1 != $tmp['test_var'])
+ printf("[012] Cannot set test variable\n");
+
+ if (true !== ($tmp = mysqli_change_user($link, $user, $passwd, $db)))
+ printf("[013] Expecting true, got %s/%s\n", gettype($tmp), $tmp);
+
+ if (!$res = mysqli_query($link, 'SELECT database() AS dbname, user() AS user'))
+ printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ $tmp = mysqli_fetch_assoc($res);
+ mysqli_free_result($res);
+
+ if (substr($tmp['user'], 0, strlen($user)) !== $user)
+ printf("[015] Expecting user %s, got user() %s\n", $user, $tmp['user']);
+ if ($tmp['dbname'] != $db)
+ printf("[016] Expecting database %s, got database() %s\n", $db, $tmp['dbname']);
+
if (false !== ($tmp = @mysqli_change_user($link, $user, $passwd, $db . '_unknown_really')))
printf("[011] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
@@ -121,4 +145,4 @@ require_once('skipifconnectfailure.inc');
print "done!";
?>
--EXPECTF--
-done! \ No newline at end of file
+done!
diff --git a/ext/mysqli/tests/mysqli_change_user_old.phpt b/ext/mysqli/tests/mysqli_change_user_old.phpt
index ddb49cd189..96357ebf51 100644
--- a/ext/mysqli/tests/mysqli_change_user_old.phpt
+++ b/ext/mysqli/tests/mysqli_change_user_old.phpt
@@ -48,6 +48,14 @@ if (mysqli_get_server_version($link) >= 50600)
if (false !== ($tmp = mysqli_change_user($link, $user, $passwd, $db . '_unknown_really')))
printf("[009] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
+ // Reconnect because Percona and MariaDB block any commands after 3 failed
+ // change_user commands
+ mysqli_close($link);
+
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ printf("[020] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
+ }
if (!mysqli_query($link, 'SET @mysqli_change_user_test_var=1'))
printf("[010] Failed to set test variable: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
@@ -116,4 +124,4 @@ if (mysqli_get_server_version($link) >= 50600)
print "done!";
?>
--EXPECTF--
-done! \ No newline at end of file
+done!
diff --git a/ext/mysqli/tests/mysqli_change_user_oo.phpt b/ext/mysqli/tests/mysqli_change_user_oo.phpt
index 7ed2d08933..34a3e51bb1 100644
--- a/ext/mysqli/tests/mysqli_change_user_oo.phpt
+++ b/ext/mysqli/tests/mysqli_change_user_oo.phpt
@@ -46,6 +46,11 @@ if (mysqli_get_server_version($link) >= 50600)
if (false !== ($tmp = $mysqli->change_user($user, $passwd, $db . '_unknown_really')))
printf("[008] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
+ // Reconnect because after 3 failed change_user attempts, the server blocks you off.
+ if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
+ printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
+
if (!$mysqli->query('SET @mysqli_change_user_test_var=1'))
printf("[009] Failed to set test variable: [%d] %s\n", $mysqli->errno, $mysqli->error);
@@ -84,4 +89,4 @@ if (mysqli_get_server_version($link) >= 50600)
print "done!";
?>
--EXPECTF--
-done! \ No newline at end of file
+done!
diff --git a/ext/mysqli/tests/mysqli_real_escape_string_gbk.phpt b/ext/mysqli/tests/mysqli_real_escape_string_gbk.phpt
index 2fd1121a76..991d3c345b 100644
--- a/ext/mysqli/tests/mysqli_real_escape_string_gbk.phpt
+++ b/ext/mysqli/tests/mysqli_real_escape_string_gbk.phpt
@@ -36,7 +36,7 @@ $port, $socket, mysqli_connect_errno(), mysqli_connect_error());
mysqli_error($link));
}
- if (!mysqli_query($link, 'CREATE TABLE test(id INT, label CHAR(1), PRIMARY
+ if (!mysqli_query($link, 'CREATE TABLE test(id INT, label CHAR(3), PRIMARY
KEY(id)) ENGINE=' . $engine . " DEFAULT CHARSET=gbk")) {
printf("Failed to create test table: [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
diff --git a/ext/mysqli/tests/table.inc b/ext/mysqli/tests/table.inc
index cb089bb950..e0d7a06c57 100644
--- a/ext/mysqli/tests/table.inc
+++ b/ext/mysqli/tests/table.inc
@@ -12,6 +12,11 @@ if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) {
exit(1);
}
+if (!mysqli_query($link, 'SET SESSION sql_mode=\'\'')) {
+ printf("Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ exit(1);
+}
+
if (!mysqli_query($link, 'CREATE TABLE test(id INT DEFAULT 0, label CHAR(1), PRIMARY KEY(id)) ENGINE=' . $engine)) {
printf("Failed to create test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
exit(1);
@@ -20,4 +25,4 @@ if (!mysqli_query($link, 'CREATE TABLE test(id INT DEFAULT 0, label CHAR(1), PRI
if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES (1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f')")) {
printf("[%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
-?> \ No newline at end of file
+?>
diff --git a/ext/mysqlnd/config9.m4 b/ext/mysqlnd/config9.m4
index d94d217945..816f4431f5 100644
--- a/ext/mysqlnd/config9.m4
+++ b/ext/mysqlnd/config9.m4
@@ -49,3 +49,29 @@ fi
if test "$PHP_MYSQLND" != "no" || test "$PHP_MYSQLND_ENABLED" = "yes" || test "$PHP_MYSQLI" != "no"; then
PHP_ADD_BUILD_DIR([ext/mysqlnd], 1)
fi
+
+dnl
+dnl Check if the compiler supports Decimal32/64/128 types from the IEEE-754 2008 version
+dnl References: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1657.pdf
+dnl http://speleotrove.com/decimal/
+dnl
+AC_CACHE_CHECK([whether whether compiler supports Decimal32/64/128 types], ac_cv_decimal_fp_supported,[
+AC_TRY_RUN( [
+#include <stdio.h>
+
+int main(int argc, char **argv) {
+ typedef float dec32 __attribute__((mode(SD)));
+ dec32 k = 99.49f;
+ double d2 = (double)k;
+ return 0;
+}
+],[
+ ac_cv_decimal_fp_supported=yes
+],[
+ ac_cv_decimal_fp_supported=no
+],[
+ ac_cv_decimal_fp_supported=no
+])])
+if test "$ac_cv_decimal_fp_supported" = "yes"; then
+ AC_DEFINE(HAVE_DECIMAL_FP_SUPPORT, 1, [Define if the compiler supports Decimal32/64/128 types.])
+fi
diff --git a/ext/mysqlnd/mysqlnd_ps_codec.c b/ext/mysqlnd/mysqlnd_ps_codec.c
index e80aa5565e..746cf01a26 100644
--- a/ext/mysqlnd/mysqlnd_ps_codec.c
+++ b/ext/mysqlnd/mysqlnd_ps_codec.c
@@ -174,12 +174,53 @@ ps_fetch_int64(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_l
static void
ps_fetch_float(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row TSRMLS_DC)
{
- float value;
+ float fval;
+ double dval;
DBG_ENTER("ps_fetch_float");
- float4get(value, *row);
- ZVAL_DOUBLE(zv, value);
+ float4get(fval, *row);
(*row)+= 4;
- DBG_INF_FMT("value=%f", value);
+ DBG_INF_FMT("value=%f", fval);
+
+ /*
+ * The following is needed to correctly support 4-byte floats.
+ * Otherwise, a value of 9.99 in a FLOAT column comes out of mysqli
+ * as 9.9998998641968.
+ *
+ * For GCC, we use the built-in decimal support to "up-convert" a
+ * 4-byte float to a 8-byte double.
+ * When that is not available, we fall back to converting the float
+ * to a string and then converting the string to a double. This mimics
+ * what MySQL does.
+ */
+#ifdef HAVE_DECIMAL_FP_SUPPORT
+ {
+ typedef float dec32 __attribute__((mode(SD)));
+ dec32 d32val = fval;
+
+ /* The following cast is guaranteed to do the right thing */
+ dval = (double) d32val;
+ }
+#else
+ {
+ char num_buf[2048]; /* Over allocated */
+ char *s;
+
+ /* 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,
+ '.',
+ 'e',
+ num_buf);
+
+ /* And now convert back to double */
+ dval = zend_strtod(s, NULL);
+ }
+#endif
+
+ ZVAL_DOUBLE(zv, dval);
DBG_VOID_RETURN;
}
/* }}} */
diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c
index b2904118e8..cdf639a72d 100644
--- a/ext/pdo/pdo_dbh.c
+++ b/ext/pdo/pdo_dbh.c
@@ -1412,7 +1412,7 @@ void pdo_dbh_init(TSRMLS_D)
REGISTER_PDO_CLASS_CONST_LONG("FETCH_UNIQUE",(long)PDO_FETCH_UNIQUE);
REGISTER_PDO_CLASS_CONST_LONG("FETCH_KEY_PAIR",(long)PDO_FETCH_KEY_PAIR);
REGISTER_PDO_CLASS_CONST_LONG("FETCH_CLASSTYPE",(long)PDO_FETCH_CLASSTYPE);
-#if PHP_MAJOR_VERSION > 5 || PHP_MINOR_VERSION >= 1
+#if PHP_VERSION_ID >= 50100
REGISTER_PDO_CLASS_CONST_LONG("FETCH_SERIALIZE",(long)PDO_FETCH_SERIALIZE);
#endif
REGISTER_PDO_CLASS_CONST_LONG("FETCH_PROPS_LATE",(long)PDO_FETCH_PROPS_LATE);
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c
index 3d403fff57..e9acfe435b 100755
--- a/ext/phar/phar_object.c
+++ b/ext/phar/phar_object.c
@@ -30,7 +30,7 @@ static zend_class_entry *phar_ce_PharException;
static zend_class_entry *phar_ce_entry;
#endif
-#if PHP_MAJOR_VERSION > 5 || ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION >= 3))
+#if PHP_VERSION_ID >= 50300
# define PHAR_ARG_INFO
#else
# define PHAR_ARG_INFO static