1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Clean up mysqli tests (#15473)

This commit is contained in:
Kamil Tekiela
2024-08-18 00:12:23 +02:00
committed by GitHub
parent d472866f33
commit 7e5171d1f6
102 changed files with 192 additions and 314 deletions

View File

@@ -16,8 +16,6 @@ require_once 'skipifconnectfailure.inc';
printf("[002] Cannot set SQL-Mode, [%d] %s\n", mysqli_errno($mysql), mysqli_error($mysql));
$esc_str = chr(0xbf) . chr(0x5c);
$len = $charset = array();
$tmp = null;
if ($mysql->set_charset("latin1")) {
/* 5C should be escaped */

View File

@@ -11,7 +11,6 @@ require_once 'skipifconnectfailure.inc';
require_once 'connect.inc';
$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$version = $mysql->server_version;
var_dump($mysql->query('DO 1'));

View File

@@ -24,7 +24,7 @@ require_once 'skipifconnectfailure.inc';
if (!$stmt->bind_param('i', $id) || !$stmt->execute())
printf("[003] [%d] %s\n", $stmt->errno, $stmt->error);
if ($res = $link->store_result()) {
if ($link->store_result()) {
printf("[004] Can store result!\n");
} else {
printf("[004] [%d] %s\n", $link->errno, $link->error);

View File

@@ -43,8 +43,6 @@ $link->close();
--FILE--
<?php
require_once 'connect.inc';
$db1 = new mysqli();
$flags = MYSQLI_CLIENT_SSL | MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT;

View File

@@ -16,7 +16,6 @@ try {
echo $e->getMessage() . \PHP_EOL;
}
$test2 = array();
$test2 = array();
try {
$test1 = mysqli_poll($test2, $test3, $tablica, 0);

View File

@@ -16,7 +16,6 @@ $table_create = "CREATE TABLE `test` (
$table_insert = "INSERT INTO `test` SET `id`=?";
$table_select = "SELECT * FROM `test`";
$table_delete = "DELETE FROM `test`";
$id = '1311200011005001566';

View File

@@ -45,8 +45,6 @@ while ($stmt->fetch()) {
echo "Finished 1\n";
$newArray = array();
echo "Finished 2\n";
?>

View File

@@ -67,7 +67,7 @@ $link->query('INSERT INTO t_test VALUES ();');
$stmt = $link->prepare('SELECT * FROM t_test;');
if ($stmt) {
$stmt->execute();
$tid = $t = $t2 = $t3 = $t4 = null;
$tid = $t = $t2 = $t4 = null;
$stmt->bind_result($tid, $t, $t2, $t4, $t6);
while ($stmt->fetch()) {
var_dump($t, $t2, $t4, $t6);

View File

@@ -44,8 +44,6 @@ function func_mysqli_fetch_all(
$tmp = mysqli_fetch_all($result, MYSQLI_BOTH);
$row = $tmp[0];
$fields = mysqli_fetch_fields($result);
if ($regexp_comparison) {
if (!preg_match($regexp_comparison, (string)$row['label']) || !preg_match($regexp_comparison, (string)$row[1])) {
printf("[%04d] Expecting %s/%s [reg exp = %s], got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4,

View File

@@ -16,13 +16,13 @@ mysqli_report(MYSQLI_REPORT_STRICT|MYSQLI_REPORT_ERROR);
$mysqli = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$ca = $mysqli->query('SELECT 1 ');
$c = $ca->fetch_assoc();
$ca->fetch_assoc();
try {
$mysqli->query('SELECT non_existent_column');
} catch (Exception $e) {
echo "Caught exception"."\n";
}
$c = $ca->fetch_assoc();
$ca->fetch_assoc();
print "done!";
?>

View File

@@ -33,7 +33,7 @@ $mysqli->real_query("SELECT (
UNION ALL
SELECT 2
) FROM dual");
$result = new mysqli_result($mysqli);
new mysqli_result($mysqli);
// now make sure the errors are thrown when not using silent mode
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
@@ -65,7 +65,7 @@ $mysqli->real_query("SELECT (
SELECT 2
) FROM dual");
try {
$result = new mysqli_result($mysqli);
new mysqli_result($mysqli);
} catch (mysqli_sql_exception $e) {
echo $e->getMessage()."\n";
}

View File

@@ -78,8 +78,7 @@ mysqli
if (1 !== ($tmp = mysqli_affected_rows($link)))
printf("[025] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp);
$charsets = array('utf8');
foreach ($charsets as $k => $charset) {
foreach (['utf8'] as $charset) {
if (!($res = mysqli_query($link, sprintf("SHOW CHARACTER SET LIKE '%s'", $charset))))
continue;
mysqli_free_result($res);

View File

@@ -31,7 +31,7 @@ if (!have_innodb($link))
/* overrule autocommit */
if (true !== ($tmp = mysqli_begin_transaction($link)))
printf("[011] Got %s - [%d] %s\n", var_dump($tmp, true), mysqli_errno($link), mysqli_error($link));
printf("[011] Got %s - [%d] %s\n", $tmp, mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, 'INSERT INTO test(id) VALUES (1)'))
printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
@@ -72,7 +72,7 @@ if (!have_innodb($link))
} else if (!mysqli_commit($link)) {
printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
} else {
$res = mysqli_query($link, "SELECT id FROM test WHERE id = 2");
mysqli_query($link, "SELECT id FROM test WHERE id = 2");
}
}

View File

@@ -20,9 +20,6 @@ if (mysqli_get_server_version($link) >= 10_00_00)
<?php
require_once 'connect.inc';
$tmp = NULL;
$link = NULL;
if (!$link = my_mysqli_connect($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);

View File

@@ -17,9 +17,6 @@ if (mysqli_get_server_version($link) >= 50600 && mysqli_get_server_version($link
<?php
require_once 'connect.inc';
$tmp = NULL;
$link = NULL;
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[006] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);

View File

@@ -15,9 +15,6 @@ if (mysqli_get_server_version($link) >= 50600)
<?php
require_once 'connect.inc';
$link = NULL;
$tmp = NULL;
$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
if (false !== ($tmp = $mysqli->change_user($user . '_unknown_really', $passwd . 'non_empty', $db)))

View File

@@ -30,7 +30,7 @@ if (!have_innodb($link))
$num = $row['_num'];
assert($num > 0);
if (!$res = mysqli_query($link, 'DELETE FROM test'))
if (false === mysqli_query($link, 'DELETE FROM test'))
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS _num FROM test'))

View File

@@ -15,7 +15,7 @@ require_once 'skipifconnectfailure.inc';
printf("\nClass variables:\n");
$variables = array_keys(get_class_vars(get_class($mysqli)));
sort($variables);
foreach ($variables as $k => $var) {
foreach ($variables as $var) {
try {
printf("%s = '%s'\n", $var, var_export($mysqli->$var, true));
} catch (Error $exception) {
@@ -25,7 +25,7 @@ require_once 'skipifconnectfailure.inc';
printf("\nObject variables:\n");
$variables = array_keys(get_object_vars($mysqli));
foreach ($variables as $k => $var) {
foreach ($variables as $var) {
try {
printf("%s = '%s'\n", $var, var_export($mysqli->$var, true));
} catch (Error $exception) {

View File

@@ -69,12 +69,12 @@ require_once 'skipifconnectfailure.inc';
printf("\nClass variables:\n");
$variables = array_keys(get_class_vars(get_class($mysqli_result)));
sort($variables);
foreach ($variables as $k => $var)
foreach ($variables as $var)
printf("%s\n", $var);
printf("\nObject variables:\n");
$variables = array_keys(get_object_vars($mysqli_result));
foreach ($variables as $k => $var)
foreach ($variables as $var)
printf("%s\n", $var);
printf("\nMagic, magic properties:\n");
@@ -121,9 +121,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));
$res = new mysqli_result($link);
$res = new mysqli_result($link, MYSQLI_STORE_RESULT);
$res = new mysqli_result($link, MYSQLI_USE_RESULT);
new mysqli_result($link);
new mysqli_result($link, MYSQLI_STORE_RESULT);
new mysqli_result($link, MYSQLI_USE_RESULT);
$valid = array(MYSQLI_STORE_RESULT, MYSQLI_USE_RESULT);
do {
@@ -132,7 +132,7 @@ require_once 'skipifconnectfailure.inc';
if ($TEST_EXPERIMENTAL) {
ob_start();
$res = new mysqli_result($link, $mode);
new mysqli_result($link, $mode);
$content = ob_get_contents();
ob_end_clean();
if (!stristr($content, 'Invalid value for resultmode'))

View File

@@ -68,12 +68,12 @@ mysqli
printf("\nClass variables:\n");
$variables = array_keys(get_class_vars(get_class($stmt)));
sort($variables);
foreach ($variables as $k => $var)
foreach ($variables as $var)
printf("%s\n", $var);
printf("\nObject variables:\n");
$variables = array_keys(get_object_vars($stmt));
foreach ($variables as $k => $var)
foreach ($variables as $var)
printf("%s\n", $var);
printf("\nMagic, magic properties:\n");

View File

@@ -10,15 +10,13 @@ require_once 'skipifconnectfailure.inc';
<?php
require_once 'connect.inc';
$tmp = NULL;
$link = NULL;
/* we need to check, if the server allows anonymous login (empty user) */
$tmp = @mysqli_connect('localhost');
$anon_allow = (gettype($tmp) == "object");
$exptype = ($anon_allow) ? "mysqli_object" : "false";
$link = NULL;
$tmp = @mysqli_connect($link);
if (($anon_allow && gettype($tmp) != "object") || (!$anon_allow && $tmp != false)) {
printf("[002] Expecting %s, got %s/%s\n", $exptype, gettype($tmp), $tmp);

View File

@@ -37,9 +37,6 @@ mysqli_close($link);
<?php
require_once 'connect.inc';
$tmp = NULL;
$link = NULL;
$res = NULL;
if (!$link = mysqli_connect($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);

View File

@@ -10,7 +10,6 @@ require_once 'skipifconnectfailure.inc';
<?php
require_once 'connect.inc';
$tmp = NULL;
$link = NULL;
// too many parameter

View File

@@ -10,7 +10,6 @@ require_once 'skipifconnectfailure.inc';
<?php
require_once 'connect.inc';
$tmp = NULL;
$link = NULL;
// too many parameter
@@ -29,7 +28,7 @@ require_once 'skipifconnectfailure.inc';
mysqli_close($link);
if ($link = @my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
if (false !== @my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
printf("[003] Connect to the server should fail using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n",
$host, $user . 'unknown_really', $db, $port, $socket);

View File

@@ -10,11 +10,6 @@ require_once 'skipifconnectfailure.inc';
<?php
require_once 'connect.inc';
$tmp = NULL;
$link = NULL;
$obj = new stdClass();
if ($mysqli = new mysqli($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket) && !mysqli_connect_errno())
printf("[003] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n",
$host, $user . 'unknown_really', $db, $port, $socket);

View File

@@ -10,9 +10,6 @@ require_once 'skipifconnectfailure.inc';
<?php
require_once 'connect.inc';
$tmp = NULL;
$link = NULL;
if ($socket != "")
/* mysqli.default_socket requires non-empty string */
ini_set('mysqli.default_socket', 'socket');

View File

@@ -107,7 +107,6 @@ $expected_constants['MYSQLI_STORE_RESULT_COPY_DATA'] = true;
$expected_constants['MYSQLI_REFRESH_BACKUP_LOG'] = 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;
@@ -154,7 +153,7 @@ $expected_constants["MYSQLI_TYPE_JSON"] = true;
$unexpected_constants = array();
foreach ($constants as $group => $consts) {
foreach ($constants as $consts) {
foreach ($consts as $name => $value) {
if (stristr($name, 'mysqli')) {
$name = strtoupper($name);

View File

@@ -31,7 +31,7 @@ if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
return false;
}
if (!$res = mysqli_query($link, 'SELECT * FROM test')) {
if (false === mysqli_query($link, 'SELECT * FROM test')) {
printf("[%03d][control string '%s'] [%d] %s.\n",
$offset + 2,
$control_string,

View File

@@ -40,7 +40,7 @@ if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
mysqli_error($link));
return false;
}
while ($row = mysqli_fetch_assoc($res))
while (mysqli_fetch_assoc($res))
;
mysqli_free_result($res);
@@ -97,7 +97,7 @@ if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
// -t,[N] - maximum nesting level
$trace = try_control_string($link, 't,1:n:O,' . $trace_file, $trace_file, 70);
$lines = explode("\n", $trace);
foreach ($lines as $k => $line) {
foreach ($lines as $line) {
$line = trim($line);
if (!preg_match("@^(\d+):+@ismU", $line, $matches)) {
printf("[075] Nesting level seem to be missing, first characters from trace are '%s'\n", substr($line, 0, 80));
@@ -113,7 +113,7 @@ if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
// omitting t
$trace = try_control_string($link, 'n:O,' . $trace_file, $trace_file, 80);
$lines = explode("\n", $trace);
foreach ($lines as $k => $line) {
foreach ($lines as $line) {
$line = trim($line);
if (preg_match("@^[|\s]*>[\w]+@ism", $line, $matches)) {
printf("[085] Looks like a function call, but there should be none in the trace file, first characters from trace are '%s'\n",
@@ -124,7 +124,7 @@ if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
// -f[,functions] - Limit debugger list to specified functions. Empty list -> all functions
$lines_all_funcs = explode("\n", try_control_string($link, 't:O,' . $trace_file, $trace_file, 90));
$functions_all_funcs = array();
foreach ($lines_all_funcs as $k => $line) {
foreach ($lines_all_funcs as $line) {
$line = trim($line);
if (preg_match("@^[|\s]*>([\w:]+)@ism", $line, $matches)) {
$functions_all_funcs[$matches[1]] = $matches[1];
@@ -133,7 +133,7 @@ if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
$lines_trace = explode("\n", try_control_string($link, 't:f:O,' . $trace_file, $trace_file, 100));
$functions_trace = array();
foreach ($lines_trace as $k => $line) {
foreach ($lines_trace as $line) {
$line = trim($line);
if (preg_match("@^[|\s]*>([\w:]+)@ism", $line, $matches)) {
$functions_trace[$matches[1]] = $matches[1];
@@ -169,7 +169,7 @@ if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
$lines_trace = explode("\n", try_control_string($link, $control_string, $trace_file, 110));
$functions_trace = array();
foreach ($lines_trace as $k => $line) {
foreach ($lines_trace as $line) {
$line = trim($line);
if (preg_match("@^[|\s]*>([\w:]+)@ism", $line, $matches)) {
$functions_trace[$matches[1]] = $matches[1];

View File

@@ -39,7 +39,7 @@ if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
mysqli_error($link));
return false;
}
while ($row = mysqli_fetch_assoc($res))
while (mysqli_fetch_assoc($res))
;
mysqli_free_result($res);
@@ -73,7 +73,7 @@ if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
$lines_trace = explode("\n", $trace);
$functions_trace = array();
foreach ($lines_trace as $k => $line) {
foreach ($lines_trace as $line) {
$line = trim($line);
if (preg_match("@^[|\s]*>([\w:]+)@ism", $line, $matches)) {
$functions_trace[$matches[1]] = $matches[1];
@@ -81,7 +81,7 @@ if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
}
$found = 0;
foreach ($memory_funcs as $k => $name)
foreach ($memory_funcs as $name)
if (isset($functions_trace[$name]))
$found++;
@@ -97,7 +97,7 @@ if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
$lines_trace = explode("\n", $trace);
$functions_trace = array();
foreach ($lines_trace as $k => $line) {
foreach ($lines_trace as $line) {
$line = trim($line);
if (preg_match("@^[|\s]*>([\w:]+)@ism", $line, $matches)) {
$functions_trace[$matches[1]] = $matches[1];
@@ -105,7 +105,7 @@ if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
}
$found = 0;
foreach ($memory_funcs as $k => $name)
foreach ($memory_funcs as $name)
if (isset($functions_trace[$name]))
$found++;

View File

@@ -10,9 +10,6 @@ require_once 'skipifconnectfailure.inc';
<?php
require_once 'connect.inc';
$tmp = NULL;
$link = NULL;
if (!$mysqli = new 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);

View File

@@ -10,9 +10,6 @@ require_once 'skipifconnectfailure.inc';
<?php
require_once 'connect.inc';
$tmp = NULL;
$link = NULL;
$mysqli = new mysqli();
if (0 !== ($tmp = @$mysqli->errno))
printf("[001] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp);

View File

@@ -10,9 +10,6 @@ require_once 'skipifconnectfailure.inc';
<?php
require_once 'connect.inc';
$tmp = NULL;
$link = NULL;
$mysqli = new mysqli();
if ('' !== ($tmp = @$mysqli->error))
printf("[001] Expecting empty string, got %s/'%s'\n", gettype($tmp), $tmp);

View File

@@ -36,7 +36,7 @@ if (!($tmp = $link->execute_query("SELECT ? AS a, ? AS b, ? AS c", [42, "foo", n
assert($tmp->fetch_assoc() === ['a' => '42', 'b' => 'foo', 'c' => null]);
// prepare error
if (!($tmp = $link->execute_query("some random gibberish", [1, "foo"]))) {
if (false === $link->execute_query("some random gibberish", [1, "foo"])) {
printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}

View File

@@ -26,7 +26,7 @@ require_once 'skipifconnectfailure.inc';
$field_names[$name] = gettype($value);
}
while ($row = mysqli_fetch_assoc($res))
while (mysqli_fetch_assoc($res))
$num_rows++;
if (($tmp = mysqli_num_rows($res)) !== $num_rows) {
@@ -43,12 +43,12 @@ require_once 'skipifconnectfailure.inc';
$num_fields, gettype($tmp), $tmp);
}
foreach ($fields as $k => $field) {
foreach ($fields as $field) {
$field->max_length = 0;// change it or we will get diff error
if (isset($field_names[$field->name])) {
unset($field_names[$field->name]);
} else {
printf("[006] Unexpected field '%s', dumping info\n");
printf("[006] Unexpected field '%s', dumping info\n", $field->name);
var_dump($field);
}
}

View File

@@ -86,14 +86,14 @@ require_once 'skipifconnectfailure.inc';
return false;
}
if (!$link->query($sql = sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) {
if (!$link->query(sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) {
// don't bail, engine might not support the datatype
return false;
}
if (is_null($php_value)) {
if (!$link->query($sql = sprintf("INSERT INTO test(id, label) VALUES (1, NULL)"))) {
printf("[%04d] [%d] %s\n", $offset + 1, $link->errno, $link->error);
printf("[%04d] [%d] %s - %s\n", $offset + 1, $link->errno, $link->error, $sql);
return false;
}
} else {
@@ -104,7 +104,7 @@ require_once 'skipifconnectfailure.inc';
}
} else {
if (!$link->query($sql = sprintf("INSERT INTO test(id, label) VALUES (1, '%d')", $sql_value))) {
printf("[%04di] [%d] %s\n", $offset + 1, $link->errno, $link->error);
printf("[%04di] [%d] %s - %s\n", $offset + 1, $link->errno, $link->error, $sql);
return false;
}
}

View File

@@ -31,7 +31,7 @@ require_once 'skipifconnectfailure.inc';
mysqli_free_result($res);
if (!$res = mysqli_query($link, "SELECT 1 AS a, 2 AS a, 3 AS c, 4 AS C, NULL AS d, true AS e")) {
printf("[010] Cannot run query, [%d] %s\n", mysqli_errno($link), $mysqli_error($link));
printf("[010] Cannot run query, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
print "[011]\n";
var_dump(mysqli_fetch_array($res, MYSQLI_BOTH));
@@ -39,7 +39,7 @@ require_once 'skipifconnectfailure.inc';
mysqli_free_result($res);
if (!$res = mysqli_query($link, "SELECT 1 AS a, 2 AS b, 3 AS c, 4 AS C")) {
printf("[012] Cannot run query, [%d] %s\n",
mysqli_errno($link), $mysqli_error($link));
mysqli_errno($link), mysqli_error($link));
exit(1);
}
@@ -61,7 +61,7 @@ require_once 'skipifconnectfailure.inc';
mysqli_free_result($res);
function func_mysqli_fetch_array($link, $engine, $sql_type, $sql_value, $php_value, $offset, $regexp_comparison = NULL, $binary_type = false) {
function func_mysqli_fetch_array($link, $engine, $sql_type, $sql_value, $php_value, $offset, $regexp_comparison = NULL) {
if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) {
printf("[%04d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));

View File

@@ -12,7 +12,6 @@ require_once 'skipifconnectfailure.inc';
require 'table.inc';
// do as much as we can do in 5 seconds
$start = microtime(true);
for ($id = 100, $start = microtime(true); (microtime(true) - $start) < 5; $id++) {
if (!mysqli_query($link, $sql = sprintf("INSERT INTO test(id, label) VALUES (%d, '%s')",
$id, mysqli_real_escape_string($link, chr(65 + ($id % 26)))))) {
@@ -52,7 +51,7 @@ require_once 'skipifconnectfailure.inc';
}
if ($row[0] !== $row['id']) {
printf("[005] Unexpected result row[0] = '%s', row[id] = '%s', [%d] %s\n",
$row[0], $row[id], mysqli_errno($link), mysqli_error($link));
$row[0], $row['id'], mysqli_errno($link), mysqli_error($link));
break;
}

View File

@@ -70,14 +70,14 @@ require_once 'skipifconnectfailure.inc';
return false;
}
if (!$mysqli->query($sql = sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) {
if (!$mysqli->query(sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) {
// don't bail, engine might not support the datatype
return false;
}
if (is_null($php_value)) {
if (!$mysqli->query($sql = sprintf("INSERT INTO test(id, label) VALUES (1, NULL)"))) {
printf("[%04d] [%d] %s\n", $offset + 1, $mysqli->errno, $mysqli->error);
printf("[%04d] [%d] %s - %s\n", $offset + 1, $mysqli->errno, $mysqli->error, $sql);
return false;
}
} else {
@@ -88,7 +88,7 @@ require_once 'skipifconnectfailure.inc';
}
} else {
if (!$mysqli->query($sql = sprintf("INSERT INTO test(id, label) VALUES (1, '%d')", $sql_value))) {
printf("[%04di] [%d] %s\n", $offset + 1, $mysqli->errno, $mysqli->error);
printf("[%04di] [%d] %s - %s\n", $offset + 1, $mysqli->errno, $mysqli->error, $sql);
return false;
}
}

View File

@@ -39,7 +39,6 @@ if (mysqli_get_server_version($link) < 50003)
$max_value = 1;
else
$max_value = pow(2, $bits) - 1;
$tests = 0;
if (!mysqli_query($link, "DROP TABLE IF EXISTS test") ||
!mysqli_query($link, $sql = sprintf('CREATE TABLE test(id BIGINT, bit_value BIT(%d) NOT NULL, bit_null BIT(%d) DEFAULT NULL) ENGINE="%s"', $bits, $bits, $engine)))
printf("[002 - %d] [%d] %s\n",$bits, mysqli_errno($link), mysqli_error($link));

View File

@@ -39,7 +39,7 @@ require_once 'skipifconnectfailure.inc';
mysqli_free_result($res);
/* Now do it with unbuffered queries */
if (!$res = mysqli_real_query($link, "SELECT 1, 2")) {
if (false === mysqli_real_query($link, "SELECT 1, 2")) {
printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (!$res = mysqli_use_result($link)) {
@@ -49,7 +49,7 @@ require_once 'skipifconnectfailure.inc';
var_dump(mysqli_fetch_assoc($res));
mysqli_free_result($res);
if (!$res = mysqli_real_query($link, "SELECT 1 AS a, 2")) {
if (false === mysqli_real_query($link, "SELECT 1 AS a, 2")) {
printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (!$res = mysqli_use_result($link)) {
@@ -59,7 +59,7 @@ require_once 'skipifconnectfailure.inc';
var_dump(mysqli_fetch_assoc($res));
mysqli_free_result($res);
if (!$res = mysqli_real_query($link, "SELECT 1 AS a, 2, 2 as '2'")) {
if (false === mysqli_real_query($link, "SELECT 1 AS a, 2, 2 as '2'")) {
printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (!$res = mysqli_use_result($link)) {
@@ -69,7 +69,7 @@ require_once 'skipifconnectfailure.inc';
var_dump(mysqli_fetch_assoc($res));
mysqli_free_result($res);
if (!$res = mysqli_real_query($link, "SELECT 1 AS a, 2 as '2', 2")) {
if (false === mysqli_real_query($link, "SELECT 1 AS a, 2 as '2', 2")) {
printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (!$res = mysqli_use_result($link)) {

View File

@@ -42,7 +42,7 @@ mysqli
}
/* some cyrillic (utf8) comes here */
if (!$res = mysqli_query($link, "SET NAMES UTF8")) {
if (false === mysqli_query($link, "SET NAMES UTF8")) {
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
@@ -53,16 +53,16 @@ mysqli
var_dump(mysqli_fetch_assoc($res));
mysqli_free_result($res);
if (!$res = mysqli_query($link, "CREATE TABLE автори_на_mysqlnd (id integer not null auto_increment primary key, име varchar(20) character set ucs2, фамилия varchar(20) character set utf8)")) {
if (false === mysqli_query($link, "CREATE TABLE автори_на_mysqlnd (id integer not null auto_increment primary key, име varchar(20) character set ucs2, фамилия varchar(20) character set utf8)")) {
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (!$res = mysqli_query($link, "INSERT INTO автори_на_mysqlnd (име, фамилия) VALUES ('Андрей', 'Христов'), ('Георг', 'Рихтер'), ('Улф','Вендел')")) {
if (false === mysqli_query($link, "INSERT INTO автори_на_mysqlnd (име, фамилия) VALUES ('Андрей', 'Христов'), ('Георг', 'Рихтер'), ('Улф','Вендел')")) {
printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (!$res = mysqli_query($link, "INSERT INTO автори_на_mysqlnd (име, фамилия) VALUES ('Andrey', 'Hristov'), ('Georg', 'Richter'), ('Ulf','Wendel')")) {
if (false === mysqli_query($link, "INSERT INTO автори_на_mysqlnd (име, фамилия) VALUES ('Andrey', 'Hristov'), ('Georg', 'Richter'), ('Ulf','Wendel')")) {
printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (!$res = mysqli_query($link, "INSERT INTO автори_на_mysqlnd (име, фамилия) VALUES ('安德烈', 'Hristov'), ('格奥尔', 'Richter'), ('乌尔夫','Wendel')")) {
if (false === mysqli_query($link, "INSERT INTO автори_на_mysqlnd (име, фамилия) VALUES ('安德烈', 'Hristov'), ('格奥尔', 'Richter'), ('乌尔夫','Wendel')")) {
printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
@@ -75,7 +75,7 @@ mysqli
}
mysqli_free_result($res);
if (!$res = mysqli_query($link, "DROP TABLE автори_на_mysqlnd")) {
if (false === mysqli_query($link, "DROP TABLE автори_на_mysqlnd")) {
printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}

View File

@@ -187,7 +187,7 @@ mysqli_close($link);
$column_def = array('col1 CHAR(1)', 'col2 CHAR(2)','INDEX idx_col1_col2(col1, col2)');
$expected_flags = array('col1' => 'MULTIPLE_KEY PART_KEY', 'col2' => 'PART_KEY');
$create = 'CREATE TABLE test(id INT, ';
foreach ($column_def as $k => $v) {
foreach ($column_def as $v) {
$create .= sprintf('%s, ', $v);
}
$create = sprintf('%s)', substr($create, 0, -2));
@@ -198,7 +198,7 @@ mysqli_close($link);
mysqli_errno($link), mysqli_error($link));
}
// id column - skip it
$field = mysqli_fetch_field($res);
mysqli_fetch_field($res);
while ($field = mysqli_fetch_field($res)) {
if (!isset($expected_flags[$field->name])) {
printf("[010] Found unexpected field '%s'\n", $field->name);

View File

@@ -9,13 +9,12 @@ require_once 'skipifconnectfailure.inc';
--FILE--
<?php
require 'table.inc';
$mysqli = $link;
if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id LIMIT 1")) {
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
var_dump(mysqli_fetch_lengths($res));
while ($row = mysqli_fetch_assoc($res))
while (mysqli_fetch_assoc($res))
var_dump(mysqli_fetch_lengths($res));
var_dump(mysqli_fetch_lengths($res));

View File

@@ -15,7 +15,7 @@ require_once 'skipifconnectfailure.inc';
}
var_dump($res->lengths);
while ($row = $res->fetch_assoc())
while ($res->fetch_assoc())
var_dump($res->lengths);
var_dump($res->lengths);

View File

@@ -122,7 +122,7 @@ require_once 'skipifconnectfailure.inc';
var_dump($obj = new mysqli_fetch_object_private_constructor(1, 2));
This does not fail.
*/
$obj = mysqli_fetch_object($res, 'mysqli_fetch_object_private_constructor', array('a', 'b'));
mysqli_fetch_object($res, 'mysqli_fetch_object_private_constructor', array('a', 'b'));
mysqli_free_result($res);
try {

View File

@@ -24,13 +24,9 @@ require_once 'skipifconnectfailure.inc';
if (!$res = mysqli_query($link, $sql = sprintf("SHOW CHARACTER SET LIKE '%s'", $character_set_connection)))
printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$tmp = mysqli_fetch_assoc($res);
if (empty($tmp))
if (!mysqli_fetch_assoc($res))
printf("[010] Cannot fetch Maxlen and/or Comment, test will fail: $sql\n");
$maxlen = (isset($tmp['Maxlen'])) ? $tmp['Maxlen'] : '';
$comment = (isset($tmp['Description'])) ? $tmp['Description'] : '';
if (!$res = mysqli_query($link, sprintf("SHOW COLLATION LIKE '%s'", $collation_connection)))
printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$tmp = mysqli_fetch_assoc($res);

View File

@@ -85,7 +85,7 @@ mysqli.allow_local_infile=1
var_dump($info);
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
if (false === my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
exit(1);
@@ -243,7 +243,7 @@ mysqli.allow_local_infile=1
mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_unbuffered', $info, $expected, $test_counter);
mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
while ($row = mysqli_fetch_assoc($res))
while (mysqli_fetch_assoc($res))
;
mysqli_free_result($res);
@@ -270,7 +270,7 @@ mysqli.allow_local_infile=1
++$test_counter, mysqli_errno($link), mysqli_error($link));
for ($i = 0; $i < $num_rows - 1; $i++)
$row = mysqli_fetch_assoc($res);
mysqli_fetch_assoc($res);
$expected['rows_fetched_from_server_normal'] = (string)($expected['rows_fetched_from_server_normal'] + $num_rows - 1);
$expected['rows_fetched_from_client_normal_unbuffered'] = (string)($expected['rows_fetched_from_client_normal_unbuffered'] + $num_rows - 1);
@@ -551,7 +551,7 @@ mysqli.allow_local_infile=1
mysqli_errno($link), mysqli_error($link));
$rows = 0;
while ($row = mysqli_fetch_assoc($res))
while (mysqli_fetch_assoc($res))
$rows++;
if (0 == $rows)
@@ -617,7 +617,6 @@ mysqli.allow_local_infile=1
++$test_counter, gettype($new_info), $new_info);
mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 2), $test_counter, 'DROP INDEX');
}
$info = $new_info;
// RENAME TABLE
if (!mysqli_query($link, "DROP TABLE IF EXISTS client_stats_test"))
@@ -640,7 +639,6 @@ mysqli.allow_local_infile=1
mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'RENAME TABLE');
}
$info = $new_info;
if (!mysqli_query($link, "DROP TABLE IF EXISTS non_result_set_queries_test"))
printf("[%03d] Cleanup, DROP TABLE failed, [%d] %s\n", ++$test_counter,
@@ -675,7 +673,6 @@ mysqli.allow_local_infile=1
printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
++$test_counter, gettype($new_info), $new_info);
mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'CREATE DATABASE');
$info = $new_info;
if (!mysqli_query($link, "CREATE DATABASE mysqli_get_client_stats_"))
printf("[%03d] CREATE DATABASE failed, [%d] %s\n", ++$test_counter,
@@ -693,7 +690,6 @@ mysqli.allow_local_infile=1
printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
++$test_counter, gettype($new_info), $new_info);
mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'DROP DATABASE');
$info = $new_info;
}
// CREATE SERVER, ALTER SERVER, DROP SERVER
@@ -812,7 +808,7 @@ mysqli.allow_local_infile=1
mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'DELETE');
$info = $new_info;
if (!$res = mysqli_query($link, "TRUNCATE TABLE test"))
if (false === mysqli_query($link, "TRUNCATE TABLE test"))
printf("[%03d] TRUNCATE failed, [%d] %s\n", ++$test_counter,
mysqli_errno($link), mysqli_error($link));
@@ -854,7 +850,7 @@ mysqli.allow_local_infile=1
printf("[%03d] Cannot insert new records, [%d] %s\n", ++$test_counter,
mysqli_errno($link), mysqli_error($link));
if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id"))
if (false === mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id"))
printf("[%03d] Cannot SELECT with mysqli_real_query(), [%d] %s\n", ++$test_counter,
mysqli_errno($link), mysqli_error($link));
@@ -862,7 +858,7 @@ mysqli.allow_local_infile=1
printf("[%03d] mysqli_use_result() failed, [%d] %s\n", ++$test_counter,
mysqli_errno($link), mysqli_error($link));
while ($row = mysqli_fetch_assoc($res))
while (mysqli_fetch_assoc($res))
;
mysqli_free_result($res);
if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
@@ -871,7 +867,7 @@ mysqli.allow_local_infile=1
mysqli_get_client_stats_assert_eq('unbuffered_sets', $new_info, (string)($info['unbuffered_sets'] + 1), $test_counter, 'mysqli_use_result()');
$info = $new_info;
if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id"))
if (false === mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id"))
printf("[%03d] Cannot SELECT with mysqli_real_query() II, [%d] %s\n", ++$test_counter,
mysqli_errno($link), mysqli_error($link));
@@ -879,7 +875,7 @@ mysqli.allow_local_infile=1
printf("[%03d] mysqli_use_result() failed, [%d] %s\n", ++$test_counter,
mysqli_errno($link), mysqli_error($link));
while ($row = mysqli_fetch_assoc($res))
while (mysqli_fetch_assoc($res))
;
mysqli_free_result($res);
if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))

View File

@@ -29,7 +29,7 @@ require_once 'skipifconnectfailure.inc';
/* fetch all rows but the last one */
for ($i = 0; $i < $num_rows - 1; $i++)
$row = mysqli_fetch_assoc($res);
mysqli_fetch_assoc($res);
/* enforce implicit cleaning of the wire and skipping the last row */
mysqli_free_result($res);

View File

@@ -12,24 +12,12 @@ if (!$TEST_EXPERIMENTAL)
<?php
require_once 'connect.inc';
$tmp = NULL;
$link = NULL;
if (!is_null($tmp = @mysqli_get_warnings()))
printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
if (!is_null($tmp = @mysqli_get_warnings($link)))
printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
if (!is_null($tmp = @mysqli_get_warnings('')))
printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("[003] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
}
if (false !== ($tmp = mysqli_get_warnings($link))) {
printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp));
printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), var_export($tmp, true));
}
if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
@@ -42,7 +30,7 @@ if (!$TEST_EXPERIMENTAL)
printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!is_object($warning = mysqli_get_warnings($link)) || 'mysqli_warning' != get_class($warning)) {
printf("[008] Expecting object/mysqli_warning, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp));
printf("[008] Expecting object/mysqli_warning, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_export($tmp, true) : $tmp));
}
if (!method_exists($warning, 'next'))
@@ -71,7 +59,7 @@ if (!$TEST_EXPERIMENTAL)
printf("[016] Expecting 2 warnings, got %d warnings", $tmp);
if (!is_object($warning = mysqli_get_warnings($link)) || 'mysqli_warning' != get_class($warning)) {
printf("[017] Expecting object/mysqli_warning, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp));
printf("[017] Expecting object/mysqli_warning, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_export($tmp, true) : $tmp));
}
if (true !== ($tmp = $warning->next()))
@@ -129,7 +117,7 @@ if (!$TEST_EXPERIMENTAL)
if (3 != $i)
printf("[034] Expecting three warnings, got %d warnings\n", $i);
$stmt = mysqli_stmt_init();
$stmt = mysqli_stmt_init($mysqli);
$warning = new mysqli_warning($stmt);
if (false !== ($tmp = $warning->next()))
printf("[035] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);

View File

@@ -11,43 +11,42 @@ mysqli.allow_local_infile=1
--FILE--
<?php
require 'table.inc';
if (!$res = mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, 'a')"))
if (false === mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, 'a')"))
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
// NOTE: empty string, no multiple insert syntax
if (!is_null($tmp = mysqli_info($link)) || ('' != $tmp))
printf("[004] Expecting null, got %s/%s\n", gettype($tmp), $tmp);
if (!$res = mysqli_query($link, "INSERT INTO test(id, label) VALUES (101, 'a'), (102, 'b')"))
if (false === mysqli_query($link, "INSERT INTO test(id, label) VALUES (101, 'a'), (102, 'b')"))
printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp))
printf("[006] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
if (!$res = mysqli_query($link, 'INSERT INTO test(id, label) SELECT id + 200, label FROM test'))
if (false === mysqli_query($link, 'INSERT INTO test(id, label) SELECT id + 200, label FROM test'))
printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp))
printf("[008] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
if (!$res = mysqli_query($link, 'ALTER TABLE test MODIFY label CHAR(2)'))
if (false === mysqli_query($link, 'ALTER TABLE test MODIFY label CHAR(2)'))
printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp))
printf("[010] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
if (!$res = mysqli_query($link, "UPDATE test SET label = 'b' WHERE id >= 100"))
if (false === mysqli_query($link, "UPDATE test SET label = 'b' WHERE id >= 100"))
printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp))
printf("[012] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
if (!$res = mysqli_query($link, "SELECT 1"))
if (false === mysqli_query($link, "SELECT 1"))
printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!is_null($tmp = mysqli_info($link)) || ('' != $tmp))
printf("[014] Expecting null, got %s/%s\n", gettype($tmp), $tmp);
mysqli_free_result($res);
// NOTE: no LOAD DATA INFILE test
if ($dir = sys_get_temp_dir()) {

View File

@@ -13,25 +13,24 @@ require_once 'skipifconnectfailure.inc';
if (0 !== ($tmp = mysqli_insert_id($link)))
printf("[003] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp);
if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id LIMIT 1")) {
if (false === mysqli_query($link, "SELECT id, label FROM test ORDER BY id LIMIT 1")) {
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (0 !== ($tmp = mysqli_insert_id($link)))
printf("[005] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp);
mysqli_free_result($res);
// no auto_increment column
if (!$res = mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, 'a')")) {
if (false === mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, 'a')")) {
printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (0 !== ($tmp = mysqli_insert_id($link)))
printf("[007] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp);
if (!$res = mysqli_query($link, "ALTER TABLE test MODIFY id INT NOT NULL AUTO_INCREMENT")) {
if (false === mysqli_query($link, "ALTER TABLE test MODIFY id INT NOT NULL AUTO_INCREMENT")) {
printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (!$res = mysqli_query($link, "INSERT INTO test(label) VALUES ('a')")) {
if (false === mysqli_query($link, "INSERT INTO test(label) VALUES ('a')")) {
printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (($last_id = mysqli_insert_id($link)) <= 0)
@@ -101,13 +100,13 @@ require_once 'skipifconnectfailure.inc';
mysqli_query($link, "UNLOCK TABLE test");
}
if (!$res = mysqli_query($link, "INSERT INTO test(id, label) VALUES (1000, 'a')")) {
if (false === mysqli_query($link, "INSERT INTO test(id, label) VALUES (1000, 'a')")) {
printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (1000 !== ($tmp = mysqli_insert_id($link)))
printf("[021] Expecting int/1000, got %s/%s\n", gettype($tmp), $tmp);
if (!$res = mysqli_query($link, "INSERT INTO test(label) VALUES ('b'), ('c')")) {
if (false === mysqli_query($link, "INSERT INTO test(label) VALUES ('b'), ('c')")) {
printf("[022] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (1000 >= ($tmp = mysqli_insert_id($link)))

View File

@@ -4,19 +4,7 @@ INSERT and packet overflow
mysqli
--SKIPIF--
<?php
require_once 'connect.inc';
if (!$link = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
die(sprintf("SKIP [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()));
$max_len = pow(2, 24);
if (!$res = mysqli_query($link, "SHOW GLOBAL VARIABLES LIKE 'max_allowed_packet'"))
die(sprintf("SKIP [%d] %s\n", mysqli_errno($link), mysqli_error($link)));
if (!mysqli_query($link, "SET NAMES 'latin1'"))
die(sprintf("SKIP [%d] %s\n", mysqli_errno($link), mysqli_error($link)));
mysqli_close($link);
require_once 'skipifconnectfailure.inc';
?>
--INI--
memory_limit=256M

View File

@@ -19,12 +19,10 @@ require_once 'skipifconnectfailure.inc';
if (!$thread_id = mysqli_thread_id($link))
printf("[004] Cannot determine thread id, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$tmp = mysqli_kill($link, $thread_id);
if (!is_bool($tmp))
printf("[005] Expecting boolean/any, got %s/%s\n", gettype($tmp), $tmp);
mysqli_kill($link, $thread_id);
if ($res = mysqli_query($link, "SELECT id FROM test LIMIT 1"))
pintf("[006] Expecting boolean/false, got %s/%s\n", gettype($res), $res);
printf("[006] Expecting boolean/false, got %s/%s\n", gettype($res), $res);
var_dump($error = mysqli_error($link));
if (!is_string($error) || ('' === $error))

View File

@@ -39,7 +39,7 @@ require_once 'skipifconnectfailure.inc';
// NOTE: if you use mysqli_use_result() with mysqli_more_results() or any other info function,
// you must fetch all rows before you can loop to the next result set!
// See also the MySQL Reference Manual: mysql_use_result()
while ($row = mysqli_fetch_array($res))
while (mysqli_fetch_array($res))
;
mysqli_free_result($res);
if (mysqli_more_results($link))

View File

@@ -19,7 +19,7 @@ require_once 'skipifconnectfailure.inc';
$i = 0;
do {
$res = mysqli_store_result($link);
while ($row = mysqli_fetch_array($res))
while (mysqli_fetch_array($res))
;
mysqli_free_result($res);
$i++;
@@ -33,7 +33,7 @@ require_once 'skipifconnectfailure.inc';
$i = 0;
while (mysqli_next_result($link) && ($res = mysqli_store_result($link))) {
while ($row = mysqli_fetch_array($res))
while (mysqli_fetch_array($res))
;
mysqli_free_result($res);
printf("%d/%d\n", $i, mysqli_insert_id($link));
@@ -46,7 +46,7 @@ require_once 'skipifconnectfailure.inc';
$i = 0;
while (mysqli_next_result($link) && ($res = mysqli_store_result($link))) {
while ($row = mysqli_fetch_array($res))
while (mysqli_fetch_array($res))
$i++;
mysqli_free_result($res);
}
@@ -77,7 +77,7 @@ require_once 'skipifconnectfailure.inc';
printf("[015 - %d] [%d] %s\n", $res_num, mysqli_errno($link), mysqli_error($link));
if (count($lengths) != 2)
printf("[016 - %d] Expecting 2 column lengths got %d [%d] %s\n", $res_num, count($lengths));
printf("[016 - %d] Expecting 2 column lengths got %d\n", $res_num, count($lengths));
foreach ($lengths as $k => $length)
if ($length <= 0)
@@ -87,7 +87,7 @@ require_once 'skipifconnectfailure.inc';
}
if ($num_rows != 1)
printf("[018 - %d] Expecting 1 row, got %d rows\n", $num_rows);
printf("[018 - %d] Expecting 1 row, got %d rows\n", $res_num, $num_rows);
$res_num++;

View File

@@ -18,7 +18,7 @@ mysqlnd.net_read_timeout=1
printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
}
if (!$res = mysqli_query($link, "SELECT SLEEP(5)"))
if (false === mysqli_query($link, "SELECT SLEEP(5)"))
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);

View File

@@ -67,7 +67,7 @@ require_once 'skipifconnectfailure.inc';
if (false !== @mysqli_ping($link))
printf("[010] Reconnect should not have happened");
if ($res = @mysqli_query($link, "SELECT DATABASE() as _dbname"))
if (@mysqli_query($link, "SELECT DATABASE() as _dbname"))
printf("[011] Executing a query should not be possible, connection should be closed, [%d] %s\n",
mysqli_errno($link), mysqli_error($link));
@@ -111,7 +111,7 @@ require_once 'skipifconnectfailure.inc';
if (false !== ($tmp = @mysqli_ping($link)))
printf("[016] Expecting boolean/false got %s/%s\n", gettype($tmp), $tmp);
if ($res = @mysqli_query($link, "SELECT DATABASE() as _dbname"))
if (@mysqli_query($link, "SELECT DATABASE() as _dbname"))
printf("[017] Running a query should not be possible, connection should be gone, [%d] %s\n",
mysqli_errno($link), mysqli_error($link));

View File

@@ -10,7 +10,7 @@ require_once 'skipifconnectfailure.inc';
<?php
require 'table.inc';
function func_test_mysqli_num_fields($link, $query, $expected, $offset, $test_free = false) {
function func_test_mysqli_num_fields(mysqli $link, string $query, int $expected, int $offset) {
if (!($res = mysqli_query($link, $query))) {
printf("[%03d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
@@ -34,7 +34,7 @@ require_once 'skipifconnectfailure.inc';
func_test_mysqli_num_fields($link, "SELECT 1 AS a", 1, 5);
func_test_mysqli_num_fields($link, "SELECT id, label FROM test", 2, 10);
func_test_mysqli_num_fields($link, "SELECT 1 AS a, NULL AS b, 'foo' AS c", 3, 15);
func_test_mysqli_num_fields($link, "SELECT id FROM test", 1, 20, true);
func_test_mysqli_num_fields($link, "SELECT id FROM test", 1, 20);
mysqli_close($link);

View File

@@ -10,7 +10,7 @@ require_once 'skipifconnectfailure.inc';
<?php
require 'table.inc';
function func_test_mysqli_num_rows($link, $query, $expected, $offset, $test_free = false) {
function func_test_mysqli_num_rows(mysqli $link, string $query, int|null $expected, int $offset) {
if (!$res = mysqli_query($link, $query, MYSQLI_STORE_RESULT)) {
printf("[%03d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
@@ -36,7 +36,7 @@ require_once 'skipifconnectfailure.inc';
func_test_mysqli_num_rows($link, "SELECT 1 AS a", 1, 5);
func_test_mysqli_num_rows($link, "SHOW VARIABLES LIKE '%nixnutz%'", 0, 10);
func_test_mysqli_num_rows($link, "INSERT INTO test(id, label) VALUES (100, 'z')", NULL, 15);
func_test_mysqli_num_rows($link, "SELECT id FROM test LIMIT 2", 2, 20, true);
func_test_mysqli_num_rows($link, "SELECT id FROM test LIMIT 2", 2, 20);
if ($res = mysqli_query($link, 'SELECT COUNT(id) AS num FROM test')) {
@@ -53,7 +53,7 @@ require_once 'skipifconnectfailure.inc';
if ($res = mysqli_query($link, 'SELECT id FROM test', MYSQLI_USE_RESULT)) {
$row = mysqli_fetch_row($res);
mysqli_fetch_row($res);
try {
var_dump(mysqli_num_rows($res));
} catch (\Error $e) {

View File

@@ -101,9 +101,10 @@ echo "nocache";
return false;
}
if (!$res = $link->query("SELECT id FROM test WHERE id = 1"))
if (!$res = $link->query("SELECT id FROM test WHERE id = 1")) {
printf("[%03d + 003] [%d] %s\n", $offset, $link->errno, $link->error);
return false;
}
if (!$row = mysqli_fetch_assoc($res)) {
printf("[%03d + 004] [%d] %s\n", $offset, $link->errno, $link->error);

View File

@@ -29,7 +29,7 @@ mysqli
die("skip GRANT failed");
}
if (!($link_pcontest = @my_mysqli_connect($host, 'pcontest', 'pcontest', $db, $port, $socket))) {
if (!@my_mysqli_connect($host, 'pcontest', 'pcontest', $db, $port, $socket)) {
mysqli_query($link, 'REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest');
mysqli_query($link, 'REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest@localhost');
mysqli_query($link, 'DROP USER pcontest@localhost');
@@ -56,7 +56,7 @@ mysqli.rollback_on_cached_plink=1
!mysqli_query($link, sprintf("GRANT SELECT ON TABLE %s.test TO pcontest@'%%'", $db)) ||
!mysqli_query($link, sprintf("GRANT SELECT ON TABLE %s.test TO pcontest@'localhost'", $db))) {
printf("[000] Init failed, [%d] %s\n",
mysqli_errno($plink), mysqli_error($plink));
mysqli_errno($link), mysqli_error($link));
}
try {
@@ -129,9 +129,10 @@ mysqli.rollback_on_cached_plink=1
var_dump(mysqli_get_links_stats());
// this fails and we have 0 (<= $num_plinks) connections
// Do not remove the variable assignment as it is important that we have 2 active connections
if ($plink = @my_mysqli_connect('p:' . $host, 'pcontest', 'pcontest', $db, $port, $socket))
printf("[010] Can connect using the old password, [%d] %s\n",
mysqli_connect_errno($link), mysqli_connect_error($link));
mysqli_connect_errno(), mysqli_connect_error());
echo "After second pconnect:";
var_dump(mysqli_get_links_stats());
@@ -168,6 +169,7 @@ mysqli.rollback_on_cached_plink=1
mysqli_free_result($res);
var_dump($row);
// Do not remove the variable assignment as it is important that we have 2 active connections
if ($plink2 = my_mysqli_connect('p:' . $host, 'pcontest', 'newpass', $db, $port, $socket)) {
printf("[015] Can open more persistent connections than allowed, [%d] %s\n",
mysqli_connect_errno(), mysqli_connect_error());

View File

@@ -46,7 +46,7 @@ require_once 'skipifconnectfailure.inc';
'mysqli.allow_local_infile', 'mysqli.local_infile_directory',
'mysqli.allow_persistent', 'mysqli.max_persistent'
);
foreach ($expected as $k => $entry)
foreach ($expected as $entry)
if (!stristr($phpinfo, $entry))
printf("[010] Could not find entry for '%s'\n", $entry);

View File

@@ -18,7 +18,7 @@ require_once 'skipifconnectfailure.inc';
var_dump(mysqli_ping($link));
// provoke an error to check if mysqli_ping resets it
$res = mysqli_query($link, 'SELECT * FROM unknown_table');
mysqli_query($link, 'SELECT * FROM unknown_table');
if (!($errno = mysqli_errno($link)))
printf("[003] Statement should have caused an error\n");

View File

@@ -44,11 +44,11 @@ require_once 'skipifconnectfailure.inc';
mysqli_close($link);
$links = array();
for ($i = 0; $i < count($queries); $i++) {
foreach ($queries as $query) {
$link = get_connection();
if (true !== ($tmp = mysqli_query($link, $queries[$i], MYSQLI_ASYNC | MYSQLI_USE_RESULT)))
if (true !== ($tmp = mysqli_query($link, $query, MYSQLI_ASYNC | MYSQLI_USE_RESULT)))
printf("[002] Expecting true got %s/%s\n", gettype($tmp), var_export($tmp, true));
// WARNING KLUDGE NOTE
@@ -57,7 +57,7 @@ require_once 'skipifconnectfailure.inc';
usleep(20000);
$links[mysqli_thread_id($link)] = array(
'query' => $queries[$i],
'query' => $query,
'link' => $link,
'processed' => false,
);
@@ -66,7 +66,7 @@ require_once 'skipifconnectfailure.inc';
$saved_errors = array();
do {
$poll_links = $poll_errors = $poll_reject = array();
foreach ($links as $thread_id => $link) {
foreach ($links as $link) {
if (!$link['processed']) {
$poll_links[] = $link['link'];
$poll_errors[] = $link['link'];
@@ -93,7 +93,7 @@ require_once 'skipifconnectfailure.inc';
if (is_object($res = mysqli_reap_async_query($link))) {
// result set object
while ($row = mysqli_fetch_assoc($res)) {
while (mysqli_fetch_assoc($res)) {
// eat up all results
;
}
@@ -120,9 +120,9 @@ require_once 'skipifconnectfailure.inc';
}
if (!$res = mysqli_query($link['link'], 'SELECT * FROM test WHERE id = 100'))
printf("[005] Expecting true got %s/%s\n", gettype($tmp), var_export($tmp, true));
printf("[005] Expecting true got %s/%s\n", gettype($res), var_export($res, true));
if (!$row = mysqli_fetch_row($res))
printf("[006] Expecting true got %s/%s\n", gettype($tmp), var_export($tmp, true));
printf("[006] Expecting true got %s/%s\n", gettype($row), var_export($row, true));
mysqli_free_result($res);
}

View File

@@ -42,7 +42,7 @@ if (mysqli_get_server_version($link) < 50012)
// WARNING: All arrays point to the same object - this will give bogus results!
// The behaviour is in line with stream_select(). Be warned, be careful.
$links = $errors = $reject = array($mysqli1, $mysqli2);
if (0 == ($ready = mysqli_poll($links, $errors, $reject, 0, 50000))) {
if (0 == mysqli_poll($links, $errors, $reject, 0, 50000)) {
continue;
}
@@ -73,7 +73,7 @@ if (mysqli_get_server_version($link) < 50012)
// WARNING: All arrays point to the same object - this will give bogus results!
$links = $errors = array($mysqli1, $mysqli2);
$reject = array($mysqli1, $mysqli2);
if (0 == ($ready = mysqli_poll($links, $errors, $reject, 0, 50000))) {
if (0 == mysqli_poll($links, $errors, $reject, 0, 50000)) {
continue;
}
foreach ($links as $link) {
@@ -103,7 +103,7 @@ if (mysqli_get_server_version($link) < 50012)
// WARNING: All arrays point to the same object - this will give bogus results!
$links = array($mysqli1, $mysqli2);
$errors = $reject = array($mysqli1, $mysqli2);
if (0 == ($ready = mysqli_poll($links, $errors, $reject, 0, 50000))) {
if (0 == mysqli_poll($links, $errors, $reject, 0, 50000)) {
continue;
}
foreach ($links as $link) {
@@ -133,7 +133,7 @@ if (mysqli_get_server_version($link) < 50012)
break;
}
$links = $errors = $reject = array($mysqli1, $mysqli2);
if (0 == ($ready = mysqli_poll($links, $errors, $reject, 0, 50000))) {
if (0 == mysqli_poll($links, $errors, $reject, 0, 50000)) {
continue;
}
// WARNING: Due to the reference issue none of these should ever fire!
@@ -176,7 +176,7 @@ if (mysqli_get_server_version($link) < 50012)
}
$links = $errors = $reject = $all;
ob_start();
if (0 == ($ready = mysqli_poll($links, $errors, $reject, 0, 50000))) {
if (0 == mysqli_poll($links, $errors, $reject, 0, 50000)) {
$tmp = ob_get_contents();
ob_end_clean();
if ($tmp != '') {
@@ -193,7 +193,7 @@ if (mysqli_get_server_version($link) < 50012)
}
} while ($processed < 2);
$ready = mysqli_poll($links, $errors, $reject, 0, 50000);
mysqli_poll($links, $errors, $reject, 0, 50000);
mysqli_close($mysqli1);
mysqli_close($mysqli2);

View File

@@ -11,11 +11,11 @@ require_once 'skipifconnectfailure.inc';
require 'table.inc';
if (false !== ($tmp = mysqli_prepare($link, false)))
printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp));
printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), var_export($tmp, true));
printf("a) [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (false !== ($tmp = mysqli_prepare($link, '')))
printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp));
printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), var_export($tmp, true));
printf("b) [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
@@ -23,11 +23,11 @@ require_once 'skipifconnectfailure.inc';
$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
if (false !== ($tmp = $mysqli->prepare(false)))
printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp));
printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), var_export($tmp, true));
printf("c) [%d] %s\n", $mysqli->errno, $mysqli->error);
if (false !== ($tmp = $mysqli->prepare('')))
printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp));
printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), var_export($tmp, true));
printf("c) [%d] %s\n", $mysqli->errno, $mysqli->error);
print "done!";

View File

@@ -45,7 +45,7 @@ require_once 'skipifconnectfailure.inc';
// let's try to play with stored procedures
mysqli_query($link, 'DROP PROCEDURE IF EXISTS p');
if (mysqli_query($link, 'CREATE PROCEDURE p(OUT ver_param VARCHAR(25)) BEGIN SELECT VERSION() INTO ver_param; END;')) {
$res = mysqli_query($link, 'CALL p(@version)');
mysqli_query($link, 'CALL p(@version)');
$res = mysqli_query($link, 'SELECT @version AS p_version');
$tmp = mysqli_fetch_assoc($res);

View File

@@ -25,7 +25,8 @@ require_once 'skipifconnectfailure.inc';
mysqli_free_result($res);
try {
foreach ($res as $row) {
$row;
echo "Iterating over a closed result set should not work\n";
var_dump($row);
}
} catch (Error $exception) {
echo $exception->getMessage() . "\n";

View File

@@ -107,8 +107,7 @@ END;')) {
if (!$res = mysqli_query($link, 'SELECT @version as _vers'))
printf("[014] Cannot fetch user variable, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!$row = mysqli_fetch_assoc($res) ||
$row['_vers'] == 'unknown')
if (!($row = mysqli_fetch_assoc($res)) || $row['_vers'] == 'unknown')
printf("[015] Results seem wrong, got %s, [%d] %s\n",
$row['_vers'],
mysqli_errno($link), mysqli_error($link));
@@ -135,8 +134,7 @@ END;')) {
if (!$res = mysqli_query($link, 'SELECT @version as _vers'))
printf("[021] Cannot fetch user variable, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!$row = mysqli_fetch_assoc($res) ||
$row['_vers'] == 'myversion')
if (!($row = mysqli_fetch_assoc($res)) || $row['_vers'] !== 'myversion')
printf("[022] Results seem wrong, got %s, [%d] %s\n",
$row['_vers'],
mysqli_errno($link), mysqli_error($link));

View File

@@ -40,7 +40,7 @@ mysqli_close($link);
// let's try to play with stored procedures
mysqli_query($link, 'DROP PROCEDURE IF EXISTS процедурка');
if (mysqli_query($link, 'CREATE PROCEDURE процедурка(OUT версия VARCHAR(25)) BEGIN SELECT VERSION() INTO версия; END;')) {
$res = mysqli_query($link, 'CALL процедурка(@version)');
mysqli_query($link, 'CALL процедурка(@version)');
$res = mysqli_query($link, 'SELECT @version AS п_версия');
$tmp = mysqli_fetch_assoc($res);

View File

@@ -24,7 +24,7 @@ $data_size = 16777174;
// Insert with compression disabled:
$mysqli = mysqli_init();
$result = my_mysqli_real_connect($mysqli, $host, $user, $passwd, $db, $port, $socket);
my_mysqli_real_connect($mysqli, $host, $user, $passwd, $db, $port, $socket);
$mysqli->query("DROP TABLE IF EXISTS test");
$mysqli->query("CREATE TABLE test (`blob` LONGBLOB NOT NULL) ENGINE=MyISAM");
@@ -37,7 +37,7 @@ $mysqli->close();
// Insert with compression enabled:
$mysqli = mysqli_init();
$result = my_mysqli_real_connect($mysqli, $host, $user, $passwd, $db, $port, $socket, MYSQLI_CLIENT_COMPRESS);
my_mysqli_real_connect($mysqli, $host, $user, $passwd, $db, $port, $socket, MYSQLI_CLIENT_COMPRESS);
$data = str_repeat("x", $data_size);
$mysqli->query("INSERT INTO $db.test(`blob`) VALUE ('$data')");

View File

@@ -18,10 +18,6 @@ require_once 'skipifconnectfailure.inc';
return $link;
}
if (!$link = get_connection())
printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
function poll_async($offset, $link, $links, $errors, $reject, $exp_ready, $use_oo_syntax) {
if ($exp_ready !== ($tmp = mysqli_poll($links, $errors, $reject, 0, 50 * 1000)))

View File

@@ -19,7 +19,7 @@ mysqli::poll($reads, $errors, $rejects, 1);
$link = $reads[0];
try {
$rs = $link->reap_async_query();
$link->reap_async_query();
} catch (mysqli_sql_exception $exception) {
echo $exception->getMessage() . "\n";
}

View File

@@ -36,7 +36,7 @@ if (!have_innodb($link))
/* note that there is no savepoint my... */
if (false !== ($tmp = mysqli_release_savepoint($link, 'my')))
printf("[010] Got %s - [%d] %s\n", var_dump($tmp, true), mysqli_errno($link), mysqli_error($link));
printf("[010] Got %s - [%d] %s\n", $tmp, mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, 'INSERT INTO test(id) VALUES (1)'))
printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
@@ -46,13 +46,13 @@ if (!have_innodb($link))
printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
if (true !== ($tmp = mysqli_savepoint($link, 'my')))
printf("[013] Got %s - [%d] %s\n", var_dump($tmp, true), mysqli_errno($link), mysqli_error($link));
printf("[013] Got %s - [%d] %s\n", $tmp, mysqli_errno($link), mysqli_error($link));
$res = mysqli_query($link, "SELECT * FROM test");
var_dump($res->fetch_assoc());
if (true !== ($tmp = mysqli_release_savepoint($link, 'my')))
printf("[014] Got %s - [%d] %s\n", var_dump($tmp, true), mysqli_errno($link), mysqli_error($link));
printf("[014] Got %s - [%d] %s\n", $tmp, mysqli_errno($link), mysqli_error($link));
print "done!";
?>

View File

@@ -55,7 +55,7 @@ require_once 'skipifconnectfailure.inc';
mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?");
while(mysqli_more_results($link)) {
mysqli_next_result($link);
$res = mysqli_store_result($link);
mysqli_store_result($link);
}
mysqli_next_result($link);
@@ -85,7 +85,7 @@ require_once 'skipifconnectfailure.inc';
mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?");
while(mysqli_more_results($link)) {
mysqli_next_result($link);
$res = mysqli_store_result($link);
mysqli_store_result($link);
}
mysqli_next_result($link);
@@ -211,8 +211,6 @@ require_once 'skipifconnectfailure.inc';
TODO:
*/
$log_slow_queries = false;
$log_queries_not_using_indexes = false;
mysqli_report(MYSQLI_REPORT_OFF);
mysqli_report(MYSQLI_REPORT_INDEX);
@@ -227,7 +225,7 @@ require_once 'skipifconnectfailure.inc';
if (!$row = mysqli_fetch_assoc($res))
printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$log_slow_query = ('ON' == $row['Value']);
$log_slow_queries = ('ON' == $row['Value']);
if (mysqli_get_server_version($link) >= 50111) {
// this might cause a warning - no index used
@@ -301,8 +299,6 @@ require_once 'skipifconnectfailure.inc';
!mysqli_query($link, 'DELETE FROM test WHERE id > 50', MYSQLI_USE_RESULT))
printf("[033] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$tmp = mysqli_thread_id($link);
mysqli_close($link);
print "done!";
?>

View File

@@ -15,7 +15,6 @@ require_once 'skipifconnectfailure.inc';
exit(1);
}
$valid = array(MYSQLI_STORE_RESULT, MYSQLI_USE_RESULT);
$invalidModes = [-1, 152];
foreach ($invalidModes as $mode) {
try {

View File

@@ -36,7 +36,7 @@ if (!have_innodb($link))
/* overrule autocommit */
if (true !== ($tmp = mysqli_savepoint($link, 'my')))
printf("[010] Got %s - [%d] %s\n", var_dump($tmp, true), mysqli_errno($link), mysqli_error($link));
printf("[010] Got %s - [%d] %s\n", $tmp, mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, 'INSERT INTO test(id) VALUES (1)'))
printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link));

View File

@@ -45,7 +45,7 @@ require_once 'skipifconnectfailure.inc';
}
if (!$link->select_db($db))
printf("[012] Failed to set '%s' as current DB; [%d] %s\n", $link->errno, $link->error);
printf("[012] Failed to set '%s' as current DB; [%d] %s\n", $db, $link->errno, $link->error);
if (!$res = mysqli_query($link, "SELECT DATABASE() AS dbname"))
printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
@@ -81,9 +81,9 @@ require_once 'skipifconnectfailure.inc';
if (!$res = $link->query("SELECT id FROM test WHERE id = 1"))
printf("[018] [%d] %s\n");
printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$row = $res->fetch_assoc();
$res->fetch_assoc();
$res->free();
mysqli_close($link);

View File

@@ -17,7 +17,6 @@ if ((($res = mysqli_query($link, 'SHOW CHARACTER SET LIKE "latin1"', MYSQLI_STOR
mysqli_close($link);
} else {
die(sprintf("skip Requires character set latin1 or latin2\n"));
mysqli_close($link);
}
?>
--FILE--

View File

@@ -17,7 +17,7 @@ require_once 'skipifconnectfailure.inc';
if ((!is_string($tmp = mysqli_stat($link))) || ('' === $tmp))
printf("[004] Expecting non empty string, got %s/'%s', [%d] %s\n",
gettype($tmp), $tmp, mysqli_errno($link), mysql_error($link));
gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link));
mysqli_close($link);

View File

@@ -11,9 +11,9 @@ require_once 'skipifconnectfailure.inc';
require 'table.inc';
$valid_attr = array(
"max_length" => MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH,
"cursor_type" => MYSQLI_STMT_ATTR_CURSOR_TYPE,
"prefetch_rows" => MYSQLI_STMT_ATTR_PREFETCH_ROWS,
MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH,
MYSQLI_STMT_ATTR_CURSOR_TYPE,
MYSQLI_STMT_ATTR_PREFETCH_ROWS,
);
$stmt = mysqli_stmt_init($link);
@@ -25,17 +25,17 @@ require_once 'skipifconnectfailure.inc';
echo $e->getMessage() . \PHP_EOL;
}
foreach ($valid_attr as $k => $attr) {
/* This can't happen anymore as it only returns int */
if (false === ($tmp = mysqli_stmt_attr_get($stmt, $attr))) {
printf("[006] Expecting any type, but not boolean/false, got %s/%s for attribute %s/%s\n",
gettype($tmp), $tmp, $k, $attr);
foreach ($valid_attr as $attr) {
try {
mysqli_stmt_attr_get($stmt, $attr);
} catch (Throwable $exception) {
echo $exception->getMessage() . "\n";
}
}
$stmt->close();
foreach ($valid_attr as $k => $attr) {
foreach ($valid_attr as $attr) {
try {
mysqli_stmt_attr_get($stmt, $attr);
} catch (Throwable $exception) {

View File

@@ -10,15 +10,6 @@ require_once 'skipifconnectfailure.inc';
<?php
require 'table.inc';
$valid_attr = array(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH);
$valid_attr[] = MYSQLI_STMT_ATTR_CURSOR_TYPE;
$valid_attr[] = MYSQLI_CURSOR_TYPE_NO_CURSOR;
$valid_attr[] = MYSQLI_CURSOR_TYPE_READ_ONLY;
$valid_attr[] = MYSQLI_CURSOR_TYPE_FOR_UPDATE;
$valid_attr[] = MYSQLI_CURSOR_TYPE_SCROLLABLE;
$valid_attr[] = MYSQLI_STMT_ATTR_PREFETCH_ROWS;
$stmt = mysqli_stmt_init($link);
try {
mysqli_stmt_attr_set($stmt, 0, 0);
@@ -51,9 +42,7 @@ require_once 'skipifconnectfailure.inc';
$stmt->store_result();
$res = $stmt->result_metadata();
$fields = $res->fetch_fields();
$max_lengths = array();
foreach ($fields as $k => $meta) {
$max_lengths[$meta->name] = $meta->max_length;
foreach ($fields as $meta) {
if ($meta->max_length !== 0)
printf("[007] max_length should be not set (= 0), got %s for field %s\n", $meta->max_length, $meta->name);
}
@@ -71,9 +60,7 @@ require_once 'skipifconnectfailure.inc';
$stmt->store_result();
$res = $stmt->result_metadata();
$fields = $res->fetch_fields();
$max_lengths = array();
foreach ($fields as $k => $meta) {
$max_lengths[$meta->name] = $meta->max_length;
foreach ($fields as $meta) {
if ($meta->max_length !== 0)
printf("[008] max_length should be not set (= 0), got %s for field %s\n", $meta->max_length, $meta->name);
}
@@ -91,9 +78,7 @@ require_once 'skipifconnectfailure.inc';
$stmt->store_result();
$res = $stmt->result_metadata();
$fields = $res->fetch_fields();
$max_lengths = array();
foreach ($fields as $k => $meta) {
$max_lengths[$meta->name] = $meta->max_length;
foreach ($fields as $meta) {
if ($meta->max_length !== 0)
printf("[009] max_length should not be set (= 0), got %s for field %s\n", $meta->max_length, $meta->name);
}

View File

@@ -382,14 +382,14 @@ require_once 'skipifconnectfailure.inc';
if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)"))
printf("[2010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
foreach ($value_list as $k => $values) {
foreach ($value_list as $values) {
if (!mysqli_stmt_bind_param($stmt, 'is', $values['id'], $values['label'])) {
printf("[2011] bind_param() failed for id = %d, [%d] %s\n",
$values['id'], mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
continue;
}
if (!$stmt->execute())
printf("[2012] [%d] execute() failed for id = %d, [%d] %s\n",
printf("[2012] execute() failed for id = %d, [%d] %s\n",
$values['id'], mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
if (!$res = mysqli_query($link, sprintf("SELECT label FROM test WHERE id = %d", $values['id'])))

View File

@@ -309,7 +309,6 @@ require_once 'skipifconnectfailure.inc';
if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?'))
printf("[050] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
$types = 'i';
$id = 1;
$params = array(
0 => $stmt,

View File

@@ -275,7 +275,7 @@ require_once 'skipifconnectfailure.inc';
try {
mysqli_stmt_bind_result($stmt, $id);
} catch (\ArgumentCountError $e) {
$e->getMessage() . \PHP_EOL;
echo $e->getMessage() . \PHP_EOL;
}
mysqli_stmt_close($stmt);
@@ -293,4 +293,5 @@ Number of bind variables doesn't match number of fields in prepared statement
Number of bind variables doesn't match number of fields in prepared statement
int(1)
%s(1) "a"
Number of bind variables doesn't match number of fields in prepared statement
done!

View File

@@ -23,8 +23,7 @@ require_once 'skipifconnectfailure.inc';
if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test"))
printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
if (true !== ($tmp = mysqli_stmt_close($stmt)))
printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
mysqli_stmt_close($stmt);
try {
mysqli_stmt_close($stmt);
@@ -48,8 +47,7 @@ require_once 'skipifconnectfailure.inc';
$link->query('KILL '.mysqli_thread_id($link));
if (true !== ($tmp = mysqli_stmt_close($stmt)))
printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
mysqli_stmt_close($stmt);
mysqli_close($link);
@@ -69,8 +67,7 @@ require_once 'skipifconnectfailure.inc';
$link->query('KILL '.mysqli_thread_id($link));
if (true !== ($tmp = mysqli_stmt_close($stmt)))
printf("[017] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
mysqli_stmt_close($stmt);
print "done!";
?>

View File

@@ -33,24 +33,21 @@ require_once 'skipifconnectfailure.inc';
if (!mysqli_stmt_store_result($stmt))
printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
if (!is_null($tmp = mysqli_stmt_data_seek($stmt, 2)))
printf("[009] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
mysqli_stmt_data_seek($stmt, 2);
if (!mysqli_stmt_fetch($stmt))
printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
var_dump($id);
if (!is_null($tmp = mysqli_stmt_data_seek($stmt, 0)))
printf("[011] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
mysqli_stmt_data_seek($stmt, 0);
if (!mysqli_stmt_fetch($stmt))
printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
var_dump($id);
if (!is_null($tmp = mysqli_stmt_data_seek($stmt, mysqli_stmt_num_rows($stmt) + 100)))
printf("[013] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
mysqli_stmt_data_seek($stmt, mysqli_stmt_num_rows($stmt) + 100);
if (mysqli_stmt_fetch($stmt))
printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));

View File

@@ -52,7 +52,7 @@ if (mysqli_get_server_version($link) < 50503) {
if (!mysqli_stmt_close($stmt))
printf("[012] Cannot close statement, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
if (!$res = $link->query("SELECT 1"))
if (false === $link->query("SELECT 1"))
printf("[013] [%d] %s\n", $link->errno, $link->error);
} else {

View File

@@ -17,7 +17,7 @@ require_once 'skipifconnectfailure.inc';
!mysqli_stmt_execute($stmt) ||
!($result = mysqli_stmt_result_metadata($stmt)) ||
!mysqli_stmt_bind_result($stmt, $id, $bind_res) ||
!($fields = mysqli_fetch_fields($result))) {
[] === mysqli_fetch_fields($result)) {
printf("FAIL 1\n");
}
while (mysqli_stmt_fetch($stmt)) {
@@ -34,7 +34,7 @@ require_once 'skipifconnectfailure.inc';
printf("FAIL 2\n");
}
print "OK: 1\n";
if (!($fields = mysqli_fetch_fields($result)))
if ([] === mysqli_fetch_fields($result))
printf("Aua 3\n");
print "OK: 2\n";
while (mysqli_stmt_fetch($stmt)) {

View File

@@ -28,14 +28,12 @@ require_once 'skipifconnectfailure.inc';
if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id"))
printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
if (NULL !== ($tmp = mysqli_stmt_free_result($stmt)))
printf("[006] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
mysqli_stmt_free_result($stmt);
if (!mysqli_stmt_execute($stmt))
printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
if (NULL !== ($tmp = mysqli_stmt_free_result($stmt)))
printf("[008] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
mysqli_stmt_free_result($stmt);
if (false !== ($tmp = mysqli_stmt_store_result($stmt)))
printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
@@ -54,8 +52,7 @@ require_once 'skipifconnectfailure.inc';
if (true !== ($tmp = mysqli_stmt_store_result($stmt)))
printf("[013] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
if (NULL !== ($tmp = mysqli_stmt_free_result($stmt)))
printf("[014] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
mysqli_stmt_free_result($stmt);
mysqli_stmt_close($stmt);

View File

@@ -102,7 +102,7 @@ require_once 'skipifconnectfailure.inc';
if (!mysqli_stmt_bind_result($stmt, $id, $label))
printf("[020] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
$row = mysqli_fetch_assoc($res);
mysqli_fetch_assoc($res);
if (NULL !== $id || NULL !== $label)
printf("[021] Bound variables should not have been set\n");
mysqli_free_result($res);

View File

@@ -10,7 +10,6 @@ require_once 'skipifconnectfailure.inc';
<?php
require 'table.inc';
$stmt = mysqli_stmt_init($link);
if (!$link->query('DROP PROCEDURE IF EXISTS p123')) {
printf("[001] [%d] %s\n", $link->error, $link->errno);
}

View File

@@ -23,7 +23,7 @@ require_once 'skipifconnectfailure.inc';
printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
if (!is_object(($res = mysqli_stmt_result_metadata($stmt))))
printf("[006] Expecting object, got %s/%s\n", gettype($tmp), $tmp);
printf("[006] Expecting object, got %s/%s\n", gettype($res), $res);
if (2 !== ($tmp = mysqli_num_fields($res)))
printf("[007] Expecting int/2, got %s/%s, [%d] %s\n",
@@ -45,9 +45,7 @@ require_once 'skipifconnectfailure.inc';
var_dump($field0_fetch);
if (!is_array($tmp = mysqli_fetch_fields($res)))
printf("[011] Expecting array, got %s/%s, [%d] %s\n",
gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link));
$tmp = mysqli_fetch_fields($res);
if (empty($tmp[0]) || empty($tmp[1]) || $tmp[0] != $field0_direct) {
printf("[012] mysqli_fetch_fields() return value is suspicious\n");

View File

@@ -64,7 +64,7 @@ require_once 'skipifconnectfailure.inc';
assert(strlen($blob) <= $max_allowed_packet);
try {
$tmp = mysqli_stmt_send_long_data($stmt, -1, $blob);
mysqli_stmt_send_long_data($stmt, -1, $blob);
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}

View File

@@ -40,8 +40,6 @@ require_once 'skipifconnectfailure.inc';
// let's ignore upper limits for LONGBLOB (2^32) ...
// maximum packet size up to which we test is 10M
$tmp = '';
$blob = '';
$tmp = str_repeat('a', 1024);
$limit = min(floor($max_allowed_packet / 1024 / 2), 10240);

View File

@@ -10,7 +10,7 @@ require_once 'skipifconnectfailure.inc';
<?php
require 'table.inc';
if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id"))
if (false === mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id"))
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!is_object($res = mysqli_store_result($link)))

View File

@@ -10,7 +10,7 @@ require_once 'skipifconnectfailure.inc';
<?php
require 'table.inc';
if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id"))
if (false === mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id"))
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!is_object($res = mysqli_store_result($link)))

View File

@@ -10,7 +10,7 @@ require_once 'skipifconnectfailure.inc';
<?php
require 'table.inc';
if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id"))
if (false === mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id"))
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!is_object($res = mysqli_use_result($link)))

View File

@@ -10,7 +10,7 @@ require_once 'skipifconnectfailure.inc';
<?php
require 'table.inc';
if (!$res = mysqli_query($link, "SELECT id, label FROM test"))
if (false === mysqli_query($link, "SELECT id, label FROM test"))
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (0 !== ($tmp = mysqli_warning_count($link)))

Some files were not shown because too many files have changed in this diff Show More