From 686c74a671ff4e730f16668be90d625c4fca677f Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sat, 1 Oct 2022 15:00:37 +0200 Subject: [PATCH 1/3] Remove support for libmysql-client from mysqli test suite Since mysqli can no longer be built against libmysql-client, there is no longer the need to distinguish. --- ext/mysqli/tests/071.phpt | 36 +--- ext/mysqli/tests/bug38710.phpt | 2 +- ext/mysqli/tests/bug44897.phpt | 4 - ext/mysqli/tests/bug45019.phpt | 10 +- ext/mysqli/tests/bug45289.phpt | 5 +- ext/mysqli/tests/bug49442.phpt | 64 +++--- ext/mysqli/tests/bug51647.phpt | 2 +- ext/mysqli/tests/bug52891.phpt | 3 - ext/mysqli/tests/bug55283.phpt | 2 +- ext/mysqli/tests/bug62885.phpt | 3 - ext/mysqli/tests/bug63398.phpt | 3 - ext/mysqli/tests/bug64726.phpt | 3 - ext/mysqli/tests/bug67983.phpt | 3 - ext/mysqli/tests/bug68077.phpt | 3 - ext/mysqli/tests/bug69899.phpt | 3 - ext/mysqli/tests/bug70949.phpt | 3 - ext/mysqli/tests/bug71863.phpt | 3 - ext/mysqli/tests/bug77935.phpt | 3 - ext/mysqli/tests/connect.inc | 2 - ext/mysqli/tests/gh7837.phpt | 3 - ext/mysqli/tests/gh9590.phpt | 3 - .../tests/mysqli_change_user_insert_id.phpt | 4 - ext/mysqli/tests/mysqli_change_user_oo.phpt | 3 - .../tests/mysqli_class_mysqli_interface.phpt | 11 +- .../mysqli_class_mysqli_stmt_interface.phpt | 8 +- ext/mysqli/tests/mysqli_connect.phpt | 38 ++-- ext/mysqli/tests/mysqli_connect_attr.phpt | 3 - ext/mysqli/tests/mysqli_connect_oo.phpt | 28 ++- ext/mysqli/tests/mysqli_constants.phpt | 61 ++---- ext/mysqli/tests/mysqli_debug.phpt | 60 +++--- ext/mysqli/tests/mysqli_debug_append.phpt | 6 +- .../tests/mysqli_debug_control_string.phpt | 6 +- ext/mysqli/tests/mysqli_debug_ini.phpt | 3 - .../mysqli_debug_mysqlnd_control_string.phpt | 22 +-- .../tests/mysqli_debug_mysqlnd_only.phpt | 3 - ext/mysqli/tests/mysqli_expire_password.phpt | 4 - ext/mysqli/tests/mysqli_explain_metadata.phpt | 2 - ext/mysqli/tests/mysqli_fetch_array.phpt | 10 +- ext/mysqli/tests/mysqli_fetch_array_oo.phpt | 10 +- ext/mysqli/tests/mysqli_fetch_column.phpt | 3 - ext/mysqli/tests/mysqli_get_host_info.phpt | 2 +- ext/mysqli/tests/mysqli_kill.phpt | 10 +- .../tests/mysqli_mysqlnd_read_timeout.phpt | 3 - .../mysqli_mysqlnd_read_timeout_long.phpt | 4 - .../mysqli_mysqlnd_read_timeout_zero.phpt | 4 - ext/mysqli/tests/mysqli_no_reconnect.phpt | 19 +- ext/mysqli/tests/mysqli_options.phpt | 3 - .../mysqli_options_int_and_float_native.phpt | 3 - .../tests/mysqli_options_openbasedir.phpt | 10 +- ext/mysqli/tests/mysqli_phpinfo.phpt | 18 +- ext/mysqli/tests/mysqli_poll.phpt | 3 - ext/mysqli/tests/mysqli_poll_kill.phpt | 3 - .../mysqli_poll_mixing_insert_select.phpt | 3 - ext/mysqli/tests/mysqli_poll_reference.phpt | 3 - ext/mysqli/tests/mysqli_ps_select_union.phpt | 182 +++++++++--------- ext/mysqli/tests/mysqli_real_connect.phpt | 44 ++--- .../tests/mysqli_real_connect_pconn.phpt | 42 ++-- ext/mysqli/tests/mysqli_reap_async_query.phpt | 3 - .../mysqli_result_references_mysqlnd.phpt | 2 - ext/mysqli/tests/mysqli_stmt_bind_result.phpt | 8 +- .../tests/mysqli_stmt_execute_bind.phpt | 3 - .../mysqli_stmt_execute_stored_proc_out.phpt | 5 - ext/mysqli/tests/mysqli_stmt_multires.phpt | 3 - ext/mysqli/tests/mysqli_stmt_num_rows.phpt | 2 +- ...mt_send_long_data_packet_size_mysqlnd.phpt | 3 - .../tests/mysqli_store_result_copy.phpt | 3 - 66 files changed, 290 insertions(+), 546 deletions(-) diff --git a/ext/mysqli/tests/071.phpt b/ext/mysqli/tests/071.phpt index 8a5334d4609ad..39d8ba775942f 100644 --- a/ext/mysqli/tests/071.phpt +++ b/ext/mysqli/tests/071.phpt @@ -16,22 +16,8 @@ require_once('skipifconnectfailure.inc'); var_dump($mysql->ping()); $ret = $mysql->kill($mysql->thread_id); - if ($IS_MYSQLND) { - if ($ret !== true){ - printf("[001] Expecting boolean/true got %s/%s\n", gettype($ret), var_export($ret, true)); - } - } else { - /* libmysql return value seems to depend on server version */ - if ((($version >= 50123) || ($version <= 40200)) && $version != 50200) { - /* TODO: find exact version */ - if ($ret !== true){ - printf("[001] Expecting boolean/true got %s/%s @\n", gettype($ret), var_export($ret, true), $version); - } - } else { - if ($ret !== false){ - printf("[001] Expecting boolean/false got %s/%s @\n", gettype($ret), var_export($ret, true), $version); - } - } + if ($ret !== true){ + printf("[001] Expecting boolean/true got %s/%s\n", gettype($ret), var_export($ret, true)); } var_dump($mysql->ping()); @@ -43,22 +29,8 @@ require_once('skipifconnectfailure.inc'); var_dump(mysqli_ping($mysql)); $ret = $mysql->kill($mysql->thread_id); - if ($IS_MYSQLND) { - if ($ret !== true){ - printf("[002] Expecting boolean/true got %s/%s\n", gettype($ret), var_export($ret, true)); - } - } else { - /* libmysql return value seems to depend on server version */ - if ((($version >= 50123) || ($version <= 40200)) && $version != 50200) { - /* TODO: find exact version */ - if ($ret !== true){ - printf("[002] Expecting boolean/true got %s/%s @\n", gettype($ret), var_export($ret, true), $version); - } - } else { - if ($ret !== false){ - printf("[002] Expecting boolean/false got %s/%s @\n", gettype($ret), var_export($ret, true), $version); - } - } + if ($ret !== true){ + printf("[002] Expecting boolean/true got %s/%s\n", gettype($ret), var_export($ret, true)); } var_dump(mysqli_ping($mysql)); diff --git a/ext/mysqli/tests/bug38710.phpt b/ext/mysqli/tests/bug38710.phpt index 9c6c7c0fc44ec..9d50b9797a5f8 100644 --- a/ext/mysqli/tests/bug38710.phpt +++ b/ext/mysqli/tests/bug38710.phpt @@ -16,7 +16,7 @@ $qry->prepare("SELECT REPEAT('a',100000)"); $qry->execute(); $qry->bind_result($text); $qry->fetch(); -if ($text !== str_repeat('a', ($IS_MYSQLND || mysqli_get_server_version($db) > 50110)? 100000:(mysqli_get_server_version($db)>=50000? 8193:8191))) { +if ($text !== str_repeat('a', 100000)) { var_dump(strlen($text)); } echo "Done"; diff --git a/ext/mysqli/tests/bug44897.phpt b/ext/mysqli/tests/bug44897.phpt index 1ec80b0000f13..50177a72e5b1c 100644 --- a/ext/mysqli/tests/bug44897.phpt +++ b/ext/mysqli/tests/bug44897.phpt @@ -6,10 +6,6 @@ mysqli fetch()) { - /* NOTE: libmysql - http://bugs.mysql.com/bug.php?id=47483 */ if ($data[$index] != $column1) { - if ($IS_MYSQLND || $index != 1) { - printf("[004] Row %d, expecting %s/%s got %s/%s\n", - $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); - } else { - if ($column1 != "thre") - printf("[005] Got '%s'. Please check if http://bugs.mysql.com/bug.php?id=47483 has been fixed and adapt tests bug45019.phpt/mysqli_ps_select_union.phpt", $column1); - } + printf("[004] Row %d, expecting %s/%s got %s/%s\n", + $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); } $index++; } diff --git a/ext/mysqli/tests/bug45289.phpt b/ext/mysqli/tests/bug45289.phpt index 8a72e3517e403..eb5906810f20e 100644 --- a/ext/mysqli/tests/bug45289.phpt +++ b/ext/mysqli/tests/bug45289.phpt @@ -25,10 +25,7 @@ require_once('skipifconnectfailure.inc'); printf("[003] [%d] %s\n", $stmt->errno, $stmt->error); if ($res = $link->store_result()) { - if ($IS_MYSQLND) - printf("[004] Can store result!\n"); - else - printf("[004] [007] http://bugs.mysql.com/bug.php?id=47485\n"); + printf("[004] Can store result!\n"); } else { printf("[004] [%d] %s\n", $link->errno, $link->error); } diff --git a/ext/mysqli/tests/bug49442.phpt b/ext/mysqli/tests/bug49442.phpt index 748ab09f884ea..e5741ead4d595 100644 --- a/ext/mysqli/tests/bug49442.phpt +++ b/ext/mysqli/tests/bug49442.phpt @@ -63,45 +63,43 @@ mysqli.max_persistent=1 mysqli_query($link, "DELETE FROM test"); mysqli_close($link); - if ($IS_MYSQLND) { - /* - mysqlnd makes a connection created through mysql_init()/mysqli_real_connect() always a 'persistent' one. - At this point 'persistent' is not to be confused with what a user calls a 'persistent' - in this case - 'persistent' means that mysqlnd uses malloc() instead of emalloc(). nothing else. ext/mysqli will - not consider it as a 'persistent' connection in a user sense, ext/mysqli will not apply max_persistent etc. - It's only about malloc() vs. emalloc(). - - However, the bug is about malloc() and efree(). You can make mysqlnd use malloc() by either using - pconnect or mysql_init() - so we should test pconnect as well. - */ - $host = 'p:' . $host; - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { - printf("[007] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - } + /* + mysqlnd makes a connection created through mysql_init()/mysqli_real_connect() always a 'persistent' one. + At this point 'persistent' is not to be confused with what a user calls a 'persistent' - in this case + 'persistent' means that mysqlnd uses malloc() instead of emalloc(). nothing else. ext/mysqli will + not consider it as a 'persistent' connection in a user sense, ext/mysqli will not apply max_persistent etc. + It's only about malloc() vs. emalloc(). + + However, the bug is about malloc() and efree(). You can make mysqlnd use malloc() by either using + pconnect or mysql_init() - so we should test pconnect as well. + */ + $host = 'p:' . $host; + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { + printf("[007] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + } - /* bug happened during query processing */ - if (!@mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s' - INTO TABLE test - FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\'' - LINES TERMINATED BY '\n'", - mysqli_real_escape_string($link, $file)))) { - printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } + /* bug happened during query processing */ + if (!@mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s' + INTO TABLE test + FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\'' + LINES TERMINATED BY '\n'", + mysqli_real_escape_string($link, $file)))) { + printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } - /* we survived? that's good enough... */ + /* we survived? that's good enough... */ - if (!$res = mysqli_query($link, "SELECT * FROM test ORDER BY id")) - printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$res = mysqli_query($link, "SELECT * FROM test ORDER BY id")) + printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - $i = 0; - while ($row = mysqli_fetch_assoc($res)) { - if (($row['id'] != $rows[$i]['id']) || ($row['label'] != $rows[$i]['label'])) { - printf("[010] Wrong values, check manually!\n"); - } - $i++; + $i = 0; + while ($row = mysqli_fetch_assoc($res)) { + if (($row['id'] != $rows[$i]['id']) || ($row['label'] != $rows[$i]['label'])) { + printf("[010] Wrong values, check manually!\n"); } - mysqli_close($link); + $i++; } + mysqli_close($link); print "done!"; ?> diff --git a/ext/mysqli/tests/bug51647.phpt b/ext/mysqli/tests/bug51647.phpt index 38515245e7b0e..fb7312aebbec5 100644 --- a/ext/mysqli/tests/bug51647.phpt +++ b/ext/mysqli/tests/bug51647.phpt @@ -9,7 +9,7 @@ require_once "connect.inc"; if (!defined('MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT')) die("skip Requires MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT"); -if ($IS_MYSQLND && !extension_loaded("openssl")) +if (!extension_loaded("openssl")) die("skip PHP streams lack support for SSL. mysqli is compiled to use mysqlnd which uses PHP streams in turn."); if (!($link = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))) diff --git a/ext/mysqli/tests/bug52891.phpt b/ext/mysqli/tests/bug52891.phpt index 1c287d79bfad1..fc76f89b703a7 100644 --- a/ext/mysqli/tests/bug52891.phpt +++ b/ext/mysqli/tests/bug52891.phpt @@ -5,9 +5,6 @@ mysqli --SKIPIF-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- 50100)) { - die("skip Your MySQL Server version has a known bug that will cause a crash"); -} if (mysqli_get_server_version($link) >= 50600) die("SKIP For MySQL < 5.6.0"); diff --git a/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt b/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt index 3e5d439a538fe..393321bd1d590 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt @@ -61,13 +61,10 @@ require_once('skipifconnectfailure.inc'); 'use_result' => true, ); - if ($IS_MYSQLND) { - // mysqlnd only - /* $expected_methods['get_client_stats'] = true; */ - $expected_methods['get_connection_stats'] = true; - $expected_methods['reap_async_query'] = true; - $expected_methods['poll'] = true; - } + /* $expected_methods['get_client_stats'] = true; */ + $expected_methods['get_connection_stats'] = true; + $expected_methods['reap_async_query'] = true; + $expected_methods['poll'] = true; /* we should add ruled when to expect them */ if (function_exists('mysqli_debug')) diff --git a/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt b/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt index 626843c427d20..c0101a8d9e412 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt @@ -40,11 +40,9 @@ mysqli 'store_result' => true, ); - if ($IS_MYSQLND) { - $expected_methods['get_result'] = true; - $expected_methods['more_results'] = true; - $expected_methods['next_result'] = true; - } + $expected_methods['get_result'] = true; + $expected_methods['more_results'] = true; + $expected_methods['next_result'] = true; foreach ($methods as $k => $method) { if (isset($expected_methods[$method])) { diff --git a/ext/mysqli/tests/mysqli_connect.phpt b/ext/mysqli/tests/mysqli_connect.phpt index 8f648934308e0..e1606c0c01440 100644 --- a/ext/mysqli/tests/mysqli_connect.phpt +++ b/ext/mysqli/tests/mysqli_connect.phpt @@ -118,28 +118,26 @@ require_once('skipifconnectfailure.inc'); mysqli_close($link); } - if ($IS_MYSQLND) { - ini_set('mysqli.default_host', 'p:' . $host); - if (!is_object($link = mysqli_connect())) { - printf("[021] Usage of mysqli.default_host (persistent) failed\n") ; - } else { - if (!$res = mysqli_query($link, "SELECT 'mysqli.default_host (persistent)' AS 'testing'")) - printf("[022] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - $tmp = mysqli_fetch_assoc($res); - if ($tmp['testing'] !== 'mysqli.default_host (persistent)') { - printf("[023] Result looks strange - check manually, [%d] %s\n", - mysqli_errno($link), mysqli_error($link)); - var_dump($tmp); - } - mysqli_free_result($res); - mysqli_close($link); + ini_set('mysqli.default_host', 'p:' . $host); + if (!is_object($link = mysqli_connect())) { + printf("[021] Usage of mysqli.default_host (persistent) failed\n") ; + } else { + if (!$res = mysqli_query($link, "SELECT 'mysqli.default_host (persistent)' AS 'testing'")) + printf("[022] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + $tmp = mysqli_fetch_assoc($res); + if ($tmp['testing'] !== 'mysqli.default_host (persistent)') { + printf("[023] Result looks strange - check manually, [%d] %s\n", + mysqli_errno($link), mysqli_error($link)); + var_dump($tmp); } + mysqli_free_result($res); + mysqli_close($link); + } - ini_set('mysqli.default_host', 'p:'); - if (is_object($link = @mysqli_connect())) { - printf("[024] Usage of mysqli.default_host=p: did not fail\n") ; - mysqli_close($link); - } + ini_set('mysqli.default_host', 'p:'); + if (is_object($link = @mysqli_connect())) { + printf("[024] Usage of mysqli.default_host=p: did not fail\n") ; + mysqli_close($link); } print "done!"; diff --git a/ext/mysqli/tests/mysqli_connect_attr.phpt b/ext/mysqli/tests/mysqli_connect_attr.phpt index 75de208c4c5a2..323a87b74682b 100644 --- a/ext/mysqli/tests/mysqli_connect_attr.phpt +++ b/ext/mysqli/tests/mysqli_connect_attr.phpt @@ -6,9 +6,6 @@ mysqli query('SELECT 1'); - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + ini_set('mysqli.default_host', 'p:' . $host); + if (!is_object($mysqli = new mysqli())) { + // Due to an API flaw this shall not connect + printf("[010] Failed to create mysqli object\n"); + } else { + // There shall be NO connection! Using new mysqli(void) shall not use defaults for a connection! + // We had long discussions on this and found that the ext/mysqli API as + // such is broken. As we can't fix it, we document how it has behaved from + // the first day on. And that's: no connection. + try { + $mysqli->query('SELECT 1'); + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; } } diff --git a/ext/mysqli/tests/mysqli_constants.phpt b/ext/mysqli/tests/mysqli_constants.phpt index 444493fae5895..c228e1aafb69c 100644 --- a/ext/mysqli/tests/mysqli_constants.phpt +++ b/ext/mysqli/tests/mysqli_constants.phpt @@ -7,7 +7,6 @@ mysqli.allow_local_infile=1 --FILE-- true, ); -/* depends on the build - experimental */ -if ($IS_MYSQLND) { - $expected_constants['MYSQLI_OPT_INT_AND_FLOAT_NATIVE'] = true; -} +$expected_constants['MYSQLI_OPT_INT_AND_FLOAT_NATIVE'] = true; -if ($IS_MYSQLND) { - $expected_constants['MYSQLI_STORE_RESULT_COPY_DATA'] = true; -} +$expected_constants['MYSQLI_STORE_RESULT_COPY_DATA'] = true; -if ($IS_MYSQLND) { - $expected_constants['MYSQLI_REFRESH_BACKUP_LOG'] = true; -} +$expected_constants['MYSQLI_REFRESH_BACKUP_LOG'] = true; -if ($IS_MYSQLND) { - $version = 50007 + 1; - $expected_constants['MYSQLI_OPT_NET_CMD_BUFFER_SIZE'] = true; - $expected_constants['MYSQLI_OPT_NET_READ_BUFFER_SIZE'] = true; - $expected_constants['MYSQLI_ASYNC'] = true; +$version = 50007 + 1; +$expected_constants['MYSQLI_OPT_NET_CMD_BUFFER_SIZE'] = true; +$expected_constants['MYSQLI_OPT_NET_READ_BUFFER_SIZE'] = true; +$expected_constants['MYSQLI_ASYNC'] = true; - $expected_constants['MYSQLI_SERVER_PS_OUT_PARAMS'] = true; -} else { - $version = mysqli_get_client_version(); -} +$expected_constants['MYSQLI_SERVER_PS_OUT_PARAMS'] = true; -if (($version > 51122 && $version < 60000) || ($version > 60003) || $IS_MYSQLND) { - $expected_constants['MYSQLI_ON_UPDATE_NOW_FLAG'] = true; -} +$expected_constants['MYSQLI_ON_UPDATE_NOW_FLAG'] = true; -/* First introduced in MySQL 6.0, backported to MySQL 5.5 */ -if ($version >= 50500 || $IS_MYSQLND) { - $expected_constants['MYSQLI_SERVER_QUERY_WAS_SLOW'] = true; -} +$expected_constants['MYSQLI_SERVER_QUERY_WAS_SLOW'] = true; $expected_constants['MYSQLI_CLIENT_SSL_VERIFY_SERVER_CERT'] = true; -if ($IS_MYSQLND) { - $expected_constants['MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT'] = true; -} +$expected_constants['MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT'] = true; -/* First introduced in MySQL 6.0, backported to MySQL 5.5 */ -if ($version >= 50606 || $IS_MYSQLND) { - $expected_constants['MYSQLI_SERVER_PUBLIC_KEY'] = true; -} +$expected_constants['MYSQLI_SERVER_PUBLIC_KEY'] = true; $expected_constants = array_merge($expected_constants, array( "MYSQLI_TYPE_NEWDECIMAL" => true, @@ -165,22 +143,15 @@ $expected_constants = array_merge($expected_constants, array( "MYSQLI_STMT_ATTR_PREFETCH_ROWS" => true, )); -if ($version < 80000 || $version >= 100000 || $IS_MYSQLND) { - $expected_constants['MYSQLI_OPT_SSL_VERIFY_SERVER_CERT'] = true; -} +$expected_constants['MYSQLI_OPT_SSL_VERIFY_SERVER_CERT'] = true; /* pretty dump test, but that is the best way to mimic mysql.c */ $expected_constants["MYSQLI_DATA_TRUNCATED"] = true; -if ($IS_MYSQLND || (!$IS_MYSQLND && ($version > 50610))) { - /* could be that MySQL/libmysql 5.6.9 had the flag already but it was no stable release */ - $expected_constants["MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS"] = true; - $expected_constants["MYSQLI_CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS"] = true; -} +$expected_constants["MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS"] = true; +$expected_constants["MYSQLI_CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS"] = true; -if ($IS_MYSQLND) { - $expected_constants["MYSQLI_TYPE_JSON"] = true; -} +$expected_constants["MYSQLI_TYPE_JSON"] = true; $unexpected_constants = array(); diff --git a/ext/mysqli/tests/mysqli_debug.phpt b/ext/mysqli/tests/mysqli_debug.phpt index ec0eacced8cd8..25cd8f2c8d6b5 100644 --- a/ext/mysqli/tests/mysqli_debug.phpt +++ b/ext/mysqli/tests/mysqli_debug.phpt @@ -23,38 +23,34 @@ if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED) if (true !== ($tmp = mysqli_debug(sprintf('d:t:O,%s/mysqli_debug_phpt.trace', sys_get_temp_dir())))) printf("[002] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - if ($IS_MYSQLND) { - // let's make this mysqlnd only - for libmysql we need debug installation - - // table.inc will create a database connection and run some SQL queries, therefore - // the debug file should have entries - require_once('table.inc'); - - clearstatcache(); - $trace_file = sprintf('%s/mysqli_debug_phpt.trace', sys_get_temp_dir()); - if (!file_exists($trace_file)) - printf("[003] Trace file '%s' has not been created\n", $trace_file); - if (filesize($trace_file) < 50) - printf("[004] Trace file '%s' is very small. filesize() reports only %d bytes. Please check.\n", - $trace_file, - filesize($trace_file)); - - // will mysqli_debug() mind if the trace file gets removed? - unlink($trace_file); - clearstatcache(); - - if (!$res = mysqli_query($link, 'SELECT * FROM test')) - printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - else - mysqli_free_result($res); - - mysqli_close($link); - - clearstatcache(); - if (!file_exists($trace_file)) - printf("[006] Trace file '%s' does not exist\n", $trace_file); - unlink($trace_file); - } + // table.inc will create a database connection and run some SQL queries, therefore + // the debug file should have entries + require_once('table.inc'); + + clearstatcache(); + $trace_file = sprintf('%s/mysqli_debug_phpt.trace', sys_get_temp_dir()); + if (!file_exists($trace_file)) + printf("[003] Trace file '%s' has not been created\n", $trace_file); + if (filesize($trace_file) < 50) + printf("[004] Trace file '%s' is very small. filesize() reports only %d bytes. Please check.\n", + $trace_file, + filesize($trace_file)); + + // will mysqli_debug() mind if the trace file gets removed? + unlink($trace_file); + clearstatcache(); + + if (!$res = mysqli_query($link, 'SELECT * FROM test')) + printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + else + mysqli_free_result($res); + + mysqli_close($link); + + clearstatcache(); + if (!file_exists($trace_file)) + printf("[006] Trace file '%s' does not exist\n", $trace_file); + unlink($trace_file); print "done!"; ?> diff --git a/ext/mysqli/tests/mysqli_debug_append.phpt b/ext/mysqli/tests/mysqli_debug_append.phpt index b48e8470a47b1..1c26d469f51db 100644 --- a/ext/mysqli/tests/mysqli_debug_append.phpt +++ b/ext/mysqli/tests/mysqli_debug_append.phpt @@ -15,9 +15,6 @@ if (!defined('MYSQLI_DEBUG_TRACE_ENABLED')) if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED) die("skip: debug functionality not enabled"); -if (!$IS_MYSQLND) - die("SKIP Libmysql feature not sufficiently spec'd in MySQL C API documentation"); - if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test is not for Windows platforms"); ?> --FILE-- @@ -84,8 +81,7 @@ if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test is not for Windows platfo mysqli_close($link); print "done"; - if ($IS_MYSQLND) - print "libmysql/DBUG package prints some debug info here." + print "libmysql/DBUG package prints some debug info here." ?> --CLEAN-- --FILE-- --EXPECTF-- Warning: mysqli_debug(): Unrecognized format ',' in %s on line %d diff --git a/ext/mysqli/tests/mysqli_debug_ini.phpt b/ext/mysqli/tests/mysqli_debug_ini.phpt index 42f78e7361a95..c53b103f2768b 100644 --- a/ext/mysqli/tests/mysqli_debug_ini.phpt +++ b/ext/mysqli/tests/mysqli_debug_ini.phpt @@ -15,9 +15,6 @@ if (!defined('MYSQLI_DEBUG_TRACE_ENABLED')) if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED) die("skip: debug functionality not enabled"); -if (!$IS_MYSQLND) - die("skip needs mysqlnd"); - if (!$fp = @fopen('/tmp/mysqli_debug_phpt.trace', 'w')) die("skip PHP cannot create a file in /tmp/mysqli_debug_phpt"); else diff --git a/ext/mysqli/tests/mysqli_debug_mysqlnd_control_string.phpt b/ext/mysqli/tests/mysqli_debug_mysqlnd_control_string.phpt index 25feade40af9e..5c2f58e9f3d4b 100644 --- a/ext/mysqli/tests/mysqli_debug_mysqlnd_control_string.phpt +++ b/ext/mysqli/tests/mysqli_debug_mysqlnd_control_string.phpt @@ -14,9 +14,6 @@ if (!defined('MYSQLI_DEBUG_TRACE_ENABLED')) if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED) die("skip: debug functionality not enabled"); - -if (!$IS_MYSQLND) - die("SKIP Libmysql feature not sufficiently spec'd in MySQL C API documentation"); ?> --FILE-- \_mysqlnd_p?efree@ismU", $trace, $matches) && - !preg_match("@^[|\s]*>\_mysqlnd_p?emalloc@ismU", $trace, $matches)) { - printf("[125] Memory dump does neither contain _mysqlnd_pefree nor _mysqlnd_pemalloc calls - check manually.\n"); - var_dump($trace); - } - + // m - trace memory allocations + $trace = try_control_string($link, 't:O,' . $trace_file . ':m', $trace_file, 120); + if (!preg_match("@^[|\s]*>\_mysqlnd_p?efree@ismU", $trace, $matches) && + !preg_match("@^[|\s]*>\_mysqlnd_p?emalloc@ismU", $trace, $matches)) { + printf("[125] Memory dump does neither contain _mysqlnd_pefree nor _mysqlnd_pemalloc calls - check manually.\n"); + var_dump($trace); } mysqli_close($link); print "done"; - if ($IS_MYSQLND) - print "libmysql/DBUG package prints some debug info here."; + print "libmysql/DBUG package prints some debug info here."; @unlink($trace_file); ?> --CLEAN-- diff --git a/ext/mysqli/tests/mysqli_debug_mysqlnd_only.phpt b/ext/mysqli/tests/mysqli_debug_mysqlnd_only.phpt index 00a460a410e1f..8d9058439752f 100644 --- a/ext/mysqli/tests/mysqli_debug_mysqlnd_only.phpt +++ b/ext/mysqli/tests/mysqli_debug_mysqlnd_only.phpt @@ -14,9 +14,6 @@ if (!defined('MYSQLI_DEBUG_TRACE_ENABLED')) if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED) die("skip: debug functionality not enabled"); - -if (!$IS_MYSQLND) - die("skip mysqlnd only test"); ?> --FILE-- server_version >= 100000) { } -if (!$IS_MYSQLND && (mysqli_get_client_version() < 50610)) { - die(sprintf("SKIP Needs libmysql 5.6.10 or newer, found %s\n", mysqli_get_client_version())); -} - mysqli_query($link, 'DROP USER expiretest'); mysqli_query($link, 'DROP USER expiretest@localhost'); diff --git a/ext/mysqli/tests/mysqli_explain_metadata.phpt b/ext/mysqli/tests/mysqli_explain_metadata.phpt index e920a7fffb081..af8d153bc759e 100644 --- a/ext/mysqli/tests/mysqli_explain_metadata.phpt +++ b/ext/mysqli/tests/mysqli_explain_metadata.phpt @@ -5,8 +5,6 @@ mysqli --SKIPIF-- --FILE-- = 51000) { - func_mysqli_fetch_array($link, $engine, "BIGINT", "-9223372036854775808", "-9223372036854775808", 250); - func_mysqli_fetch_array($link, $engine, "BIGINT", NULL, NULL, 260); - func_mysqli_fetch_array($link, $engine, "BIGINT UNSIGNED", "18446744073709551615", "18446744073709551615", 260); - func_mysqli_fetch_array($link, $engine, "BIGINT UNSIGNED", NULL, NULL, 280); - } + func_mysqli_fetch_array($link, $engine, "BIGINT", "-9223372036854775808", "-9223372036854775808", 250); + func_mysqli_fetch_array($link, $engine, "BIGINT", NULL, NULL, 260); + func_mysqli_fetch_array($link, $engine, "BIGINT UNSIGNED", "18446744073709551615", "18446744073709551615", 260); + func_mysqli_fetch_array($link, $engine, "BIGINT UNSIGNED", NULL, NULL, 280); func_mysqli_fetch_array($link, $engine, "FLOAT", (string)(-9223372036854775808 - 1.1), "-9.22337e+18", 290, "/-9\.22337e\+?[0]?18/iu"); func_mysqli_fetch_array($link, $engine, "FLOAT", NULL, NULL, 300); diff --git a/ext/mysqli/tests/mysqli_fetch_array_oo.phpt b/ext/mysqli/tests/mysqli_fetch_array_oo.phpt index 87dd7ee7adba1..8695166338c13 100644 --- a/ext/mysqli/tests/mysqli_fetch_array_oo.phpt +++ b/ext/mysqli/tests/mysqli_fetch_array_oo.phpt @@ -171,12 +171,10 @@ require_once('skipifconnectfailure.inc'); func_mysqli_fetch_array($mysqli, $engine, "INTEGER UNSIGNED", "4294967295", "4294967295", 230); func_mysqli_fetch_array($mysqli, $engine, "INTEGER UNSIGNED", NULL, NULL, 240); - if ($IS_MYSQLND || mysqli_get_server_version($link) >= 51000) { - func_mysqli_fetch_array($mysqli, $engine, "BIGINT", "-9223372036854775808", "-9223372036854775808", 250); - func_mysqli_fetch_array($mysqli, $engine, "BIGINT", NULL, NULL, 260); - func_mysqli_fetch_array($mysqli, $engine, "BIGINT UNSIGNED", "18446744073709551615", "18446744073709551615", 270); - func_mysqli_fetch_array($mysqli, $engine, "BIGINT UNSIGNED", NULL, NULL, 280); - } + func_mysqli_fetch_array($mysqli, $engine, "BIGINT", "-9223372036854775808", "-9223372036854775808", 250); + func_mysqli_fetch_array($mysqli, $engine, "BIGINT", NULL, NULL, 260); + func_mysqli_fetch_array($mysqli, $engine, "BIGINT UNSIGNED", "18446744073709551615", "18446744073709551615", 270); + func_mysqli_fetch_array($mysqli, $engine, "BIGINT UNSIGNED", NULL, NULL, 280); func_mysqli_fetch_array($mysqli, $engine, "FLOAT", (string)(-9223372036854775808 - 1.1), "-9.22337e+18", 290, "/-9\.22337e\+?[0]?18/iu"); func_mysqli_fetch_array($mysqli, $engine, "FLOAT", NULL, NULL, 300); diff --git a/ext/mysqli/tests/mysqli_fetch_column.phpt b/ext/mysqli/tests/mysqli_fetch_column.phpt index fb4886f693c97..fddb41687d8ab 100644 --- a/ext/mysqli/tests/mysqli_fetch_column.phpt +++ b/ext/mysqli/tests/mysqli_fetch_column.phpt @@ -5,9 +5,6 @@ mysqli --SKIPIF-- --FILE-- info != 'Records: 6 Duplicates: 0 Warnings: 0') { - printf("[008] mysqlnd used to be more verbose and used to support SELECT\n"); - } - } else { - if ($link->info != NULL) { - printf("[008] Time for wonders - libmysql has started to support SELECT, change test\n"); - } + if ($link->info != 'Records: 6 Duplicates: 0 Warnings: 0') { + printf("[008] mysqlnd used to be more verbose and used to support SELECT\n"); } mysqli_close($link); diff --git a/ext/mysqli/tests/mysqli_mysqlnd_read_timeout.phpt b/ext/mysqli/tests/mysqli_mysqlnd_read_timeout.phpt index 472f88f97e860..95e11db9a6dd1 100644 --- a/ext/mysqli/tests/mysqli_mysqlnd_read_timeout.phpt +++ b/ext/mysqli/tests/mysqli_mysqlnd_read_timeout.phpt @@ -5,9 +5,6 @@ mysqli --SKIPIF-- --INI-- default_socket_timeout=60 diff --git a/ext/mysqli/tests/mysqli_mysqlnd_read_timeout_long.phpt b/ext/mysqli/tests/mysqli_mysqlnd_read_timeout_long.phpt index a877a5cc08cf4..6953fb7809ba0 100644 --- a/ext/mysqli/tests/mysqli_mysqlnd_read_timeout_long.phpt +++ b/ext/mysqli/tests/mysqli_mysqlnd_read_timeout_long.phpt @@ -6,10 +6,6 @@ mysqli getMessage() . "\n"; } diff --git a/ext/mysqli/tests/mysqli_options_int_and_float_native.phpt b/ext/mysqli/tests/mysqli_options_int_and_float_native.phpt index dc213aa11a728..ecf8bc5cfbeb2 100644 --- a/ext/mysqli/tests/mysqli_options_int_and_float_native.phpt +++ b/ext/mysqli/tests/mysqli_options_int_and_float_native.phpt @@ -5,9 +5,6 @@ mysqli --SKIPIF-- --FILE-- diff --git a/ext/mysqli/tests/mysqli_phpinfo.phpt b/ext/mysqli/tests/mysqli_phpinfo.phpt index 526afe74eba82..b7cd133dc2d6a 100644 --- a/ext/mysqli/tests/mysqli_phpinfo.phpt +++ b/ext/mysqli/tests/mysqli_phpinfo.phpt @@ -41,16 +41,14 @@ require_once('skipifconnectfailure.inc'); if (!stristr($phpinfo, "mysqli.max_links")) printf("[008] php.ini setting mysqli.max_links not shown.\n"); - if ($IS_MYSQLND) { - $expected = array( - 'size', - 'mysqli.allow_local_infile', 'mysqli.local_infile_directory', - 'mysqli.allow_persistent', 'mysqli.max_persistent' - ); - foreach ($expected as $k => $entry) - if (!stristr($phpinfo, $entry)) - printf("[010] Could not find entry for '%s'\n", $entry); - } + $expected = array( + 'size', + 'mysqli.allow_local_infile', 'mysqli.local_infile_directory', + 'mysqli.allow_persistent', 'mysqli.max_persistent' + ); + foreach ($expected as $k => $entry) + if (!stristr($phpinfo, $entry)) + printf("[010] Could not find entry for '%s'\n", $entry); print "done!"; ?> diff --git a/ext/mysqli/tests/mysqli_poll.phpt b/ext/mysqli/tests/mysqli_poll.phpt index ac78ccbbf83d7..e666a65aed8b5 100644 --- a/ext/mysqli/tests/mysqli_poll.phpt +++ b/ext/mysqli/tests/mysqli_poll.phpt @@ -5,9 +5,6 @@ mysqli --SKIPIF-- --FILE-- --FILE-- --FILE-- close(); - if ($IS_MYSQLND) { - /* - Advantage mysqlnd - - The metadata mysqlnd has available after prepare is better than - the one made available by the MySQL Client Library (libmysql). - "libmysql" will give wrong results and that is OK - - http://bugs.mysql.com/bug.php?id=47483 - */ - if (!($stmt = $link->prepare("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST('two' AS CHAR)"))) - printf("[005] [%d] %s\n", $link->errno, $link->error); - - $column1 = null; - /* Note: bind_result before execute */ - if (!$stmt->bind_result($column1) || !$stmt->execute()) - printf("[006] [%d] %s\n", $stmt->errno, $stmt->error); - - $index = 0; - while ($stmt->fetch()) { - if ($data[$index] != $column1) { - printf("[007] Row %d, expecting %s/%s got %s/%s\n", - $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); - } - $index++; + /* + Advantage mysqlnd - + The metadata mysqlnd has available after prepare is better than + the one made available by the MySQL Client Library (libmysql). + "libmysql" will give wrong results and that is OK - + http://bugs.mysql.com/bug.php?id=47483 + */ + if (!($stmt = $link->prepare("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST('two' AS CHAR)"))) + printf("[005] [%d] %s\n", $link->errno, $link->error); + + $column1 = null; + /* Note: bind_result before execute */ + if (!$stmt->bind_result($column1) || !$stmt->execute()) + printf("[006] [%d] %s\n", $stmt->errno, $stmt->error); + + $index = 0; + while ($stmt->fetch()) { + if ($data[$index] != $column1) { + printf("[007] Row %d, expecting %s/%s got %s/%s\n", + $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); } - $stmt->close(); + $index++; } + $stmt->close(); // Regular (non-prepared) queries print "Mixing CAST('somestring'AS CHAR), integer and CAST(integer AS CHAR)...\n"; @@ -98,25 +96,23 @@ require_once('skipifconnectfailure.inc'); } $stmt->close(); - if ($IS_MYSQLND) { - /* Advantage mysqlnd - see above... */ - if (!($stmt = $link->prepare("SELECT 1 AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST(2 AS CHAR)"))) - printf("[012] [%d] %s\n", $link->errno, $link->error); - - $column1 = null; - if (!$stmt->bind_result($column1) || !$stmt->execute()) - printf("[013] [%d] %s\n", $stmt->errno, $stmt->error); - - $index = 0; - while ($stmt->fetch()) { - if ($data[$index] != $column1) { - printf("[014] Row %d, expecting %s/%s got %s/%s\n", - $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); - } - $index++; + /* Advantage mysqlnd - see above... */ + if (!($stmt = $link->prepare("SELECT 1 AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST(2 AS CHAR)"))) + printf("[012] [%d] %s\n", $link->errno, $link->error); + + $column1 = null; + if (!$stmt->bind_result($column1) || !$stmt->execute()) + printf("[013] [%d] %s\n", $stmt->errno, $stmt->error); + + $index = 0; + while ($stmt->fetch()) { + if ($data[$index] != $column1) { + printf("[014] Row %d, expecting %s/%s got %s/%s\n", + $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); } - $stmt->close(); + $index++; } + $stmt->close(); print "Using integer only...\n"; if (!($res = $link->query("SELECT 1 AS column1 UNION SELECT 303 UNION SELECT 2"))) @@ -147,25 +143,23 @@ require_once('skipifconnectfailure.inc'); } $stmt->close(); - if ($IS_MYSQLND) { - /* Advantage mysqlnd - see above */ - if (!($stmt = $link->prepare("SELECT 1 AS column1 UNION SELECT 303 UNION SELECT 2"))) - printf("[019] [%d] %s\n", $link->errno, $link->error); - - $column1 = null; - if (!$stmt->bind_result($column1) || !$stmt->execute()) - printf("[020] [%d] %s\n", $stmt->errno, $stmt->error); - - $index = 0; - while ($stmt->fetch()) { - if ($data[$index] != $column1) { - printf("[021] Row %d, expecting %s/%s got %s/%s\n", - $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); - } - $index++; + /* Advantage mysqlnd - see above */ + if (!($stmt = $link->prepare("SELECT 1 AS column1 UNION SELECT 303 UNION SELECT 2"))) + printf("[019] [%d] %s\n", $link->errno, $link->error); + + $column1 = null; + if (!$stmt->bind_result($column1) || !$stmt->execute()) + printf("[020] [%d] %s\n", $stmt->errno, $stmt->error); + + $index = 0; + while ($stmt->fetch()) { + if ($data[$index] != $column1) { + printf("[021] Row %d, expecting %s/%s got %s/%s\n", + $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); } - $stmt->close(); + $index++; } + $stmt->close(); print "Testing bind_param(), strings only...\n"; $two = 'two'; @@ -185,27 +179,25 @@ require_once('skipifconnectfailure.inc'); } $stmt->close(); - if ($IS_MYSQLND) { - /* Advantage mysqlnd - see above */ - $two = 'two'; - $three = 'three'; - if (!($stmt = $link->prepare("SELECT 'one' AS column1 UNION SELECT ? UNION SELECT ?"))) - printf("[024] [%d] %s\n", $stmt->errno, $stmt->error); - - $column1 = null; - if (!$stmt->bind_param('ss', $three, $two) || !$stmt->bind_result($column1) || !$stmt->execute()) - printf("[025] [%d] %s\n", $stmt->errno, $stmt->error); - - $index = 0; - while ($stmt->fetch()) { - if ($data[$index] != $column1) { - printf("[26] Row %d, expecting %s/%s, got %s/%s\n", - $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); - } - $index++; + /* Advantage mysqlnd - see above */ + $two = 'two'; + $three = 'three'; + if (!($stmt = $link->prepare("SELECT 'one' AS column1 UNION SELECT ? UNION SELECT ?"))) + printf("[024] [%d] %s\n", $stmt->errno, $stmt->error); + + $column1 = null; + if (!$stmt->bind_param('ss', $three, $two) || !$stmt->bind_result($column1) || !$stmt->execute()) + printf("[025] [%d] %s\n", $stmt->errno, $stmt->error); + + $index = 0; + while ($stmt->fetch()) { + if ($data[$index] != $column1) { + printf("[26] Row %d, expecting %s/%s, got %s/%s\n", + $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); } - $stmt->close(); + $index++; } + $stmt->close(); print "Testing bind_param(), strings only, with CAST AS CHAR...\n"; $two = 'two'; @@ -225,27 +217,25 @@ require_once('skipifconnectfailure.inc'); } $stmt->close(); - if ($IS_MYSQLND) { - /* Advantage mysqlnd - see above */ - $two = 'two'; - $three = 'three beers are more than enough'; - if (!($stmt = $link->prepare("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST(? AS CHAR) UNION SELECT CAST(? AS CHAR)"))) - printf("[029] [%d] %s\n", $stmt->errno, $stmt->error); - - $column1 = null; - if (!$stmt->bind_param('ss', $three, $two) || !$stmt->bind_result($column1) || !$stmt->execute()) - printf("[030] [%d] %s\n", $stmt->errno, $stmt->error); - - $index = 0; - while ($stmt->fetch()) { - if ($data[$index] != $column1) { - printf("[31] Row %d, expecting %s/%s, got %s/%s\n", - $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); - } - $index++; + /* Advantage mysqlnd - see above */ + $two = 'two'; + $three = 'three beers are more than enough'; + if (!($stmt = $link->prepare("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST(? AS CHAR) UNION SELECT CAST(? AS CHAR)"))) + printf("[029] [%d] %s\n", $stmt->errno, $stmt->error); + + $column1 = null; + if (!$stmt->bind_param('ss', $three, $two) || !$stmt->bind_result($column1) || !$stmt->execute()) + printf("[030] [%d] %s\n", $stmt->errno, $stmt->error); + + $index = 0; + while ($stmt->fetch()) { + if ($data[$index] != $column1) { + printf("[31] Row %d, expecting %s/%s, got %s/%s\n", + $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); } - $stmt->close(); + $index++; } + $stmt->close(); $link->close(); diff --git a/ext/mysqli/tests/mysqli_real_connect.phpt b/ext/mysqli/tests/mysqli_real_connect.phpt index 2df7356215dad..b2b23ea45018c 100644 --- a/ext/mysqli/tests/mysqli_real_connect.phpt +++ b/ext/mysqli/tests/mysqli_real_connect.phpt @@ -113,32 +113,30 @@ mysqli.allow_local_infile=1 mysqli_close($link); var_dump($link); - if ($IS_MYSQLND) { - ini_set('mysqli.default_host', 'p:' . $host); - $link = mysqli_init(); - if (!@mysqli_real_connect($link)) { - printf("[022] Usage of mysqli.default_host=p:%s (persistent) failed\n", $host) ; - } else { - if (!$res = mysqli_query($link, "SELECT 'mysqli.default_host (persistent)' AS 'testing'")) - printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - $tmp = mysqli_fetch_assoc($res); - if ($tmp['testing'] !== 'mysqli.default_host (persistent)') { - printf("[024] Result looks strange - check manually, [%d] %s\n", - mysqli_errno($link), mysqli_error($link)); - var_dump($tmp); - } - mysqli_free_result($res); - mysqli_close($link); + ini_set('mysqli.default_host', 'p:' . $host); + $link = mysqli_init(); + if (!@mysqli_real_connect($link)) { + printf("[022] Usage of mysqli.default_host=p:%s (persistent) failed\n", $host) ; + } else { + if (!$res = mysqli_query($link, "SELECT 'mysqli.default_host (persistent)' AS 'testing'")) + printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + $tmp = mysqli_fetch_assoc($res); + if ($tmp['testing'] !== 'mysqli.default_host (persistent)') { + printf("[024] Result looks strange - check manually, [%d] %s\n", + mysqli_errno($link), mysqli_error($link)); + var_dump($tmp); } + mysqli_free_result($res); + mysqli_close($link); + } - ini_set('mysqli.default_host', 'p:'); - $link = mysqli_init(); - if (@mysqli_real_connect($link)) { - printf("[025] Usage of mysqli.default_host=p: did not fail\n") ; - mysqli_close($link); - } - @mysqli_close($link); + ini_set('mysqli.default_host', 'p:'); + $link = mysqli_init(); + if (@mysqli_real_connect($link)) { + printf("[025] Usage of mysqli.default_host=p: did not fail\n") ; + mysqli_close($link); } + @mysqli_close($link); try { mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket); diff --git a/ext/mysqli/tests/mysqli_real_connect_pconn.phpt b/ext/mysqli/tests/mysqli_real_connect_pconn.phpt index b9f7a4b39fa5f..087bc64a43dc9 100644 --- a/ext/mysqli/tests/mysqli_real_connect_pconn.phpt +++ b/ext/mysqli/tests/mysqli_real_connect_pconn.phpt @@ -5,8 +5,6 @@ mysqli --SKIPIF-- --INI-- mysqli.allow_local_infile=1 @@ -116,29 +114,27 @@ mysqli.max_persistent=10 mysqli_close($link); - if ($IS_MYSQLND) { - $link = mysqli_init(); - if (!@mysqli_real_connect($link)) { - printf("[022] Usage of mysqli.default_host=p:%s (persistent) failed\n", $host) ; - } else { - if (!$res = mysqli_query($link, "SELECT 'mysqli.default_host (persistent)' AS 'testing'")) - printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - $tmp = mysqli_fetch_assoc($res); - if ($tmp['testing'] !== 'mysqli.default_host (persistent)') { - printf("[024] Result looks strange - check manually, [%d] %s\n", - mysqli_errno($link), mysqli_error($link)); - var_dump($tmp); - } - mysqli_free_result($res); - mysqli_close($link); + $link = mysqli_init(); + if (!@mysqli_real_connect($link)) { + printf("[022] Usage of mysqli.default_host=p:%s (persistent) failed\n", $host) ; + } else { + if (!$res = mysqli_query($link, "SELECT 'mysqli.default_host (persistent)' AS 'testing'")) + printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + $tmp = mysqli_fetch_assoc($res); + if ($tmp['testing'] !== 'mysqli.default_host (persistent)') { + printf("[024] Result looks strange - check manually, [%d] %s\n", + mysqli_errno($link), mysqli_error($link)); + var_dump($tmp); } + mysqli_free_result($res); + mysqli_close($link); + } - ini_set('mysqli.default_host', 'p:'); - $link = mysqli_init(); - if (@mysqli_real_connect($link)) { - printf("[025] Usage of mysqli.default_host=p: did not fail\n") ; - mysqli_close($link); - } + ini_set('mysqli.default_host', 'p:'); + $link = mysqli_init(); + if (@mysqli_real_connect($link)) { + printf("[025] Usage of mysqli.default_host=p: did not fail\n") ; + mysqli_close($link); } if (NULL === ($tmp = mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))) diff --git a/ext/mysqli/tests/mysqli_reap_async_query.phpt b/ext/mysqli/tests/mysqli_reap_async_query.phpt index 7d538297623bc..49398a45df07d 100644 --- a/ext/mysqli/tests/mysqli_reap_async_query.phpt +++ b/ext/mysqli/tests/mysqli_reap_async_query.phpt @@ -5,9 +5,6 @@ mysqli --SKIPIF-- --FILE-- --FILE-- 4294967296))) { - /* NOTE: the MySQL Client Library - not mysqlnd - will allocate - a hugge max_length(type) = 4GB bind buffer */ - func_mysqli_stmt_bind_result($link, $engine, "b", "LONGBLOB", "", 1660); - func_mysqli_stmt_bind_result($link, $engine, "b", "LONGTEXT", "", 1680, 'string'); - } + func_mysqli_stmt_bind_result($link, $engine, "b", "LONGBLOB", "", 1660); + func_mysqli_stmt_bind_result($link, $engine, "b", "LONGTEXT", "", 1680, 'string'); func_mysqli_stmt_bind_result($link, $engine, "s", "ENUM('a', 'b')", "a", 1700, 'string'); func_mysqli_stmt_bind_result($link, $engine, "s", "ENUM('a', 'b')", NULL, 1720, 'string'); diff --git a/ext/mysqli/tests/mysqli_stmt_execute_bind.phpt b/ext/mysqli/tests/mysqli_stmt_execute_bind.phpt index deb95c9f8bdea..7921e51f75be4 100644 --- a/ext/mysqli/tests/mysqli_stmt_execute_bind.phpt +++ b/ext/mysqli/tests/mysqli_stmt_execute_bind.phpt @@ -5,9 +5,6 @@ mysqli --SKIPIF-- --FILE-- --FILE-- --FILE-- --FILE-- --INI-- mysqlnd.debug="d:t:O,{TMP}/mysqlnd.trace" From 455e5ca2b9736b918747297507bf2f5819a10c6c Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 4 Oct 2022 15:47:49 +0200 Subject: [PATCH 2/3] Fix indentation --- ext/mysqli/tests/mysqli_connect.phpt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/mysqli/tests/mysqli_connect.phpt b/ext/mysqli/tests/mysqli_connect.phpt index e1606c0c01440..0e1142ee92a61 100644 --- a/ext/mysqli/tests/mysqli_connect.phpt +++ b/ext/mysqli/tests/mysqli_connect.phpt @@ -119,8 +119,8 @@ require_once('skipifconnectfailure.inc'); } ini_set('mysqli.default_host', 'p:' . $host); - if (!is_object($link = mysqli_connect())) { - printf("[021] Usage of mysqli.default_host (persistent) failed\n") ; + if (!is_object($link = mysqli_connect())) { + printf("[021] Usage of mysqli.default_host (persistent) failed\n") ; } else { if (!$res = mysqli_query($link, "SELECT 'mysqli.default_host (persistent)' AS 'testing'")) printf("[022] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); From 2da68903a6579b78bc2d6c5ef0d5bbb020280da4 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 4 Oct 2022 16:12:36 +0200 Subject: [PATCH 3/3] Drop superfluous is_object() checks --- .../mysqli_class_mysqli_result_interface.phpt | 17 +++------ ext/mysqli/tests/mysqli_connect_oo.phpt | 37 ++++++++++--------- ext/mysqli/tests/mysqli_driver.phpt | 4 +- ext/mysqli/tests/mysqli_get_warnings.phpt | 3 +- 4 files changed, 26 insertions(+), 35 deletions(-) diff --git a/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt b/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt index abbb47ebb1d8d..946657d3ef8aa 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt @@ -111,8 +111,7 @@ require_once('skipifconnectfailure.inc'); printf("mysqli_result->unknown = '%s'\n", @$mysqli_result->unknown); printf("\nConstructor:\n"); - if (!is_object($res = new mysqli_result($link))) - printf("[001] Expecting object/mysqli_result got %s/%s\n", gettye($res), $res); + $res = new mysqli_result($link); try { $res->num_rows; @@ -123,14 +122,9 @@ require_once('skipifconnectfailure.inc'); if (!mysqli_query($link, "SELECT id FROM test ORDER BY id")) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!is_object($res = new mysqli_result($link))) - printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!is_object($res = new mysqli_result($link, MYSQLI_STORE_RESULT))) - printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!is_object($res = new mysqli_result($link, MYSQLI_USE_RESULT))) - printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + $res = new mysqli_result($link); + $res = new mysqli_result($link, MYSQLI_STORE_RESULT); + $res = new mysqli_result($link, MYSQLI_USE_RESULT); $valid = array(MYSQLI_STORE_RESULT, MYSQLI_USE_RESULT); do { @@ -139,8 +133,7 @@ require_once('skipifconnectfailure.inc'); if ($TEST_EXPERIMENTAL) { ob_start(); - if (!is_object($res = new mysqli_result($link, $mode))) - printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + $res = new mysqli_result($link, $mode); $content = ob_get_contents(); ob_end_clean(); if (!stristr($content, 'Invalid value for resultmode')) diff --git a/ext/mysqli/tests/mysqli_connect_oo.phpt b/ext/mysqli/tests/mysqli_connect_oo.phpt index 9ff7ef1179315..a5b065a065f56 100644 --- a/ext/mysqli/tests/mysqli_connect_oo.phpt +++ b/ext/mysqli/tests/mysqli_connect_oo.phpt @@ -24,35 +24,40 @@ require_once('skipifconnectfailure.inc'); // Run the following tests without an anoynmous MySQL user and use a password for the test user! ini_set('mysqli.default_socket', $socket); - if (!is_object($mysqli = new mysqli($host, $user, $passwd, $db, $port)) || (0 !== mysqli_connect_errno())) { + $mysqli = new mysqli($host, $user, $passwd, $db, $port); + if (0 !== mysqli_connect_errno()) { printf("[005] Usage of mysqli.default_socket failed\n") ; } else { $mysqli->close(); } ini_set('mysqli.default_port', $port); - if (!is_object($mysqli = new mysqli($host, $user, $passwd, $db)) || (0 !== mysqli_connect_errno())) { + $mysqli = new mysqli($host, $user, $passwd, $db); + if (0 !== mysqli_connect_errno()) { printf("[006] Usage of mysqli.default_port failed\n") ; } else { $mysqli->close(); } ini_set('mysqli.default_pw', $passwd); - if (!is_object($mysqli = new mysqli($host, $user)) || (0 !== mysqli_connect_errno())) { + $mysqli = new mysqli($host, $user); + if (0 !== mysqli_connect_errno()) { printf("[007] Usage of mysqli.default_pw failed\n") ; } else { $mysqli->close(); } ini_set('mysqli.default_user', $user); - if (!is_object($mysqli = new mysqli($host)) || (0 !== mysqli_connect_errno())) { + $mysqli = new mysqli($host); + if (0 !== mysqli_connect_errno()) { printf("[008] Usage of mysqli.default_user failed\n") ; } else { $mysqli->close(); } ini_set('mysqli.default_host', $host); - if (!is_object($mysqli = new mysqli()) || (0 !== mysqli_connect_errno())) { + $mysqli = new mysqli(); + if (0 !== mysqli_connect_errno()) { printf("[012] Failed to create mysqli object\n"); } else { // There shall be NO connection! Using new mysqli(void) shall not use defaults for a connection! @@ -67,19 +72,15 @@ require_once('skipifconnectfailure.inc'); } ini_set('mysqli.default_host', 'p:' . $host); - if (!is_object($mysqli = new mysqli())) { - // Due to an API flaw this shall not connect - printf("[010] Failed to create mysqli object\n"); - } else { - // There shall be NO connection! Using new mysqli(void) shall not use defaults for a connection! - // We had long discussions on this and found that the ext/mysqli API as - // such is broken. As we can't fix it, we document how it has behaved from - // the first day on. And that's: no connection. - try { - $mysqli->query('SELECT 1'); - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + $mysqli = new mysqli(); + // There shall be NO connection! Using new mysqli(void) shall not use defaults for a connection! + // We had long discussions on this and found that the ext/mysqli API as + // such is broken. As we can't fix it, we document how it has behaved from + // the first day on. And that's: no connection. + try { + $mysqli->query('SELECT 1'); + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; } print "... and now Exceptions\n"; diff --git a/ext/mysqli/tests/mysqli_driver.phpt b/ext/mysqli/tests/mysqli_driver.phpt index 2291ccbfc2320..79f62cc8685a6 100644 --- a/ext/mysqli/tests/mysqli_driver.phpt +++ b/ext/mysqli/tests/mysqli_driver.phpt @@ -10,9 +10,7 @@ require_once('skipifconnectfailure.inc'); client_info) !== $client_info) { diff --git a/ext/mysqli/tests/mysqli_get_warnings.phpt b/ext/mysqli/tests/mysqli_get_warnings.phpt index d8d210eee12cf..2d2a0042d83a3 100644 --- a/ext/mysqli/tests/mysqli_get_warnings.phpt +++ b/ext/mysqli/tests/mysqli_get_warnings.phpt @@ -92,8 +92,7 @@ if (!$TEST_EXPERIMENTAL) if (!$mysqli->query("CREATE TABLE t1 (a smallint)")) printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!is_object($warning = new mysqli_warning($mysqli))) - printf("[024] Expecting object/mysqli_warning, got %s/%s", gettype($warning), $warning); + $warning = new mysqli_warning($mysqli); if (!is_string($warning->message) || ('' == $warning->message)) printf("[025] Expecting string, got %s/%s", gettype($warning->message), $warning->message);