printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_fetch_null"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
mysqli fetch bigint values (ok to fail with 4.1.x)
--SKIPIF--
<?php
- if (PHP_INT_SIZE == 8) {
- echo 'skip test valid only for 32bit systems';
- exit;
- }
- require_once('skipif.inc');
- require_once('skipifconnectfailure.inc');
+ if (PHP_INT_SIZE == 8) {
+ echo 'skip test valid only for 32bit systems';
+ exit;
+ }
+ require_once('skipif.inc');
+ require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
- printf("[002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch_uint"))
- printf("[002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
mysqli autocommit/commit/rollback
--SKIPIF--
<?php
- require_once('skipif.inc');
- require_once('skipifconnectfailure.inc');
- require_once("connect.inc");
+ require_once('skipif.inc');
+ require_once('skipifconnectfailure.inc');
+ require_once("connect.inc");
- $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
- if (!$link)
- die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ if (!$link)
+ die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
- if (!have_innodb($link))
- die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
+ if (!have_innodb($link))
+ die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
Num_of_rows=1
mysqli autocommit/commit/rollback with innodb
--SKIPIF--
<?php
- require_once('skipif.inc');
- require_once('skipifconnectfailure.inc');
+ require_once('skipif.inc');
+ require_once('skipifconnectfailure.inc');
- require_once('connect.inc');
- if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
+ require_once('connect.inc');
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
- if (!have_innodb($link))
- die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
+ if (!have_innodb($link))
+ die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
array(2) {
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS insert_read"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS general_test"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS general_test"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
function test: mysqli_insert_id()
--SKIPIF--
<?php
- if (PHP_INT_SIZE == 8) {
- echo 'skip test valid only for 32bit systems';
- exit;
- }
- require_once('skipif.inc');
- require_once('skipifconnectfailure.inc');
+ if (PHP_INT_SIZE == 8) {
+ echo 'skip test valid only for 32bit systems';
+ exit;
+ }
+ require_once('skipif.inc');
+ require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS t036"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_result"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_result"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_result"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_warnings"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_update"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
mysqli_stmt_bind_result (SHOW)
--SKIPIF--
<?php
- require_once('skipif.inc');
- require_once('skipifemb.inc');
- require_once('skipifconnectfailure.inc');
+ require_once('skipif.inc');
+ require_once('skipifemb.inc');
+ require_once('skipifconnectfailure.inc');
- require_once("connect.inc");
- $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ require_once("connect.inc");
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
- $stmt = mysqli_prepare($link, "SHOW VARIABLES LIKE 'port'");
- mysqli_stmt_execute($stmt);
+ $stmt = mysqli_prepare($link, "SHOW VARIABLES LIKE 'port'");
+ mysqli_stmt_execute($stmt);
- if (!$stmt->field_count) {
- printf("skip SHOW command is not supported in prepared statements.");
- }
- $stmt->close();
- mysqli_close($link);
+ if (!$stmt->field_count) {
+ printf("skip SHOW command is not supported in prepared statements.");
+ }
+ $stmt->close();
+ mysqli_close($link);
?>
--FILE--
<?php
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_affected"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_affected"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_fetch_null"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_store_result"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS mbind"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS mbind"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_fetch"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_set_local_infile_handler'))
- die("skip - function not available.");
+ die("skip - function not available.");
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!$link)
- die(sprintf("skip Can't connect [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf("skip Can't connect [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
include_once("local_infile_tools.inc");
if ($msg = check_local_infile_support($link, $engine))
- die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
+ die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
mysqli_close($link);
?>
mysqli.allow_local_infile=1
--FILE--
<?php
- require_once("connect.inc");
+ require_once("connect.inc");
- function my_read($fp, &$buffer, $buflen, &$error) {
- $buffer = strrev(fread($fp, $buflen));
- return(strlen($buffer));
- }
+ function my_read($fp, &$buffer, $buflen, &$error) {
+ $buffer = strrev(fread($fp, $buflen));
+ return(strlen($buffer));
+ }
- /*** test mysqli_connect 127.0.0.1 ***/
- $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ /*** test mysqli_connect 127.0.0.1 ***/
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
- /* create temporary file */
- $filename = __DIR__ . "061.csv";
- $fp = fopen($filename, "w");
- fwrite($fp, "foo;bar");
- fclose($fp);
+ /* create temporary file */
+ $filename = __DIR__ . "061.csv";
+ $fp = fopen($filename, "w");
+ fwrite($fp, "foo;bar");
+ fclose($fp);
- if (!mysqli_query($link,"DROP TABLE IF EXISTS t_061"))
- printf("Cannot drop table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- if (!mysqli_query($link,"CREATE TABLE t_061 (c1 varchar(10), c2 varchar(10))"))
- printf("Cannot create table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!mysqli_query($link,"DROP TABLE IF EXISTS t_061"))
+ printf("Cannot drop table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!mysqli_query($link,"CREATE TABLE t_061 (c1 varchar(10), c2 varchar(10))"))
+ printf("Cannot create table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- if (!mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s' INTO TABLE t_061 FIELDS TERMINATED BY ';'", mysqli_real_escape_string($link, $filename))))
- printf("Cannot load data: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s' INTO TABLE t_061 FIELDS TERMINATED BY ';'", mysqli_real_escape_string($link, $filename))))
+ printf("Cannot load data: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- mysqli_set_local_infile_handler($link, "my_read");
- if (!mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s' INTO TABLE t_061 FIELDS TERMINATED BY ';'", mysqli_real_escape_string($link, $filename))))
- printf("Cannot load data using infile handler: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ mysqli_set_local_infile_handler($link, "my_read");
+ if (!mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s' INTO TABLE t_061 FIELDS TERMINATED BY ';'", mysqli_real_escape_string($link, $filename))))
+ printf("Cannot load data using infile handler: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- if ($result = mysqli_query($link, "SELECT c1,c2 FROM t_061")) {
- while (($row = mysqli_fetch_row($result))) {
- printf("%s-%s\n", $row[0], $row[1]);
- printf("%s-%s\n", gettype($row[0]), gettype($row[1]));
- }
- mysqli_free_result($result);
- }
+ if ($result = mysqli_query($link, "SELECT c1,c2 FROM t_061")) {
+ while (($row = mysqli_fetch_row($result))) {
+ printf("%s-%s\n", $row[0], $row[1]);
+ printf("%s-%s\n", gettype($row[0]), gettype($row[1]));
+ }
+ mysqli_free_result($result);
+ }
- mysqli_close($link);
- unlink($filename);
- print "done!";
+ mysqli_close($link);
+ unlink($filename);
+ print "done!";
?>
--CLEAN--
<?php
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_set_charset')) {
- die('skip mysqli_set_charset() not available');
+ die('skip mysqli_set_charset() not available');
}
?>
--FILE--
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_warnings"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
function test: nested selects (cursors)
--SKIPIF--
<?php
- require_once('skipif.inc');
- require_once('skipifconnectfailure.inc');
- require_once("connect.inc");
+ require_once('skipif.inc');
+ require_once('skipifconnectfailure.inc');
+ require_once("connect.inc");
- if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die("skip Cannot connect to check required version");
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ die("skip Cannot connect to check required version");
- /* skip cursor test for versions < 50004 */
- if ((!$IS_MYSQLND && (mysqli_get_client_version() < 50009)) ||
- (mysqli_get_server_version($link) < 50009)) {
- die(sprintf("skip Client library doesn't support cursors (%s/%s)",
- mysqli_get_client_version(), mysqli_get_server_version($link)));
- }
- mysqli_close($link);
+ /* skip cursor test for versions < 50004 */
+ if ((!$IS_MYSQLND && (mysqli_get_client_version() < 50009)) ||
+ (mysqli_get_server_version($link) < 50009)) {
+ die(sprintf("skip Client library doesn't support cursors (%s/%s)",
+ mysqli_get_client_version(), mysqli_get_server_version($link)));
+ }
+ mysqli_close($link);
?>
--FILE--
<?php
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
for ($i =0; $i < 3; $i++) {
- if (!mysqli_query($link, sprintf("DROP TABLE IF EXISTS cursor%d", $i)))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!mysqli_query($link, sprintf("DROP TABLE IF EXISTS cursor%d", $i)))
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
mysqli_close($link);
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_users"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_warnings"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bint") || !mysqli_query($link, "DROP TABLE IF EXISTS test_buint"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS temp"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
mysqli.allow_local_infile=1
--FILE--
<?php
- require_once("connect.inc");
+ require_once("connect.inc");
- /*** test mysqli_connect 127.0.0.1 ***/
- $mysql = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ /*** test mysqli_connect 127.0.0.1 ***/
+ $mysql = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
- $mysql->query("DROP TABLE IF EXISTS litest");
- $mysql->query("CREATE TABLE litest (a VARCHAR(20))");
+ $mysql->query("DROP TABLE IF EXISTS litest");
+ $mysql->query("CREATE TABLE litest (a VARCHAR(20))");
- $mysql->query("LOAD DATA LOCAL INFILE 'filenotfound' INTO TABLE litest");
- var_dump($mysql->error);
+ $mysql->query("LOAD DATA LOCAL INFILE 'filenotfound' INTO TABLE litest");
+ var_dump($mysql->error);
- $mysql->close();
- printf("Done");
+ $mysql->close();
+ printf("Done");
?>
--CLEAN--
<?php
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS my_time"))
- printf("[002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_set_charset')) {
- die('skip mysqli_set_charset() not available');
+ die('skip mysqli_set_charset() not available');
}
?>
--FILE--
memory_limit=83886080
--FILE--
<?php
- require_once("connect.inc");
-
- function create_table($link, $column, $min, $max, $engine, $offset) {
-
- if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) {
- printf("[%03d] Cannot drop table test, [%d] %s\n",
- $offset,
- mysqli_errno($link), mysqli_error($link));
- return array();
- }
- print "$column\n";
-
- $sql = sprintf("CREATE TABLE test(id INT AUTO_INCREMENT PRIMARY KEY, col1 %s) ENGINE=%s",
- $column, $engine);
- if (!mysqli_query($link, $sql)) {
- printf("[%03d] Cannot create table test, [%d] %s\n",
- $offset + 1,
- mysqli_errno($link), mysqli_error($link));
- return array();
- }
-
- $values = array();
- for ($i = 1; $i <= 100; $i++) {
- $col1 = mt_rand($min, $max);
- $values[$i] = $col1;
- $sql = sprintf("INSERT INTO test(id, col1) VALUES (%d, %f)",
- $i, $col1);
- if (!mysqli_query($link, $sql)) {
- printf("[%03d] Cannot insert data, [%d] %s\n",
- $offset + 2,
- mysqli_errno($link), mysqli_error($link));
- return array();
- }
- }
-
- return $values;
- }
-
- function test_format($link, $format, $from, $order_by, $expected, $offset) {
-
- if (!$stmt = mysqli_stmt_init($link)) {
- printf("[%03d] Cannot create PS, [%d] %s\n",
- $offset,
- mysqli_errno($link), mysqli_error($link));
- return false;
- }
- print "$format\n";
-
- if ($order_by)
- $sql = sprintf('SELECT %s AS _format FROM %s ORDER BY %s', $format, $from, $order_by);
- else
- $sql = sprintf('SELECT %s AS _format FROM %s', $format, $from);
-
- if (!mysqli_stmt_prepare($stmt, $sql)) {
- printf("[%03d] Cannot prepare PS, [%d] %s\n",
- $offset + 1,
- mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- return false;
- }
-
- if (!mysqli_stmt_execute($stmt)) {
- printf("[%03d] Cannot execute PS, [%d] %s\n",
- $offset + 2,
- mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- return false;
- }
-
- if (!mysqli_stmt_store_result($stmt)) {
- printf("[%03d] Cannot store result set, [%d] %s\n",
- $offset + 3,
- mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- return false;
- }
-
- if (!is_array($expected)) {
-
- $result = null;
- if (!mysqli_stmt_bind_result($stmt, $result)) {
- printf("[%03d] Cannot bind result, [%d] %s\n",
- $offset + 4,
- mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- return false;
- }
-
- if (!mysqli_stmt_fetch($stmt)) {
- printf("[%03d] Cannot fetch result,, [%d] %s\n",
- $offset + 5,
- mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- return false;
- }
-
- if ($result !== $expected) {
- printf("[%03d] Expecting %s/%s got %s/%s with %s - %s.\n",
- $offset + 6,
- gettype($expected), $expected,
- gettype($result), $result,
- $format, $sql);
- }
-
- } else {
-
- $order_by_col = $result = null;
- if (!is_null($order_by)) {
- if (!mysqli_stmt_bind_result($stmt, $order_by_col, $result)) {
- printf("[%03d] Cannot bind result, [%d] %s\n",
- $offset + 7,
- mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- return false;
- }
- } else {
- if (!mysqli_stmt_bind_result($stmt, $result)) {
- printf("[%03d] Cannot bind result, [%d] %s\n",
- $offset + 7,
- mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- return false;
- }
- }
-
- foreach ($expected as $k => $v) {
- if (!mysqli_stmt_fetch($stmt)) {
- break;
- }
- if ($result !== $v) {
- printf("[%03d] Row %d - expecting %s/%s got %s/%s [%s] with %s - %s.\n",
- $offset + 8,
- $k,
- gettype($v), $v,
- gettype($result), $result,
- $order_by_col,
- $format, $sql);
- }
- }
-
- }
-
- mysqli_stmt_free_result($stmt);
- mysqli_stmt_close($stmt);
-
- return true;
- }
-
- if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- printf("[001] Cannot connect - [%d] %s\n",
- mysqli_connect_errno(),
- mysqli_connect_error());
-
- /* create new table and select from it */
- $expected = create_table($link, 'FLOAT', -10000, 10000, $engine, 90);
- foreach ($expected as $k => $v)
- $expected[$k] = number_format(round($v), 0, '.', ',');
- test_format($link, 'FORMAT(col1, 0)', 'test', NULL, array(), 100);
-
- $expected = create_table($link, 'FLOAT', -10000, 10000, $engine, 110);
- foreach ($expected as $k => $v)
- $expected[$k] = number_format(round($v), 0, '.', ',');
- test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 120);
-
- $expected = create_table($link, 'FLOAT UNSIGNED', 0, 10000, $engine, 130);
- foreach ($expected as $k => $v)
- $expected[$k] = number_format(round($v), 0, '.', ',');
- test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 140);
-
- $expected = create_table($link, 'DECIMAL(5,0)', -1000, 1000, $engine, 150);
- foreach ($expected as $k => $v)
- $expected[$k] = number_format(round($v), 0, '.', ',');
- test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 160);
-
- mysqli_close($link);
- print "done!";
+ require_once("connect.inc");
+
+ function create_table($link, $column, $min, $max, $engine, $offset) {
+
+ if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) {
+ printf("[%03d] Cannot drop table test, [%d] %s\n",
+ $offset,
+ mysqli_errno($link), mysqli_error($link));
+ return array();
+ }
+ print "$column\n";
+
+ $sql = sprintf("CREATE TABLE test(id INT AUTO_INCREMENT PRIMARY KEY, col1 %s) ENGINE=%s",
+ $column, $engine);
+ if (!mysqli_query($link, $sql)) {
+ printf("[%03d] Cannot create table test, [%d] %s\n",
+ $offset + 1,
+ mysqli_errno($link), mysqli_error($link));
+ return array();
+ }
+
+ $values = array();
+ for ($i = 1; $i <= 100; $i++) {
+ $col1 = mt_rand($min, $max);
+ $values[$i] = $col1;
+ $sql = sprintf("INSERT INTO test(id, col1) VALUES (%d, %f)",
+ $i, $col1);
+ if (!mysqli_query($link, $sql)) {
+ printf("[%03d] Cannot insert data, [%d] %s\n",
+ $offset + 2,
+ mysqli_errno($link), mysqli_error($link));
+ return array();
+ }
+ }
+
+ return $values;
+ }
+
+ function test_format($link, $format, $from, $order_by, $expected, $offset) {
+
+ if (!$stmt = mysqli_stmt_init($link)) {
+ printf("[%03d] Cannot create PS, [%d] %s\n",
+ $offset,
+ mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+ print "$format\n";
+
+ if ($order_by)
+ $sql = sprintf('SELECT %s AS _format FROM %s ORDER BY %s', $format, $from, $order_by);
+ else
+ $sql = sprintf('SELECT %s AS _format FROM %s', $format, $from);
+
+ if (!mysqli_stmt_prepare($stmt, $sql)) {
+ printf("[%03d] Cannot prepare PS, [%d] %s\n",
+ $offset + 1,
+ mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ return false;
+ }
+
+ if (!mysqli_stmt_execute($stmt)) {
+ printf("[%03d] Cannot execute PS, [%d] %s\n",
+ $offset + 2,
+ mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ return false;
+ }
+
+ if (!mysqli_stmt_store_result($stmt)) {
+ printf("[%03d] Cannot store result set, [%d] %s\n",
+ $offset + 3,
+ mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ return false;
+ }
+
+ if (!is_array($expected)) {
+
+ $result = null;
+ if (!mysqli_stmt_bind_result($stmt, $result)) {
+ printf("[%03d] Cannot bind result, [%d] %s\n",
+ $offset + 4,
+ mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ return false;
+ }
+
+ if (!mysqli_stmt_fetch($stmt)) {
+ printf("[%03d] Cannot fetch result,, [%d] %s\n",
+ $offset + 5,
+ mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ return false;
+ }
+
+ if ($result !== $expected) {
+ printf("[%03d] Expecting %s/%s got %s/%s with %s - %s.\n",
+ $offset + 6,
+ gettype($expected), $expected,
+ gettype($result), $result,
+ $format, $sql);
+ }
+
+ } else {
+
+ $order_by_col = $result = null;
+ if (!is_null($order_by)) {
+ if (!mysqli_stmt_bind_result($stmt, $order_by_col, $result)) {
+ printf("[%03d] Cannot bind result, [%d] %s\n",
+ $offset + 7,
+ mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ return false;
+ }
+ } else {
+ if (!mysqli_stmt_bind_result($stmt, $result)) {
+ printf("[%03d] Cannot bind result, [%d] %s\n",
+ $offset + 7,
+ mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ return false;
+ }
+ }
+
+ foreach ($expected as $k => $v) {
+ if (!mysqli_stmt_fetch($stmt)) {
+ break;
+ }
+ if ($result !== $v) {
+ printf("[%03d] Row %d - expecting %s/%s got %s/%s [%s] with %s - %s.\n",
+ $offset + 8,
+ $k,
+ gettype($v), $v,
+ gettype($result), $result,
+ $order_by_col,
+ $format, $sql);
+ }
+ }
+
+ }
+
+ mysqli_stmt_free_result($stmt);
+ mysqli_stmt_close($stmt);
+
+ return true;
+ }
+
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[001] Cannot connect - [%d] %s\n",
+ mysqli_connect_errno(),
+ mysqli_connect_error());
+
+ /* create new table and select from it */
+ $expected = create_table($link, 'FLOAT', -10000, 10000, $engine, 90);
+ foreach ($expected as $k => $v)
+ $expected[$k] = number_format(round($v), 0, '.', ',');
+ test_format($link, 'FORMAT(col1, 0)', 'test', NULL, array(), 100);
+
+ $expected = create_table($link, 'FLOAT', -10000, 10000, $engine, 110);
+ foreach ($expected as $k => $v)
+ $expected[$k] = number_format(round($v), 0, '.', ',');
+ test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 120);
+
+ $expected = create_table($link, 'FLOAT UNSIGNED', 0, 10000, $engine, 130);
+ foreach ($expected as $k => $v)
+ $expected[$k] = number_format(round($v), 0, '.', ',');
+ test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 140);
+
+ $expected = create_table($link, 'DECIMAL(5,0)', -1000, 1000, $engine, 150);
+ foreach ($expected as $k => $v)
+ $expected[$k] = number_format(round($v), 0, '.', ',');
+ test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 160);
+
+ mysqli_close($link);
+ print "done!";
?>
--CLEAN--
<?php
require_once('skipifconnectfailure.inc');
require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
}
if (mysqli_get_server_version($link) <= 50000) {
- die(sprintf('skip Needs MySQL 5.0+, found version %d.', mysqli_get_server_version($link)));
+ die(sprintf('skip Needs MySQL 5.0+, found version %d.', mysqli_get_server_version($link)));
}
?>
--FILE--
require_once('skipif.inc');
if (!stristr(mysqli_get_client_info(), 'mysqlnd'))
- die("skip: only available in mysqlnd");
+ die("skip: only available in mysqlnd");
require_once('skipifconnectfailure.inc');
require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
}
if (mysqli_get_server_version($link) <= 50000) {
- die(sprintf('skip Needs MySQL 5.0+, found version %d.', mysqli_get_server_version($link)));
+ die(sprintf('skip Needs MySQL 5.0+, found version %d.', mysqli_get_server_version($link)));
}
?>
--FILE--
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_query($link, "DROP PROCEDURE IF EXISTS p");
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
[004] [%s
require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
if (!defined("MYSQLI_ASYNC")) {
- die("skip mysqlnd only");
+ die("skip mysqlnd only");
}
?>
--FILE--
require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
if (!defined("MYSQLI_ASYNC")) {
- die("skip mysqlnd only");
+ die("skip mysqlnd only");
}
?>
--FILE--
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
array(1) {
$link = mysqli_init();
if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
- die(sprintf("skip Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf("skip Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()));
}
include_once("local_infile_tools.inc");
if ($msg = check_local_infile_support($link, $engine))
- die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
+ die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
mysqli_close($link);
?>
mysqli.max_persistent=1
--FILE--
<?php
- include ("connect.inc");
-
- $link = mysqli_init();
- if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
- printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
- }
-
- if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) {
- printf("[002] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- }
-
- if (!mysqli_query($link, 'CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE=' . $engine)) {
- printf("[003] Failed to create test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- }
-
- include("local_infile_tools.inc");
- $file = create_standard_csv(4);
-
- 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("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- }
-
- if (!$res = mysqli_query($link, "SELECT * FROM test ORDER BY id"))
- printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
- $rows = array();
- while ($row = mysqli_fetch_assoc($res)) {
- var_dump($row);
- $rows[] = $row;
- }
-
- mysqli_free_result($res);
-
- 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 appy max_persistent etc.
- Its only about malloc() vs. emalloc().
-
- However, the bug is about malloc() and efree(). You can make 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));
- }
-
- /* 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));
-
- $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++;
- }
- mysqli_close($link);
- }
-
- print "done!";
+ include ("connect.inc");
+
+ $link = mysqli_init();
+ if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
+ printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ }
+
+ if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) {
+ printf("[002] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ }
+
+ if (!mysqli_query($link, 'CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE=' . $engine)) {
+ printf("[003] Failed to create test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ }
+
+ include("local_infile_tools.inc");
+ $file = create_standard_csv(4);
+
+ 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("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ }
+
+ if (!$res = mysqli_query($link, "SELECT * FROM test ORDER BY id"))
+ printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ $rows = array();
+ while ($row = mysqli_fetch_assoc($res)) {
+ var_dump($row);
+ $rows[] = $row;
+ }
+
+ mysqli_free_result($res);
+
+ 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 appy max_persistent etc.
+ Its only about malloc() vs. emalloc().
+
+ However, the bug is about malloc() and efree(). You can make 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));
+ }
+
+ /* 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));
+
+ $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++;
+ }
+ mysqli_close($link);
+ }
+
+ print "done!";
?>
--CLEAN--
<?php
mysqli.reconnect = Off
--FILE--
<?php
- include ("connect.inc");
+ include ("connect.inc");
- $link = mysqli_init();
- if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
- printf("[002] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
- }
- mysqli_close($link);
- echo "closed once\n";
+ $link = mysqli_init();
+ if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
+ printf("[002] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ }
+ mysqli_close($link);
+ echo "closed once\n";
- $link = mysqli_init();
- if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
- printf("[002] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
- }
- mysqli_close($link);
- echo "closed twice\n";
+ $link = mysqli_init();
+ if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
+ printf("[002] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ }
+ mysqli_close($link);
+ echo "closed twice\n";
- $link = mysqli_init();
- if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
- printf("[003] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
- }
- mysqli_close($link);
- echo "closed for third time\n";
+ $link = mysqli_init();
+ if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
+ printf("[003] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ }
+ mysqli_close($link);
+ echo "closed for third time\n";
- print "done!";
+ print "done!";
?>
--EXPECT--
closed once
require_once("connect.inc");
if ($IS_MYSQLND && !extension_loaded("openssl"))
- die("skip PHP streams lack support for SSL. mysqli is compiled to use mysqlnd which uses PHP streams in turn.");
+ 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)))
- die(sprintf("skip Connect failed, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf("skip Connect failed, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
if (false === strpos($link->host_info, 'TCP/IP'))
- die(sprintf("skip SSL only supported on TCP/IP"));
+ die(sprintf("skip SSL only supported on TCP/IP"));
$row = NULL;
if ($res = $link->query('SHOW VARIABLES LIKE "have_ssl"')) {
- $row = $res->fetch_row();
+ $row = $res->fetch_row();
} else {
- if ($link->errno == 1064 && ($res = $link->query("SHOW VARIABLES"))) {
- while ($row = $res->fetch_row())
- if ($row[0] == 'have_ssl')
- break;
- } else {
- die(sprintf("skip Failed to test for MySQL SSL support, [%d] %s", $link->errno, $link->error));
- }
+ if ($link->errno == 1064 && ($res = $link->query("SHOW VARIABLES"))) {
+ while ($row = $res->fetch_row())
+ if ($row[0] == 'have_ssl')
+ break;
+ } else {
+ die(sprintf("skip Failed to test for MySQL SSL support, [%d] %s", $link->errno, $link->error));
+ }
}
if (empty($row))
- die(sprintf("skip Failed to test for MySQL SSL support, [%d] %s", $link->errno, $link->error));
+ die(sprintf("skip Failed to test for MySQL SSL support, [%d] %s", $link->errno, $link->error));
if (($row[1] == 'NO') || ($row[1] == 'DISABLED'))
- die(sprintf("skip MySQL has no SSL support, [%d] %s", $link->errno, $link->error));
+ die(sprintf("skip MySQL has no SSL support, [%d] %s", $link->errno, $link->error));
$link->close();
?>
require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
if (!$IS_MYSQLND) {
- die("skip: test applies only to mysqlnd");
+ die("skip: test applies only to mysqlnd");
}
?>
--FILE--
require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- printf("[clean] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket);
+ printf("[clean] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
}
if (!mysqli_query($link, 'DROP TABLE IF EXISTS tuint')) {
- printf("[clean] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[clean] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (!mysqli_query($link, 'DROP TABLE IF EXISTS tsint')) {
- printf("[clean] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[clean] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
mysqli_close($link);
require_once('skipifconnectfailure.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die("skip Cannot connect to MySQL");
+ die("skip Cannot connect to MySQL");
include_once("local_infile_tools.inc");
if ($msg = check_local_infile_support($link, $engine))
- die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
+ die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
mysqli_close($link);
mysqli.allow_local_infile=1
--FILE--
<?php
- require_once("connect.inc");
+ require_once("connect.inc");
- if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
- }
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ }
- if (!$link->query("DROP TABLE IF EXISTS test")) {
- printf("[002] [%d] %s\n", $link->errno, $link->error);
- }
+ if (!$link->query("DROP TABLE IF EXISTS test")) {
+ printf("[002] [%d] %s\n", $link->errno, $link->error);
+ }
- if (!$link->query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine)) {
- printf("[003] [%d] %s\n", $link->errno, $link->error);
- }
+ if (!$link->query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine)) {
+ printf("[003] [%d] %s\n", $link->errno, $link->error);
+ }
- if (FALSE == file_put_contents('bug53503.data', "1\n2\n3\n"))
- printf("[004] Failed to create CVS file\n");
+ if (FALSE == file_put_contents('bug53503.data', "1\n2\n3\n"))
+ printf("[004] Failed to create CVS file\n");
- if (!$link->query("SELECT 1 FROM DUAL"))
- printf("[005] [%d] %s\n", $link->errno, $link->error);
+ if (!$link->query("SELECT 1 FROM DUAL"))
+ printf("[005] [%d] %s\n", $link->errno, $link->error);
- if (!$link->query("LOAD DATA LOCAL INFILE 'bug53503.data' INTO TABLE test")) {
- printf("[006] [%d] %s\n", $link->errno, $link->error);
- echo "bug";
- } else {
- echo "done";
- }
- $link->close();
+ if (!$link->query("LOAD DATA LOCAL INFILE 'bug53503.data' INTO TABLE test")) {
+ printf("[006] [%d] %s\n", $link->errno, $link->error);
+ echo "bug";
+ } else {
+ echo "done";
+ }
+ $link->close();
?>
--CLEAN--
<?php
mysqli.reconnect = Off
--FILE--
<?php
- include ("connect.inc");
+ include ("connect.inc");
- $link = mysqli_init();
- if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
- printf("[002] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
- }
+ $link = mysqli_init();
+ if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
+ printf("[002] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ }
- $create = "CREATE TEMPORARY TABLE IF NOT EXISTS t54221(a int)";
+ $create = "CREATE TEMPORARY TABLE IF NOT EXISTS t54221(a int)";
- $query = "$create;$create;$create;";
- if ($link->multi_query($query)) {
- do {
- $sth = $link->store_result();
+ $query = "$create;$create;$create;";
+ if ($link->multi_query($query)) {
+ do {
+ $sth = $link->store_result();
- if ($link->warning_count) {
- $warnings = $link->get_warnings();
- if ($warnings) {
- do {
- echo "Warning: ".$warnings->errno.": ".$warnings->message."\n";
- } while ($warnings->next());
- }
- }
- } while ($link->more_results() && $link->next_result());
- }
+ if ($link->warning_count) {
+ $warnings = $link->get_warnings();
+ if ($warnings) {
+ do {
+ echo "Warning: ".$warnings->errno.": ".$warnings->message."\n";
+ } while ($warnings->next());
+ }
+ }
+ } while ($link->more_results() && $link->next_result());
+ }
- mysqli_close($link);
+ mysqli_close($link);
- print "done!";
+ print "done!";
?>
--EXPECT--
Warning: 1050: Table 't54221' already exists
mysqli.reconnect = Off
--FILE--
<?php
- include ("connect.inc");
+ include ("connect.inc");
- $link = mysqli_init();
- if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
- printf("[002] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
- }
+ $link = mysqli_init();
+ if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
+ printf("[002] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ }
- $japanese_so = pack('H4', '835c');
- $link->set_charset('sjis');
- var_dump($link->real_escape_string($japanese_so) === $japanese_so);
- mysqli_close($link);
+ $japanese_so = pack('H4', '835c');
+ $link->set_charset('sjis');
+ var_dump($link->real_escape_string($japanese_so) === $japanese_so);
+ mysqli_close($link);
- print "done!";
+ print "done!";
?>
--EXPECT--
bool(true)
require_once("connect.inc");
if ($IS_MYSQLND && !extension_loaded("openssl"))
- die("skip PHP streams lack support for SSL. mysqli is compiled to use mysqlnd which uses PHP streams in turn.");
+ 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)))
- die(sprintf("skip Connect failed, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf("skip Connect failed, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
if (false === strpos($link->host_info, 'TCP/IP'))
- die(sprintf("skip SSL only supported on TCP/IP"));
+ die(sprintf("skip SSL only supported on TCP/IP"));
$row = NULL;
if ($res = $link->query('SHOW VARIABLES LIKE "have_ssl"')) {
- $row = $res->fetch_row();
+ $row = $res->fetch_row();
} else {
- if ($link->errno == 1064 && ($res = $link->query("SHOW VARIABLES"))) {
- while ($row = $res->fetch_row())
- if ($row[0] == 'have_ssl')
- break;
- } else {
- die(sprintf("skip Failed to test for MySQL SSL support, [%d] %s", $link->errno, $link->error));
- }
+ if ($link->errno == 1064 && ($res = $link->query("SHOW VARIABLES"))) {
+ while ($row = $res->fetch_row())
+ if ($row[0] == 'have_ssl')
+ break;
+ } else {
+ die(sprintf("skip Failed to test for MySQL SSL support, [%d] %s", $link->errno, $link->error));
+ }
}
if (empty($row))
- die(sprintf("skip Failed to test for MySQL SSL support, [%d] %s", $link->errno, $link->error));
+ die(sprintf("skip Failed to test for MySQL SSL support, [%d] %s", $link->errno, $link->error));
if (($row[1] == 'NO') || ($row[1] == 'DISABLED'))
- die(sprintf("skip MySQL has no SSL support, [%d] %s", $link->errno, $link->error));
+ die(sprintf("skip MySQL has no SSL support, [%d] %s", $link->errno, $link->error));
$link->close();
?>
mysqli_float_handling - ensure 4 byte float is handled correctly
--SKIPIF--
<?php
- require_once('skipif.inc');
- require_once('skipifemb.inc');
- require_once('skipifconnectfailure.inc');
+ require_once('skipif.inc');
+ require_once('skipifemb.inc');
+ require_once('skipifconnectfailure.inc');
?>
--INI--
precision=5
--FILE--
<?php
- require('connect.inc');
- if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
- die();
- }
+ require('connect.inc');
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ die();
+ }
- if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) {
- printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- die();
- }
+ if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) {
+ printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ die();
+ }
- if (!mysqli_query($link, "CREATE TABLE test(id INT PRIMARY KEY, fp4 FLOAT, fp8 DOUBLE) ENGINE = InnoDB")) {
- printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- die();
- }
+ if (!mysqli_query($link, "CREATE TABLE test(id INT PRIMARY KEY, fp4 FLOAT, fp8 DOUBLE) ENGINE = InnoDB")) {
+ printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ die();
+ }
- // Insert via string to make sure the real floating number gets to the DB
- if (!mysqli_query($link, "INSERT INTO test(id, fp4, fp8) VALUES (1, 9.9999, 9.9999)")) {
- printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- die();
- }
+ // Insert via string to make sure the real floating number gets to the DB
+ if (!mysqli_query($link, "INSERT INTO test(id, fp4, fp8) VALUES (1, 9.9999, 9.9999)")) {
+ printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ die();
+ }
- if (!($stmt = mysqli_prepare($link, "SELECT id, fp4, fp8 FROM test"))) {
- printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- die();
- }
+ if (!($stmt = mysqli_prepare($link, "SELECT id, fp4, fp8 FROM test"))) {
+ printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ die();
+ }
- $id = null;
- $fp4 = null;
- $fp8 = null;
+ $id = null;
+ $fp4 = null;
+ $fp8 = null;
- if (!mysqli_stmt_bind_result($stmt, $id, $fp4, $fp8)) {
- printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- die();
- }
+ if (!mysqli_stmt_bind_result($stmt, $id, $fp4, $fp8)) {
+ printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ die();
+ }
- if (!mysqli_stmt_execute($stmt)) {
- printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- die();
- }
+ if (!mysqli_stmt_execute($stmt)) {
+ printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ die();
+ }
- if (!(mysqli_stmt_fetch($stmt))) {
- printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- die();
- }
+ if (!(mysqli_stmt_fetch($stmt))) {
+ printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ die();
+ }
- print $id . ": " . $fp4 . ": " . $fp8 . "\n";
+ print $id . ": " . $fp4 . ": " . $fp8 . "\n";
?>
--CLEAN--
<?php
require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
if (!$IS_MYSQLND) {
- die("skip: test applies only to mysqlnd");
+ die("skip: test applies only to mysqlnd");
}
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die("skip Cannot connect to MySQL");
+ die("skip Cannot connect to MySQL");
include_once("local_infile_tools.inc");
if ($msg = check_local_infile_support($link, $engine))
- die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
+ die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
mysqli_close($link);
?>
open_basedir=
--FILE--
<?php
- require_once("connect.inc");
+ require_once("connect.inc");
- ini_set("open_basedir", __DIR__);
- if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
- }
+ ini_set("open_basedir", __DIR__);
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ }
- if (!$link->query("DROP TABLE IF EXISTS test")) {
- printf("[002] [%d] %s\n", $link->errno, $link->error);
- }
+ if (!$link->query("DROP TABLE IF EXISTS test")) {
+ printf("[002] [%d] %s\n", $link->errno, $link->error);
+ }
- if (!$link->query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine)) {
- printf("[003] [%d] %s\n", $link->errno, $link->error);
- }
+ if (!$link->query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine)) {
+ printf("[003] [%d] %s\n", $link->errno, $link->error);
+ }
- if (FALSE == file_put_contents(__DIR__ . '/bug53503.data', "1\n2\n3\n"))
- printf("[004] Failed to create CVS file\n");
+ if (FALSE == file_put_contents(__DIR__ . '/bug53503.data', "1\n2\n3\n"))
+ printf("[004] Failed to create CVS file\n");
- if (!$link->query("SELECT 1 FROM DUAL"))
- printf("[005] [%d] %s\n", $link->errno, $link->error);
+ if (!$link->query("SELECT 1 FROM DUAL"))
+ printf("[005] [%d] %s\n", $link->errno, $link->error);
- if (!$link->query("LOAD DATA LOCAL INFILE '" . str_replace("\\", "/", __DIR__) . "/bug53503.data' INTO TABLE test")) {
- printf("[006] [%d] %s\n", $link->errno, $link->error);
- echo "bug\n";
- } else {
- echo "done\n";
- }
+ if (!$link->query("LOAD DATA LOCAL INFILE '" . str_replace("\\", "/", __DIR__) . "/bug53503.data' INTO TABLE test")) {
+ printf("[006] [%d] %s\n", $link->errno, $link->error);
+ echo "bug\n";
+ } else {
+ echo "done\n";
+ }
- ini_set("open_basedir", __DIR__ . "/dummy");
- if (!$link->query("LOAD DATA LOCAL INFILE '" . __DIR__ . "/bug53503.data' INTO TABLE test")) {
- printf("[006] [%d] %s\n", $link->errno, $link->error);
- echo "done\n";
- } else {
- echo "bug\n";
- }
- $link->close();
+ ini_set("open_basedir", __DIR__ . "/dummy");
+ if (!$link->query("LOAD DATA LOCAL INFILE '" . __DIR__ . "/bug53503.data' INTO TABLE test")) {
+ printf("[006] [%d] %s\n", $link->errno, $link->error);
+ echo "done\n";
+ } else {
+ echo "bug\n";
+ }
+ $link->close();
?>
--CLEAN--
<?php
require_once __DIR__ . '/skipifconnectfailure.inc';
require_once __DIR__ . '/connect.inc';
if (!$IS_MYSQLND) {
- die('skip mysqlnd only');
+ die('skip mysqlnd only');
}
?>
--FILE--
mysqli_float_handling - ensure 4 byte float is handled correctly
--SKIPIF--
<?php
- require_once('skipif.inc');
- require_once('skipifemb.inc');
- require_once('skipifconnectfailure.inc');
- if (@$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- if ($link->server_version < 50709) {
- die("skip MySQL 5.7.9+ needed. Found [".
- intval(substr($link->server_version."", -5, 1)).
- ".".
- intval(substr($link->server_version."", -4, 2)).
- ".".
- intval(substr($link->server_version."", -2, 2)).
- "]");
- }
- }
+ require_once('skipif.inc');
+ require_once('skipifemb.inc');
+ require_once('skipifconnectfailure.inc');
+ if (@$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ if ($link->server_version < 50709) {
+ die("skip MySQL 5.7.9+ needed. Found [".
+ intval(substr($link->server_version."", -5, 1)).
+ ".".
+ intval(substr($link->server_version."", -4, 2)).
+ ".".
+ intval(substr($link->server_version."", -2, 2)).
+ "]");
+ }
+ }
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
OK
require_once('skipifconnectfailure.inc');
require_once("connect.inc");
if (!$IS_MYSQLND) {
- die("skip mysqlnd only test");
+ die("skip mysqlnd only test");
}
?>
--FILE--
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS bug70949"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
require_once('skipifconnectfailure.inc');
require_once("connect.inc");
if (!$IS_MYSQLND) {
- die("skip mysqlnd only test");
+ die("skip mysqlnd only test");
}
?>
--FILE--
require_once("connect.inc");
if ("127.0.0.1" != $host && "localhost" != $host) {
- die("skip require 127.0.0.1 connection");
+ die("skip require 127.0.0.1 connection");
}
?>
require_once("connect.inc");
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die("skip Cannot connect to check required version");
+ die("skip Cannot connect to check required version");
/* Fractional seconds are supported with servers >= 5.6.4. */
if (mysqli_get_server_version($link) < 50604) {
- die(sprintf("skip Server doesn't support fractional seconds in timestamp (%s)", mysqli_get_server_version($link)));
+ die(sprintf("skip Server doesn't support fractional seconds in timestamp (%s)", mysqli_get_server_version($link)));
}
mysqli_close($link);
?>
$link = mysqli_init();
if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
- die(sprintf("skip Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf("skip Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()));
}
require_once('local_infile_tools.inc');
if ($msg = check_local_infile_support($link, $engine))
- die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
+ die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
?>
--INI--
mysqli.allow_local_infile=0
--FILE--
<?php
- require_once("connect.inc");
- if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
- }
- if (!$link->query("DROP TABLE IF EXISTS test")) {
- printf("[002] [%d] %s\n", $link->errno, $link->error);
- }
- if (!$link->query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine)) {
- printf("[003] [%d] %s\n", $link->errno, $link->error);
- }
- if (FALSE == file_put_contents('bug77956.data', "waa? meukee!"))
- printf("[004] Failed to create CVS file\n");
- if (!$link->query("SELECT 1 FROM DUAL"))
- printf("[005] [%d] %s\n", $link->errno, $link->error);
- if (!$link->query("LOAD DATA LOCAL INFILE 'bug77956.data' INTO TABLE test")) {
- printf("[006] [%d] %s\n", $link->errno, $link->error);
- echo "done";
- } else {
- echo "bug";
- }
- $link->close();
+ require_once("connect.inc");
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ }
+ if (!$link->query("DROP TABLE IF EXISTS test")) {
+ printf("[002] [%d] %s\n", $link->errno, $link->error);
+ }
+ if (!$link->query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine)) {
+ printf("[003] [%d] %s\n", $link->errno, $link->error);
+ }
+ if (FALSE == file_put_contents('bug77956.data', "waa? meukee!"))
+ printf("[004] Failed to create CVS file\n");
+ if (!$link->query("SELECT 1 FROM DUAL"))
+ printf("[005] [%d] %s\n", $link->errno, $link->error);
+ if (!$link->query("LOAD DATA LOCAL INFILE 'bug77956.data' INTO TABLE test")) {
+ printf("[006] [%d] %s\n", $link->errno, $link->error);
+ echo "done";
+ } else {
+ echo "bug";
+ }
+ $link->close();
?>
--CLEAN--
<?php
require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- printf("[clean] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket);
+ printf("[clean] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
}
if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) {
- printf("[clean] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[clean] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
mysqli_close($link);
<?php
- /*
- Default values are "localhost", "root",
- database "test" and empty password.
- Change the MYSQL_TEST environment values
- if you want to use another configuration
- */
-
- $driver = new mysqli_driver;
-
- $host = getenv("MYSQL_TEST_HOST") ?: "localhost";
- $port = getenv("MYSQL_TEST_PORT") ?: 3306;
- $user = getenv("MYSQL_TEST_USER") ?: "root";
- $passwd = getenv("MYSQL_TEST_PASSWD") ?: "";
- $db = getenv("MYSQL_TEST_DB") ?: "test";
- $engine = getenv("MYSQL_TEST_ENGINE") ?: "InnoDB";
- $socket = getenv("MYSQL_TEST_SOCKET") ?: null;
- $skip_on_connect_failure = getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") ?: true;
- $connect_flags = (int)getenv("MYSQL_TEST_CONNECT_FLAGS") ?: 0;
- if ($socket) {
- ini_set('mysqli.default_socket', $socket);
- }
-
- /* Development setting: test experimal features and/or feature requests that never worked before? */
- $TEST_EXPERIMENTAL = (in_array(getenv("MYSQL_TEST_EXPERIMENTAL"), array(0, 1))) ?
- ((1 == getenv("MYSQL_TEST_EXPERIMENTAL")) ? true : false) :
- false;
-
- $IS_MYSQLND = stristr(mysqli_get_client_info(), "mysqlnd");
-
- if (!function_exists('sys_get_temp_dir')) {
- function sys_get_temp_dir() {
-
- if (!empty($_ENV['TMP']))
- return realpath( $_ENV['TMP'] );
- if (!empty($_ENV['TMPDIR']))
- return realpath( $_ENV['TMPDIR'] );
- if (!empty($_ENV['TEMP']))
- return realpath( $_ENV['TEMP'] );
-
- $temp_file = tempnam(md5(uniqid(rand(), TRUE)), '');
- if ($temp_file) {
- $temp_dir = realpath(dirname($temp_file));
- unlink($temp_file);
- return $temp_dir;
- }
- return FALSE;
- }
- }
-
- if (!function_exists('my_mysqli_connect')) {
-
- /**
- * Whenever possible, please use this wrapper to make testing ot MYSQLI_CLIENT_COMPRESS (and potentially SSL) possible
- *
- * @param enable_env_flags Enable setting of connection flags through env(MYSQL_TEST_CONNECT_FLAGS)?
- */
- function my_mysqli_connect($host, $user, $passwd, $db, $port, $socket, $enable_env_flags = true) {
- global $connect_flags;
-
- $flags = $enable_env_flags? $connect_flags:0;
- if ($flags !== 0) {
- $link = mysqli_init();
- if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags))
- $link = false;
- } else {
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
- }
-
- return $link;
- }
-
- /**
- * Whenever possible, please use this wrapper to make testing ot MYSQLI_CLIENT_COMPRESS (and potentially SSL) possible
- *
- * @param enable_env_flags Enable setting of connection flags through env(MYSQL_TEST_CONNECT_FLAGS)
- */
- function my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags = 0, $enable_env_flags = true) {
- global $connect_flags;
-
- if ($enable_env_flags)
- $flags = $flags | $connect_flags;
-
- return mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags);
- }
-
- class my_mysqli extends mysqli {
- public function __construct($host, $user, $passwd, $db, $port, $socket, $enable_env_flags = true) {
- global $connect_flags;
-
- $flags = ($enable_env_flags) ? $connect_flags : 0;
-
- if ($flags !== false) {
- parent::init();
- $this->real_connect($host, $user, $passwd, $db, $port, $socket, $flags);
- } else {
- parent::__construct($host, $user, $passwd, $db, $port, $socket);
- }
- }
- }
-
- function have_innodb($link) {
- if (($res = $link->query("SHOW VARIABLES LIKE 'have_innodb'")) &&
- ($row = $res->fetch_row()) &&
- !empty($row)) {
- if ($row[1] == "DISABLED" || $row[1] == "NO") {
- return false;
- }
- return true;
- } else {
- /* MySQL 5.6.1+ */
- if ($res = $link->query("SHOW ENGINES")) {
- while ($row = $res->fetch_assoc()) {
- if (!isset($row['Engine']) || !isset($row['Support']))
- return false;
-
- if (('InnoDB' == $row['Engine']) &&
- (('YES' == $row['Support']) || ('DEFAULT' == $row['Support']))
- ) {
- return true;
- }
- }
- return false;
- } else {
- return false;
- }
- }
- return false;
- }
-
- } else {
- printf("skip Eeeek/BUG/FIXME - connect.inc included twice! skipif bug?\n");
- }
-
- function handle_catchable_fatal($errno, $error, $file, $line) {
- static $errcodes = array();
- if (empty($errcodes)) {
- $constants = get_defined_constants();
- foreach ($constants as $name => $value) {
- if (substr($name, 0, 2) == "E_")
- $errcodes[$value] = $name;
- }
- }
- printf("[%s] %s in %s on line %s\n",
- (isset($errcodes[$errno])) ? $errcodes[$errno] : $errno,
- $error, $file, $line);
-
- return true;
- }
+ /*
+ Default values are "localhost", "root",
+ database "test" and empty password.
+ Change the MYSQL_TEST environment values
+ if you want to use another configuration
+ */
+
+ $driver = new mysqli_driver;
+
+ $host = getenv("MYSQL_TEST_HOST") ?: "localhost";
+ $port = getenv("MYSQL_TEST_PORT") ?: 3306;
+ $user = getenv("MYSQL_TEST_USER") ?: "root";
+ $passwd = getenv("MYSQL_TEST_PASSWD") ?: "";
+ $db = getenv("MYSQL_TEST_DB") ?: "test";
+ $engine = getenv("MYSQL_TEST_ENGINE") ?: "InnoDB";
+ $socket = getenv("MYSQL_TEST_SOCKET") ?: null;
+ $skip_on_connect_failure = getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") ?: true;
+ $connect_flags = (int)getenv("MYSQL_TEST_CONNECT_FLAGS") ?: 0;
+ if ($socket) {
+ ini_set('mysqli.default_socket', $socket);
+ }
+
+ /* Development setting: test experimal features and/or feature requests that never worked before? */
+ $TEST_EXPERIMENTAL = (in_array(getenv("MYSQL_TEST_EXPERIMENTAL"), array(0, 1))) ?
+ ((1 == getenv("MYSQL_TEST_EXPERIMENTAL")) ? true : false) :
+ false;
+
+ $IS_MYSQLND = stristr(mysqli_get_client_info(), "mysqlnd");
+
+ if (!function_exists('sys_get_temp_dir')) {
+ function sys_get_temp_dir() {
+
+ if (!empty($_ENV['TMP']))
+ return realpath( $_ENV['TMP'] );
+ if (!empty($_ENV['TMPDIR']))
+ return realpath( $_ENV['TMPDIR'] );
+ if (!empty($_ENV['TEMP']))
+ return realpath( $_ENV['TEMP'] );
+
+ $temp_file = tempnam(md5(uniqid(rand(), TRUE)), '');
+ if ($temp_file) {
+ $temp_dir = realpath(dirname($temp_file));
+ unlink($temp_file);
+ return $temp_dir;
+ }
+ return FALSE;
+ }
+ }
+
+ if (!function_exists('my_mysqli_connect')) {
+
+ /**
+ * Whenever possible, please use this wrapper to make testing ot MYSQLI_CLIENT_COMPRESS (and potentially SSL) possible
+ *
+ * @param enable_env_flags Enable setting of connection flags through env(MYSQL_TEST_CONNECT_FLAGS)?
+ */
+ function my_mysqli_connect($host, $user, $passwd, $db, $port, $socket, $enable_env_flags = true) {
+ global $connect_flags;
+
+ $flags = $enable_env_flags? $connect_flags:0;
+ if ($flags !== 0) {
+ $link = mysqli_init();
+ if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags))
+ $link = false;
+ } else {
+ $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ }
+
+ return $link;
+ }
+
+ /**
+ * Whenever possible, please use this wrapper to make testing ot MYSQLI_CLIENT_COMPRESS (and potentially SSL) possible
+ *
+ * @param enable_env_flags Enable setting of connection flags through env(MYSQL_TEST_CONNECT_FLAGS)
+ */
+ function my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags = 0, $enable_env_flags = true) {
+ global $connect_flags;
+
+ if ($enable_env_flags)
+ $flags = $flags | $connect_flags;
+
+ return mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags);
+ }
+
+ class my_mysqli extends mysqli {
+ public function __construct($host, $user, $passwd, $db, $port, $socket, $enable_env_flags = true) {
+ global $connect_flags;
+
+ $flags = ($enable_env_flags) ? $connect_flags : 0;
+
+ if ($flags !== false) {
+ parent::init();
+ $this->real_connect($host, $user, $passwd, $db, $port, $socket, $flags);
+ } else {
+ parent::__construct($host, $user, $passwd, $db, $port, $socket);
+ }
+ }
+ }
+
+ function have_innodb($link) {
+ if (($res = $link->query("SHOW VARIABLES LIKE 'have_innodb'")) &&
+ ($row = $res->fetch_row()) &&
+ !empty($row)) {
+ if ($row[1] == "DISABLED" || $row[1] == "NO") {
+ return false;
+ }
+ return true;
+ } else {
+ /* MySQL 5.6.1+ */
+ if ($res = $link->query("SHOW ENGINES")) {
+ while ($row = $res->fetch_assoc()) {
+ if (!isset($row['Engine']) || !isset($row['Support']))
+ return false;
+
+ if (('InnoDB' == $row['Engine']) &&
+ (('YES' == $row['Support']) || ('DEFAULT' == $row['Support']))
+ ) {
+ return true;
+ }
+ }
+ return false;
+ } else {
+ return false;
+ }
+ }
+ return false;
+ }
+
+ } else {
+ printf("skip Eeeek/BUG/FIXME - connect.inc included twice! skipif bug?\n");
+ }
+
+ function handle_catchable_fatal($errno, $error, $file, $line) {
+ static $errcodes = array();
+ if (empty($errcodes)) {
+ $constants = get_defined_constants();
+ foreach ($constants as $name => $value) {
+ if (substr($name, 0, 2) == "E_")
+ $errcodes[$value] = $name;
+ }
+ }
+ printf("[%s] %s in %s on line %s\n",
+ (isset($errcodes[$errno])) ? $errcodes[$errno] : $errno,
+ $error, $file, $line);
+
+ return true;
+ }
?>
=== DONE ===\r
--CLEAN--\r
<?php\r
- require_once("clean_table.inc");\r
+ require_once("clean_table.inc");\r
?>\r
--EXPECT--\r
bool(false)\r
<?php
- /* Utility function for mysqli_set_local_infile*.phpt tests */
- function shutdown_clean($file) {
- if ($file) {
- unlink($file);
- }
- }
-
- function check_local_infile_support($link, $engine, $table_name = 'test') {
-
- if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"'))
- return "Cannot check if Server variable 'local_infile' is set to 'ON'";
-
- $row = mysqli_fetch_assoc($res);
- mysqli_free_result($res);
- if ('ON' != $row['Value'])
- return sprintf("Server variable 'local_infile' seems not set to 'ON', found '%s'", $row['Value']);
-
- if (!mysqli_query($link, sprintf('DROP TABLE IF EXISTS %s', $table_name))) {
- return "Failed to drop old test table";
- }
-
- if (!mysqli_query($link, $sql = sprintf('CREATE TABLE %s(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE=%s',
- $table_name, $engine)))
- return "Failed to create test table: $sql";
-
- $file = create_standard_csv(1, false);
- if (!$file) {
- mysqli_query($link, sprintf('DROP TABLE IF EXISTS %s', $table_name));
- return "Cannot create CSV file";
- }
-
- if (!@mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s'
- INTO TABLE %s
- FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\''
- LINES TERMINATED BY '\n'",
- mysqli_real_escape_string($link, $file),
- $table_name))) {
- if (1148 == mysqli_errno($link)) {
- mysqli_query($link, sprintf('DROP TABLE IF EXISTS %s', $table_name));
- return "Cannot test LOAD DATA LOCAL INFILE, [1148] The used command is not allowed with this MySQL version";
- } else if ($link->errno) {
- return $link->error;
- }
- }
- mysqli_query($link, sprintf('DROP TABLE IF EXISTS %s', $table_name));
- return "";
- }
-
- function create_standard_csv($offset, $verbose = true) {
- // create a CVS file
- $file = tempnam(sys_get_temp_dir(), 'mysqli_test');
- if (!$fp = fopen($file, 'w')) {
- if ($verbose)
- printf("[%03d + 1] Cannot create CVS file '%s'\n", $offset, $file);
- return NULL;
- } else {
- /* Looks ugly? No, handy if you have crashes... */
- register_shutdown_function("shutdown_clean", $file);
- }
-
- if (!fwrite($fp, "97;'x';\n") ||
- !fwrite($fp, "98;'y';\n") ||
- !fwrite($fp, "99;'z';\n")) {
- if ($verbose)
- printf("[%03d + 3] Cannot write CVS file '%s'\n", $offset, $file);
- return NULL;
- }
-
- fclose($fp);
-
- if (!chmod($file, 0644)) {
- if ($verbose)
- printf("[%03d + 4] Cannot change the file perms of '%s' from 0600 to 0644, MySQL might not be able to read it\n",
- $offset, $file);
- return NULL;
- }
- return $file;
- }
-
- function try_handler($offset, $link, $file, $handler, $expected = null) {
-
- if ('default' == $handler) {
- mysqli_set_local_infile_default($link);
- } else if (!mysqli_set_local_infile_handler($link, $handler)) {
- printf("[%03d] Cannot set infile handler to '%s'\n", $offset, $handler);
- return false;
- }
- printf("Callback set to '%s'\n", $handler);
-
- if (!mysqli_query($link, sprintf("DELETE FROM test"))) {
- printf("[%03d] Cannot remove records, [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link));
- return false;
- }
-
- 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("[%03d] LOAD DATA failed, [%d] %s\n",
- $offset + 2,
- mysqli_errno($link), mysqli_error($link));
- }
-
- if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id")) {
- printf("[%03d] [%d] %s\n", $offset + 3, mysqli_errno($link), mysqli_error($link));
- return false;
- }
-
- if (!is_array($expected))
- return true;
-
- foreach ($expected as $k => $values) {
- if (!$tmp = mysqli_fetch_assoc($res)) {
- printf("[%03d/%d] [%d] '%s'\n", $offset + 4, $k, mysqli_errno($link), mysqli_error($link));
- return false;
- }
- if ($values['id'] != $tmp['id']) {
- printf("[%03d/%d] Expecting %s got %s\n",
- $offset + 5, $k,
- $values['id'], $tmp['id']);
- return false;
- }
- if ($values['label'] != $tmp['label']) {
- printf("[%03d/%d] Expecting %s got %s\n",
- $offset + 6, $k,
- $values['label'], $tmp['label']);
- return false;
- }
- }
-
- if ($res && $tmp = mysqli_fetch_assoc($res)) {
- printf("[%03d] More results than expected!\n", $offset + 7);
- do {
- var_dump($tmp);
- } while ($tmp = mysqli_fetch_assoc($res));
- return false;
- }
-
- if ($res)
- mysqli_free_result($res);
-
- return true;
- }
+ /* Utility function for mysqli_set_local_infile*.phpt tests */
+ function shutdown_clean($file) {
+ if ($file) {
+ unlink($file);
+ }
+ }
+
+ function check_local_infile_support($link, $engine, $table_name = 'test') {
+
+ if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"'))
+ return "Cannot check if Server variable 'local_infile' is set to 'ON'";
+
+ $row = mysqli_fetch_assoc($res);
+ mysqli_free_result($res);
+ if ('ON' != $row['Value'])
+ return sprintf("Server variable 'local_infile' seems not set to 'ON', found '%s'", $row['Value']);
+
+ if (!mysqli_query($link, sprintf('DROP TABLE IF EXISTS %s', $table_name))) {
+ return "Failed to drop old test table";
+ }
+
+ if (!mysqli_query($link, $sql = sprintf('CREATE TABLE %s(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE=%s',
+ $table_name, $engine)))
+ return "Failed to create test table: $sql";
+
+ $file = create_standard_csv(1, false);
+ if (!$file) {
+ mysqli_query($link, sprintf('DROP TABLE IF EXISTS %s', $table_name));
+ return "Cannot create CSV file";
+ }
+
+ if (!@mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s'
+ INTO TABLE %s
+ FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\''
+ LINES TERMINATED BY '\n'",
+ mysqli_real_escape_string($link, $file),
+ $table_name))) {
+ if (1148 == mysqli_errno($link)) {
+ mysqli_query($link, sprintf('DROP TABLE IF EXISTS %s', $table_name));
+ return "Cannot test LOAD DATA LOCAL INFILE, [1148] The used command is not allowed with this MySQL version";
+ } else if ($link->errno) {
+ return $link->error;
+ }
+ }
+ mysqli_query($link, sprintf('DROP TABLE IF EXISTS %s', $table_name));
+ return "";
+ }
+
+ function create_standard_csv($offset, $verbose = true) {
+ // create a CVS file
+ $file = tempnam(sys_get_temp_dir(), 'mysqli_test');
+ if (!$fp = fopen($file, 'w')) {
+ if ($verbose)
+ printf("[%03d + 1] Cannot create CVS file '%s'\n", $offset, $file);
+ return NULL;
+ } else {
+ /* Looks ugly? No, handy if you have crashes... */
+ register_shutdown_function("shutdown_clean", $file);
+ }
+
+ if (!fwrite($fp, "97;'x';\n") ||
+ !fwrite($fp, "98;'y';\n") ||
+ !fwrite($fp, "99;'z';\n")) {
+ if ($verbose)
+ printf("[%03d + 3] Cannot write CVS file '%s'\n", $offset, $file);
+ return NULL;
+ }
+
+ fclose($fp);
+
+ if (!chmod($file, 0644)) {
+ if ($verbose)
+ printf("[%03d + 4] Cannot change the file perms of '%s' from 0600 to 0644, MySQL might not be able to read it\n",
+ $offset, $file);
+ return NULL;
+ }
+ return $file;
+ }
+
+ function try_handler($offset, $link, $file, $handler, $expected = null) {
+
+ if ('default' == $handler) {
+ mysqli_set_local_infile_default($link);
+ } else if (!mysqli_set_local_infile_handler($link, $handler)) {
+ printf("[%03d] Cannot set infile handler to '%s'\n", $offset, $handler);
+ return false;
+ }
+ printf("Callback set to '%s'\n", $handler);
+
+ if (!mysqli_query($link, sprintf("DELETE FROM test"))) {
+ printf("[%03d] Cannot remove records, [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+
+ 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("[%03d] LOAD DATA failed, [%d] %s\n",
+ $offset + 2,
+ mysqli_errno($link), mysqli_error($link));
+ }
+
+ if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id")) {
+ printf("[%03d] [%d] %s\n", $offset + 3, mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+
+ if (!is_array($expected))
+ return true;
+
+ foreach ($expected as $k => $values) {
+ if (!$tmp = mysqli_fetch_assoc($res)) {
+ printf("[%03d/%d] [%d] '%s'\n", $offset + 4, $k, mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+ if ($values['id'] != $tmp['id']) {
+ printf("[%03d/%d] Expecting %s got %s\n",
+ $offset + 5, $k,
+ $values['id'], $tmp['id']);
+ return false;
+ }
+ if ($values['label'] != $tmp['label']) {
+ printf("[%03d/%d] Expecting %s got %s\n",
+ $offset + 6, $k,
+ $values['label'], $tmp['label']);
+ return false;
+ }
+ }
+
+ if ($res && $tmp = mysqli_fetch_assoc($res)) {
+ printf("[%03d] More results than expected!\n", $offset + 7);
+ do {
+ var_dump($tmp);
+ } while ($tmp = mysqli_fetch_assoc($res));
+ return false;
+ }
+
+ if ($res)
+ mysqli_free_result($res);
+
+ return true;
+ }
?>
mysqli_affected_rows()
--SKIPIF--
<?php
- require_once('skipif.inc');
- require_once('skipifemb.inc');
- require_once('skipifconnectfailure.inc');
+ require_once('skipif.inc');
+ require_once('skipifemb.inc');
+ require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
mysqli->affected_rows
--SKIPIF--
<?php
- require_once('skipif.inc');
- require_once('skipifemb.inc');
- require_once('skipifconnectfailure.inc');
+ require_once('skipif.inc');
+ require_once('skipifemb.inc');
+ require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
require_once('connect.inc');
if (!$link = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- die(sprintf("SKIP Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket));
+ die(sprintf("SKIP Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket));
}
if ($link->server_version < 50500)
- die(sprintf("SKIP Needs MySQL 5.5 or newer, found MySQL %s\n", $link->server_info));
+ die(sprintf("SKIP Needs MySQL 5.5 or newer, found MySQL %s\n", $link->server_info));
if (!$res = $link->query("SHOW PLUGINS"))
- die(sprintf("SKIP [%d] %s\n", $link->errno, $link->error));
+ die(sprintf("SKIP [%d] %s\n", $link->errno, $link->error));
$have_pam = false;
while ($row = $res->fetch_assoc()) {
- if (isset($row['Name']) && ('mysql_clear_password' == $row['Name'])) {
- $have_pam = true;
- break;
- }
+ if (isset($row['Name']) && ('mysql_clear_password' == $row['Name'])) {
+ $have_pam = true;
+ break;
+ }
}
$res->close();
mysqli_query($link, 'DROP USER pamtest@localhost');
if (!mysqli_query($link, 'CREATE USER pamtest@"%" IDENTIFIED WITH mysql_clear_password') ||
- !mysqli_query($link, 'CREATE USER pamtest@"localhost" IDENTIFIED WITH mysql_clear_password')) {
- printf("skip Cannot create second DB user [%d] %s", mysqli_errno($link), mysqli_error($link));
- mysqli_close($link);
- die("skip CREATE USER failed");
+ !mysqli_query($link, 'CREATE USER pamtest@"localhost" IDENTIFIED WITH mysql_clear_password')) {
+ printf("skip Cannot create second DB user [%d] %s", mysqli_errno($link), mysqli_error($link));
+ mysqli_close($link);
+ die("skip CREATE USER failed");
}
if (!$link->query("CREATE TABLE test (id INT)") || !$link->query("INSERT INTO test(id) VALUES (1)"))
- die(sprintf("SKIP [%d] %s\n", $link->errno, $link->error));
+ die(sprintf("SKIP [%d] %s\n", $link->errno, $link->error));
if (!mysqli_query($link, sprintf("GRANT SELECT ON TABLE %s.test TO pamtest@'%%'", $db)) ||
- !mysqli_query($link, sprintf("GRANT SELECT ON TABLE %s.test TO pamtest@'localhost'", $db))) {
- printf("skip Cannot grant SELECT to user [%d] %s", mysqli_errno($link), mysqli_error($link));
- mysqli_close($link);
- die("skip GRANT failed");
+ !mysqli_query($link, sprintf("GRANT SELECT ON TABLE %s.test TO pamtest@'localhost'", $db))) {
+ printf("skip Cannot grant SELECT to user [%d] %s", mysqli_errno($link), mysqli_error($link));
+ mysqli_close($link);
+ die("skip GRANT failed");
}
?>
--INI--
max_execution_time=240
--FILE--
<?php
- require_once('connect.inc');
- require_once('table.inc');
+ require_once('connect.inc');
+ require_once('table.inc');
- if (!$link = my_mysqli_connect($host, 'pamtest', 'pamtest', $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);
- } else {
+ if (!$link = my_mysqli_connect($host, 'pamtest', 'pamtest', $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);
+ } else {
- if (!$res = $link->query("SELECT id FROM test WHERE id = 1"))
- printf("[002] [%d] %s\n", $link->errno, $link->error);
+ if (!$res = $link->query("SELECT id FROM test WHERE id = 1"))
+ printf("[002] [%d] %s\n", $link->errno, $link->error);
- if (!$row = mysqli_fetch_assoc($res)) {
- printf("[003] [%d] %s\n", $link->errno, $link->error);
- }
+ if (!$row = mysqli_fetch_assoc($res)) {
+ printf("[003] [%d] %s\n", $link->errno, $link->error);
+ }
- if ($row['id'] != 1) {
- printf("[004] Expecting 1 got %s/'%s'", gettype($row['id']), $row['id']);
- }
+ if ($row['id'] != 1) {
+ printf("[004] Expecting 1 got %s/'%s'", gettype($row['id']), $row['id']);
+ }
- $res->close();
- $link->close();
- }
+ $res->close();
+ $link->close();
+ }
- print "done!";
+ print "done!";
?>
--CLEAN--
<?php
mysqli_autocommit()
--SKIPIF--
<?php
- require_once('skipif.inc');
- require_once('skipifemb.inc');
- require_once('connect.inc');
- require_once('skipifconnectfailure.inc');
-
- if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket));
- }
-
- if (!have_innodb($link))
- die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
+ require_once('skipif.inc');
+ require_once('skipifemb.inc');
+ require_once('connect.inc');
+ require_once('skipifconnectfailure.inc');
+
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket));
+ }
+
+ if (!have_innodb($link))
+ die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
mysqli->autocommit()
--SKIPIF--
<?php
- require_once('skipif.inc');
- require_once('skipifemb.inc');
- require_once('skipifconnectfailure.inc');
- require_once('connect.inc');
-
- if (!$link = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) {
- printf("skip 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);
- }
-
- if (!have_innodb($link))
- die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
+ require_once('skipif.inc');
+ require_once('skipifemb.inc');
+ require_once('skipifconnectfailure.inc');
+ require_once('connect.inc');
+
+ if (!$link = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) {
+ printf("skip 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);
+ }
+
+ if (!have_innodb($link))
+ die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
if (!have_innodb($link))
- die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
+ die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
NULL
max_execution_time=240
--FILE--
<?php
- require_once('connect.inc');
- require_once('table.inc');
+ require_once('connect.inc');
+ require_once('table.inc');
- // We need this little hack to be able to re-run the test
- $lock = 'phptest_' . mt_rand(0, 100000);
- $thread_id = mysqli_thread_id($link);
+ // We need this little hack to be able to re-run the test
+ $lock = 'phptest_' . mt_rand(0, 100000);
+ $thread_id = mysqli_thread_id($link);
- printf("Testing GET_LOCK()...\n");
+ printf("Testing GET_LOCK()...\n");
- if (!$res = mysqli_query($link, sprintf('SELECT GET_LOCK("%s", 2) AS _ok', $lock)))
- printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!$res = mysqli_query($link, sprintf('SELECT GET_LOCK("%s", 2) AS _ok', $lock)))
+ printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- if (!$row = mysqli_fetch_assoc($res))
- printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!$row = mysqli_fetch_assoc($res))
+ printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- if ($row['_ok'] != 1)
- printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- else
- printf("... lock '%s' acquired by thread %d\n", $lock, $thread_id);
+ if ($row['_ok'] != 1)
+ printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ else
+ printf("... lock '%s' acquired by thread %d\n", $lock, $thread_id);
- mysqli_free_result($res);
+ mysqli_free_result($res);
- // GET_LOCK("phptest") should be released
- /* From the mysql_change_user documentation:
+ // GET_LOCK("phptest") should be released
+ /* From the mysql_change_user documentation:
This command resets the state as if one had done a new connect. (See Section 25.2.13, “Controlling Automatic Reconnect Behavior”.) It always performs a ROLLBACK of any active transactions, closes and drops all temporary tables, and unlocks all locked tables. Session system variables are reset to the values of the corresponding global system variables. Prepared statements are released and HANDLER variables are closed. Locks acquired with GET_LOCK() are released. These effects occur even if the user didn't change.
- */
- mysqli_change_user($link, $user, $passwd, $db);
+ */
+ mysqli_change_user($link, $user, $passwd, $db);
sleep(5);
- $new_thread_id = mysqli_thread_id($link);
+ $new_thread_id = mysqli_thread_id($link);
- printf("... calling IS_USED_LOCK() on '%s' using thread '%d'\n", $lock, $new_thread_id);
- if (!$res = mysqli_query($link, 'SELECT IS_USED_LOCK("phptest") AS _ok'))
- printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("... calling IS_USED_LOCK() on '%s' using thread '%d'\n", $lock, $new_thread_id);
+ if (!$res = mysqli_query($link, 'SELECT IS_USED_LOCK("phptest") AS _ok'))
+ printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- if (!$row = mysqli_fetch_assoc($res))
- printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!$row = mysqli_fetch_assoc($res))
+ printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- if ($row['_ok'] != NULL)
- printf("[006] Lock '%s' should have been released, [%d] %s\n",
- $lock,
- mysqli_errno($link), mysqli_error($link));
+ if ($row['_ok'] != NULL)
+ printf("[006] Lock '%s' should have been released, [%d] %s\n",
+ $lock,
+ mysqli_errno($link), mysqli_error($link));
- printf("... calling IS_FREE_LOCK() on '%s' using thread '%d'\n", $lock, $new_thread_id);
- if (!$res = mysqli_query($link, 'SELECT IS_FREE_LOCK("phptest") AS _ok'))
- printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("... calling IS_FREE_LOCK() on '%s' using thread '%d'\n", $lock, $new_thread_id);
+ if (!$res = mysqli_query($link, 'SELECT IS_FREE_LOCK("phptest") AS _ok'))
+ printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- if (!$row = mysqli_fetch_assoc($res))
- printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!$row = mysqli_fetch_assoc($res))
+ printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- if ($row['_ok'] != 1)
- printf("[009] Lock '%s' should have been released, [%d] %s\n",
- $lock,
- mysqli_errno($link), mysqli_error($link));
+ if ($row['_ok'] != 1)
+ printf("[009] Lock '%s' should have been released, [%d] %s\n",
+ $lock,
+ mysqli_errno($link), mysqli_error($link));
- mysqli_free_result($res);
+ mysqli_free_result($res);
- /* Ok, let's try a NEW connection and a NEW lock! */
- mysqli_close($link);
- if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- printf("[010] Cannot open new connection, [%d] %s\n",
- mysqli_connect_errno(), mysqli_connect_error());
+ /* Ok, let's try a NEW connection and a NEW lock! */
+ mysqli_close($link);
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[010] Cannot open new connection, [%d] %s\n",
+ mysqli_connect_errno(), mysqli_connect_error());
- do {
- $newlock = 'phptest_' . mt_rand(0, 100000);
- } while ($lock == $newlock);
+ do {
+ $newlock = 'phptest_' . mt_rand(0, 100000);
+ } while ($lock == $newlock);
- $new_thread_id = mysqli_thread_id($link);
- printf("... calling IS_USED_LOCK() on '%s' using new connection with thread '%d'\n", $newlock, $new_thread_id);
- if (!$res = mysqli_query($link, 'SELECT IS_USED_LOCK("phptest") AS _ok'))
- printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ $new_thread_id = mysqli_thread_id($link);
+ printf("... calling IS_USED_LOCK() on '%s' using new connection with thread '%d'\n", $newlock, $new_thread_id);
+ if (!$res = mysqli_query($link, 'SELECT IS_USED_LOCK("phptest") AS _ok'))
+ printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- if (!$row = mysqli_fetch_assoc($res))
- printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!$row = mysqli_fetch_assoc($res))
+ printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- if ($row['_ok'] != NULL)
- printf("[013] Lock '%s' should have been released, [%d] %s\n",
- $lock,
- mysqli_errno($link), mysqli_error($link));
+ if ($row['_ok'] != NULL)
+ printf("[013] Lock '%s' should have been released, [%d] %s\n",
+ $lock,
+ mysqli_errno($link), mysqli_error($link));
- print "done!";
+ print "done!";
?>
--CLEAN--
<?php
require_once('connect.inc');
if (!$IS_MYSQLND) {
- die("skip Might hit known and open bugs http://bugs.mysql.com/bug.php?id=30472, http://bugs.mysql.com/bug.php?id=45184");
+ die("skip Might hit known and open bugs http://bugs.mysql.com/bug.php?id=30472, http://bugs.mysql.com/bug.php?id=45184");
}
?>
--FILE--
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
require_once('skipifconnectfailure.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die(sprintf("SKIP Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket));
+ die(sprintf("SKIP Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket));
if (mysqli_get_server_version($link) < 50600)
- die("SKIP For MySQL >= 5.6.0");
+ die("SKIP For MySQL >= 5.6.0");
?>
--FILE--
<?php
require_once('skipifconnectfailure.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die(sprintf("SKIP Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket));
+ die(sprintf("SKIP Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket));
if (mysqli_get_server_version($link) >= 50600)
- die("SKIP For MySQL < 5.6.0");
+ die("SKIP For MySQL < 5.6.0");
?>
--FILE--
<?php
require_once('table.inc');
if (!$IS_MYSQLND && (mysqli_get_server_version($link) < 50118 && mysqli_get_server_version($link) > 50100)) {
- die("skip Your MySQL Server version has a known bug that will cause a crash");
+ 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");
+ die("SKIP For MySQL < 5.6.0");
?>
--FILE--
<?php
require_once('skipifconnectfailure.inc');
require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
if (!have_innodb($link))
- die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
+ die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
require_once('skipifconnectfailure.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die(sprintf("skip [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf("skip [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
if (!$res = mysqli_query($link, 'SELECT version() AS server_version'))
- die(sprintf("skip [%d] %s\n", mysqli_errno($link), mysqli_error($link)));
+ die(sprintf("skip [%d] %s\n", mysqli_errno($link), mysqli_error($link)));
$tmp = mysqli_fetch_assoc($res);
mysqli_free_result($res);
$version = explode('.', $tmp['server_version']);
if (empty($version))
- die(sprintf("skip Cannot determine server version, we need MySQL Server 4.1+ for the test!"));
+ die(sprintf("skip Cannot determine server version, we need MySQL Server 4.1+ for the test!"));
if ($version[0] <= 4 && $version[1] < 1)
- die(sprintf("skip We need MySQL Server 4.1+ for the test!"));
+ die(sprintf("skip We need MySQL Server 4.1+ for the test!"));
?>
--FILE--
<?php
require_once('skipifemb.inc');
if (!function_exists('mysqli_set_charset')) {
- die('skip mysqli_set_charset() not available');
+ die('skip mysqli_set_charset() not available');
}
?>
--FILE--
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
mysqli_chararcter_set_name(), mysql_client_encoding() [alias]
--SKIPIF--
<?php
- require_once('skipif.inc');
- require_once('skipifemb.inc');
- require_once('skipifconnectfailure.inc');
+ require_once('skipif.inc');
+ require_once('skipifemb.inc');
+ require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
Those tests go into the details and are aimed to be a development tool, no more.
*/
if (!$IS_MYSQLND)
- die("skip Test has been written for the latest version of mysqlnd only");
+ die("skip Test has been written for the latest version of mysqlnd only");
?>
--FILE--
<?php
Those tests go into the details and are aimed to be a development tool, no more.
*/
if (!$IS_MYSQLND)
- die("skip Test has been written for mysqlnd only");
+ die("skip Test has been written for mysqlnd only");
?>
--FILE--
Those tests go into the details and are aimed to be a development tool, no more.
*/
if (!$IS_MYSQLND)
- die("skip Test has been written for mysqlnd only");
+ die("skip Test has been written for mysqlnd only");
?>
--FILE--
<?php
Interface of the class mysqli_stmt
--SKIPIF--
<?php
- require_once('skipif.inc');
- require_once('skipifemb.inc');
- require_once('skipifconnectfailure.inc');
+ require_once('skipif.inc');
+ require_once('skipifemb.inc');
+ require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
require_once('connect.inc');
if (!$TEST_EXPERIMENTAL)
- die("skip - experimental (= unsupported) feature");
+ die("skip - experimental (= unsupported) feature");
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: Wrong parameter count for mysqli_warning::mysqli_warning() in %s on line %d
Those tests go into the details and are aimed to be a development tool, no more.
*/
if (!$IS_MYSQLND)
- die("skip Test has been written for mysqlnd only");
+ die("skip Test has been written for mysqlnd only");
?>
--FILE--
<?php
require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
if (!have_innodb($link))
- die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
+ die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
if (!have_innodb($link))
- die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
+ die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli::commit(): Transaction name truncated. Must be only [0-9A-Za-z\-_=]+ in %s on line %d
require_once('skipifconnectfailure.inc');
if (!$IS_MYSQLND)
- die("skip: test applies only to mysqlnd");
+ die("skip: test applies only to mysqlnd");
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die("skip Cannot connect to the server");
+ die("skip Cannot connect to the server");
/* skip test if the server version does not have session_connect_attrs table yet*/
if (!$res = mysqli_query($link, "select count(*) as count from information_schema.tables where table_schema='performance_schema' and table_name='session_connect_attrs';"))
new mysqli()
--SKIPIF--
<?php
- require_once('skipif.inc');
- require_once('skipifemb.inc');
- require_once('skipifconnectfailure.inc');
- if (!get_current_user())
- die('skip: get_current_user() not supported');
- if (stristr(mysqli_get_client_info(), 'mysqlnd'))
- die("skip: test for libmysql (different error output when using php streams");
+ require_once('skipif.inc');
+ require_once('skipifemb.inc');
+ require_once('skipifconnectfailure.inc');
+ if (!get_current_user())
+ die('skip: get_current_user() not supported');
+ if (stristr(mysqli_get_client_info(), 'mysqlnd'))
+ die("skip: test for libmysql (different error output when using php streams");
?>
--FILE--
<?php
mysqli.allow_local_infile=1
--FILE--
<?php
- require("connect.inc");
- require("table.inc");
-
- $php_version = (int)str_replace('.', '', PHP_VERSION);
- $constants = get_defined_constants(true);
- sort($constants);
-
- $expected_constants = array(
- 'MYSQLI_READ_DEFAULT_GROUP' => true,
- 'MYSQLI_READ_DEFAULT_FILE' => true,
- 'MYSQLI_OPT_CONNECT_TIMEOUT' => true,
- 'MYSQLI_OPT_LOCAL_INFILE' => true,
- 'MYSQLI_OPT_READ_TIMEOUT' => true,
- 'MYSQLI_INIT_COMMAND' => true,
- 'MYSQLI_CLIENT_SSL' => true,
- "MYSQLI_CLIENT_COMPRESS" => true,
- "MYSQLI_CLIENT_INTERACTIVE" => true,
- "MYSQLI_CLIENT_IGNORE_SPACE" => true,
- "MYSQLI_CLIENT_NO_SCHEMA" => true,
- "MYSQLI_CLIENT_FOUND_ROWS" => true,
- "MYSQLI_STORE_RESULT" => true,
- "MYSQLI_USE_RESULT" => true,
- "MYSQLI_ASSOC" => true,
- "MYSQLI_NUM" => true,
- "MYSQLI_BOTH" => true,
- "MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH"=> true,
- "MYSQLI_NOT_NULL_FLAG" => true,
- "MYSQLI_PRI_KEY_FLAG" => true,
- "MYSQLI_UNIQUE_KEY_FLAG" => true,
- "MYSQLI_MULTIPLE_KEY_FLAG" => true,
- "MYSQLI_BLOB_FLAG" => true,
- "MYSQLI_UNSIGNED_FLAG" => true,
- "MYSQLI_ZEROFILL_FLAG" => true,
- "MYSQLI_AUTO_INCREMENT_FLAG" => true,
- "MYSQLI_TIMESTAMP_FLAG" => true,
- "MYSQLI_SET_FLAG" => true,
- "MYSQLI_NUM_FLAG" => true,
- "MYSQLI_ENUM_FLAG" => true,
- "MYSQLI_BINARY_FLAG" => true,
- "MYSQLI_PART_KEY_FLAG" => true,
- "MYSQLI_GROUP_FLAG" => true,
- "MYSQLI_SERVER_QUERY_NO_GOOD_INDEX_USED"=> true,
- "MYSQLI_SERVER_QUERY_NO_INDEX_USED" => true,
-
- "MYSQLI_TYPE_DECIMAL" => true,
- "MYSQLI_TYPE_TINY" => true,
- "MYSQLI_TYPE_SHORT" => true,
- "MYSQLI_TYPE_LONG" => true,
- "MYSQLI_TYPE_FLOAT" => true,
- "MYSQLI_TYPE_DOUBLE" => true,
- "MYSQLI_TYPE_NULL" => true,
- "MYSQLI_TYPE_TIMESTAMP" => true,
- "MYSQLI_TYPE_LONGLONG" => true,
- "MYSQLI_TYPE_INT24" => true,
- "MYSQLI_TYPE_DATE" => true,
- "MYSQLI_TYPE_TIME" => true,
- "MYSQLI_TYPE_DATETIME" => true,
- "MYSQLI_TYPE_YEAR" => true,
- "MYSQLI_TYPE_NEWDATE" => true,
- "MYSQLI_TYPE_ENUM" => true,
- "MYSQLI_TYPE_SET" => true,
- "MYSQLI_TYPE_TINY_BLOB" => true,
- "MYSQLI_TYPE_MEDIUM_BLOB" => true,
- "MYSQLI_TYPE_LONG_BLOB" => true,
- "MYSQLI_TYPE_BLOB" => true,
- "MYSQLI_TYPE_VAR_STRING" => true,
- "MYSQLI_TYPE_STRING" => true,
- "MYSQLI_TYPE_CHAR" => true,
- "MYSQLI_TYPE_INTERVAL" => true,
- "MYSQLI_TYPE_GEOMETRY" => true,
- "MYSQLI_NO_DATA" => true,
- "MYSQLI_REPORT_INDEX" => true,
- "MYSQLI_REPORT_STRICT" => true,
- "MYSQLI_REPORT_ALL" => true,
- "MYSQLI_REPORT_ERROR" => true,
- "MYSQLI_REPORT_OFF" => true,
- "MYSQLI_SET_CHARSET_NAME" => true,
- "MYSQLI_SET_CHARSET_DIR" => true,
- "MYSQLI_REFRESH_GRANT" => true,
- "MYSQLI_REFRESH_LOG" => true,
- "MYSQLI_REFRESH_TABLES" => true,
- "MYSQLI_REFRESH_HOSTS" => true,
- "MYSQLI_REFRESH_STATUS" => true,
- "MYSQLI_REFRESH_THREADS" => true,
- "MYSQLI_REFRESH_SLAVE" => true,
- "MYSQLI_REFRESH_MASTER" => true,
- "MYSQLI_DEBUG_TRACE_ENABLED" => true,
- "MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT" => true,
- "MYSQLI_TRANS_START_READ_WRITE" => true,
- "MYSQLI_TRANS_START_READ_ONLY" => true,
- "MYSQLI_TRANS_COR_AND_CHAIN" => true,
- "MYSQLI_TRANS_COR_AND_NO_CHAIN" => true,
- "MYSQLI_TRANS_COR_RELEASE" => true,
- "MYSQLI_TRANS_COR_NO_RELEASE" => true,
- );
-
- /* depends on the build - experimental */
- if ($IS_MYSQLND && defined('MYSQLI_OPT_INT_AND_FLOAT_NATIVE')) {
- $expected_constants['MYSQLI_OPT_INT_AND_FLOAT_NATIVE'] = true;
- }
-
- if ($IS_MYSQLND && defined('MYSQLI_STORE_RESULT_COPY_DATA')) {
- $expected_constants['MYSQLI_STORE_RESULT_COPY_DATA'] = true;
- }
-
- if ($IS_MYSQLND || defined('MYSQLI_REFRESH_BACKUP_LOG')) {
- $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;
-
- $expected_constants['MYSQLI_SERVER_PS_OUT_PARAMS'] = true;
- } else {
- $version = mysqli_get_client_version();
- }
-
- if (($version > 51122 && $version < 60000) || ($version > 60003) || $IS_MYSQLND) {
- $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;
- }
-
- if ($version >= 50033 || $IS_MYSQLND) {
- $expected_constants['MYSQLI_CLIENT_SSL_VERIFY_SERVER_CERT'] = true;
- }
- if ($IS_MYSQLND) {
- $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;
- }
-
- if ($version > 50002) {
- $expected_constants = array_merge($expected_constants, array(
- "MYSQLI_TYPE_NEWDECIMAL" => true,
- "MYSQLI_TYPE_BIT" => true,
- ));
- }
-
- if ($version > 50002 || $IS_MYSQLND) {
- $expected_constants['MYSQLI_NO_DEFAULT_VALUE_FLAG'] = true;
- }
-
- if ($version > 50003) {
- $expected_constants = array_merge($expected_constants, array(
- "MYSQLI_STMT_ATTR_CURSOR_TYPE" => true,
- "MYSQLI_CURSOR_TYPE_NO_CURSOR" => true,
- "MYSQLI_CURSOR_TYPE_READ_ONLY" => true,
- "MYSQLI_CURSOR_TYPE_FOR_UPDATE" => true,
- "MYSQLI_CURSOR_TYPE_SCROLLABLE" => true,
- ));
- }
-
- if ($version > 50007) {
- $expected_constants = array_merge($expected_constants, array(
- "MYSQLI_STMT_ATTR_PREFETCH_ROWS" => true,
- ));
- }
-
- if ($version > 50110 || $IS_MYSQLND) {
- $expected_constants['MYSQLI_OPT_SSL_VERIFY_SERVER_CERT'] = true;
- }
-
- /* pretty dump test, but that is the best way to mimic mysql.c */
- if (defined('MYSQLI_DATA_TRUNCATED'))
- $expected_constants["MYSQLI_DATA_TRUNCATED"] = true;
-
- if (defined('MYSQLI_SERVER_PS_OUT_PARAMS'))
- $expected_constants["MYSQLI_SERVER_PS_OUT_PARAMS"] = true;
-
- if (!$IS_MYSQLND) {
- /* libmysql only */
-
- /* are they available in all versions of ext/mysqli ?
- ... no we must have removed them at some point - for BC, weakening the test
- */
- if (defined("MYSQLI_RPL_MASTER")) {
- $expected_constants["MYSQLI_RPL_MASTER"] = true;
- $expected_constants["MYSQLI_RPL_SLAVE"] = true;
- $expected_constants["MYSQLI_RPL_ADMIN"] = 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;
- }
-
- if ($IS_MYSQLND) {
- $expected_constants["MYSQLI_TYPE_JSON"] = true;
- }
-
- $unexpected_constants = array();
-
- foreach ($constants as $group => $consts) {
- foreach ($consts as $name => $value) {
- if (stristr($name, 'mysqli')) {
- $name = strtoupper($name);
- if (isset($expected_constants[$name])) {
- unset($expected_constants[$name]);
- } else {
- $unexpected_constants[$name] = $name;
- }
- }
- }
- }
-
- if (!empty($unexpected_constants)) {
- printf("Dumping list of unexpected constants\n");
- var_dump($unexpected_constants);
- }
-
- if (!empty($expected_constants)) {
- printf("Dumping list of missing constants\n");
- var_dump($expected_constants);
- }
-
- print "done!";
+ require("connect.inc");
+ require("table.inc");
+
+ $php_version = (int)str_replace('.', '', PHP_VERSION);
+ $constants = get_defined_constants(true);
+ sort($constants);
+
+ $expected_constants = array(
+ 'MYSQLI_READ_DEFAULT_GROUP' => true,
+ 'MYSQLI_READ_DEFAULT_FILE' => true,
+ 'MYSQLI_OPT_CONNECT_TIMEOUT' => true,
+ 'MYSQLI_OPT_LOCAL_INFILE' => true,
+ 'MYSQLI_OPT_READ_TIMEOUT' => true,
+ 'MYSQLI_INIT_COMMAND' => true,
+ 'MYSQLI_CLIENT_SSL' => true,
+ "MYSQLI_CLIENT_COMPRESS" => true,
+ "MYSQLI_CLIENT_INTERACTIVE" => true,
+ "MYSQLI_CLIENT_IGNORE_SPACE" => true,
+ "MYSQLI_CLIENT_NO_SCHEMA" => true,
+ "MYSQLI_CLIENT_FOUND_ROWS" => true,
+ "MYSQLI_STORE_RESULT" => true,
+ "MYSQLI_USE_RESULT" => true,
+ "MYSQLI_ASSOC" => true,
+ "MYSQLI_NUM" => true,
+ "MYSQLI_BOTH" => true,
+ "MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH"=> true,
+ "MYSQLI_NOT_NULL_FLAG" => true,
+ "MYSQLI_PRI_KEY_FLAG" => true,
+ "MYSQLI_UNIQUE_KEY_FLAG" => true,
+ "MYSQLI_MULTIPLE_KEY_FLAG" => true,
+ "MYSQLI_BLOB_FLAG" => true,
+ "MYSQLI_UNSIGNED_FLAG" => true,
+ "MYSQLI_ZEROFILL_FLAG" => true,
+ "MYSQLI_AUTO_INCREMENT_FLAG" => true,
+ "MYSQLI_TIMESTAMP_FLAG" => true,
+ "MYSQLI_SET_FLAG" => true,
+ "MYSQLI_NUM_FLAG" => true,
+ "MYSQLI_ENUM_FLAG" => true,
+ "MYSQLI_BINARY_FLAG" => true,
+ "MYSQLI_PART_KEY_FLAG" => true,
+ "MYSQLI_GROUP_FLAG" => true,
+ "MYSQLI_SERVER_QUERY_NO_GOOD_INDEX_USED"=> true,
+ "MYSQLI_SERVER_QUERY_NO_INDEX_USED" => true,
+
+ "MYSQLI_TYPE_DECIMAL" => true,
+ "MYSQLI_TYPE_TINY" => true,
+ "MYSQLI_TYPE_SHORT" => true,
+ "MYSQLI_TYPE_LONG" => true,
+ "MYSQLI_TYPE_FLOAT" => true,
+ "MYSQLI_TYPE_DOUBLE" => true,
+ "MYSQLI_TYPE_NULL" => true,
+ "MYSQLI_TYPE_TIMESTAMP" => true,
+ "MYSQLI_TYPE_LONGLONG" => true,
+ "MYSQLI_TYPE_INT24" => true,
+ "MYSQLI_TYPE_DATE" => true,
+ "MYSQLI_TYPE_TIME" => true,
+ "MYSQLI_TYPE_DATETIME" => true,
+ "MYSQLI_TYPE_YEAR" => true,
+ "MYSQLI_TYPE_NEWDATE" => true,
+ "MYSQLI_TYPE_ENUM" => true,
+ "MYSQLI_TYPE_SET" => true,
+ "MYSQLI_TYPE_TINY_BLOB" => true,
+ "MYSQLI_TYPE_MEDIUM_BLOB" => true,
+ "MYSQLI_TYPE_LONG_BLOB" => true,
+ "MYSQLI_TYPE_BLOB" => true,
+ "MYSQLI_TYPE_VAR_STRING" => true,
+ "MYSQLI_TYPE_STRING" => true,
+ "MYSQLI_TYPE_CHAR" => true,
+ "MYSQLI_TYPE_INTERVAL" => true,
+ "MYSQLI_TYPE_GEOMETRY" => true,
+ "MYSQLI_NO_DATA" => true,
+ "MYSQLI_REPORT_INDEX" => true,
+ "MYSQLI_REPORT_STRICT" => true,
+ "MYSQLI_REPORT_ALL" => true,
+ "MYSQLI_REPORT_ERROR" => true,
+ "MYSQLI_REPORT_OFF" => true,
+ "MYSQLI_SET_CHARSET_NAME" => true,
+ "MYSQLI_SET_CHARSET_DIR" => true,
+ "MYSQLI_REFRESH_GRANT" => true,
+ "MYSQLI_REFRESH_LOG" => true,
+ "MYSQLI_REFRESH_TABLES" => true,
+ "MYSQLI_REFRESH_HOSTS" => true,
+ "MYSQLI_REFRESH_STATUS" => true,
+ "MYSQLI_REFRESH_THREADS" => true,
+ "MYSQLI_REFRESH_SLAVE" => true,
+ "MYSQLI_REFRESH_MASTER" => true,
+ "MYSQLI_DEBUG_TRACE_ENABLED" => true,
+ "MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT" => true,
+ "MYSQLI_TRANS_START_READ_WRITE" => true,
+ "MYSQLI_TRANS_START_READ_ONLY" => true,
+ "MYSQLI_TRANS_COR_AND_CHAIN" => true,
+ "MYSQLI_TRANS_COR_AND_NO_CHAIN" => true,
+ "MYSQLI_TRANS_COR_RELEASE" => true,
+ "MYSQLI_TRANS_COR_NO_RELEASE" => true,
+ );
+
+ /* depends on the build - experimental */
+ if ($IS_MYSQLND && defined('MYSQLI_OPT_INT_AND_FLOAT_NATIVE')) {
+ $expected_constants['MYSQLI_OPT_INT_AND_FLOAT_NATIVE'] = true;
+ }
+
+ if ($IS_MYSQLND && defined('MYSQLI_STORE_RESULT_COPY_DATA')) {
+ $expected_constants['MYSQLI_STORE_RESULT_COPY_DATA'] = true;
+ }
+
+ if ($IS_MYSQLND || defined('MYSQLI_REFRESH_BACKUP_LOG')) {
+ $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;
+
+ $expected_constants['MYSQLI_SERVER_PS_OUT_PARAMS'] = true;
+ } else {
+ $version = mysqli_get_client_version();
+ }
+
+ if (($version > 51122 && $version < 60000) || ($version > 60003) || $IS_MYSQLND) {
+ $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;
+ }
+
+ if ($version >= 50033 || $IS_MYSQLND) {
+ $expected_constants['MYSQLI_CLIENT_SSL_VERIFY_SERVER_CERT'] = true;
+ }
+ if ($IS_MYSQLND) {
+ $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;
+ }
+
+ if ($version > 50002) {
+ $expected_constants = array_merge($expected_constants, array(
+ "MYSQLI_TYPE_NEWDECIMAL" => true,
+ "MYSQLI_TYPE_BIT" => true,
+ ));
+ }
+
+ if ($version > 50002 || $IS_MYSQLND) {
+ $expected_constants['MYSQLI_NO_DEFAULT_VALUE_FLAG'] = true;
+ }
+
+ if ($version > 50003) {
+ $expected_constants = array_merge($expected_constants, array(
+ "MYSQLI_STMT_ATTR_CURSOR_TYPE" => true,
+ "MYSQLI_CURSOR_TYPE_NO_CURSOR" => true,
+ "MYSQLI_CURSOR_TYPE_READ_ONLY" => true,
+ "MYSQLI_CURSOR_TYPE_FOR_UPDATE" => true,
+ "MYSQLI_CURSOR_TYPE_SCROLLABLE" => true,
+ ));
+ }
+
+ if ($version > 50007) {
+ $expected_constants = array_merge($expected_constants, array(
+ "MYSQLI_STMT_ATTR_PREFETCH_ROWS" => true,
+ ));
+ }
+
+ if ($version > 50110 || $IS_MYSQLND) {
+ $expected_constants['MYSQLI_OPT_SSL_VERIFY_SERVER_CERT'] = true;
+ }
+
+ /* pretty dump test, but that is the best way to mimic mysql.c */
+ if (defined('MYSQLI_DATA_TRUNCATED'))
+ $expected_constants["MYSQLI_DATA_TRUNCATED"] = true;
+
+ if (defined('MYSQLI_SERVER_PS_OUT_PARAMS'))
+ $expected_constants["MYSQLI_SERVER_PS_OUT_PARAMS"] = true;
+
+ if (!$IS_MYSQLND) {
+ /* libmysql only */
+
+ /* are they available in all versions of ext/mysqli ?
+ ... no we must have removed them at some point - for BC, weakening the test
+ */
+ if (defined("MYSQLI_RPL_MASTER")) {
+ $expected_constants["MYSQLI_RPL_MASTER"] = true;
+ $expected_constants["MYSQLI_RPL_SLAVE"] = true;
+ $expected_constants["MYSQLI_RPL_ADMIN"] = 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;
+ }
+
+ if ($IS_MYSQLND) {
+ $expected_constants["MYSQLI_TYPE_JSON"] = true;
+ }
+
+ $unexpected_constants = array();
+
+ foreach ($constants as $group => $consts) {
+ foreach ($consts as $name => $value) {
+ if (stristr($name, 'mysqli')) {
+ $name = strtoupper($name);
+ if (isset($expected_constants[$name])) {
+ unset($expected_constants[$name]);
+ } else {
+ $unexpected_constants[$name] = $name;
+ }
+ }
+ }
+ }
+
+ if (!empty($unexpected_constants)) {
+ printf("Dumping list of unexpected constants\n");
+ var_dump($unexpected_constants);
+ }
+
+ if (!empty($expected_constants)) {
+ printf("Dumping list of missing constants\n");
+ var_dump($expected_constants);
+ }
+
+ print "done!";
?>
--EXPECT--
done!
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_data_seek(): Function cannot be used with MYSQL_USE_RESULT in %s on line %d
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_result::data_seek(): Function cannot be used with MYSQL_USE_RESULT in %s on line %d
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_debug'))
- die("skip: mysqli_debug() not available");
+ die("skip: mysqli_debug() not available");
if (!defined('MYSQLI_DEBUG_TRACE_ENABLED'))
- die("skip: can't say for sure if mysqli_debug works");
+ die("skip: can't say for sure if mysqli_debug works");
if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
- die("skip: debug functionality not enabled");
+ die("skip: debug functionality not enabled");
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
done%s
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_debug'))
- die("skip: mysqli_debug() not available");
+ die("skip: mysqli_debug() not available");
if (!defined('MYSQLI_DEBUG_TRACE_ENABLED'))
- die("skip: can't say for sure if mysqli_debug works");
+ die("skip: can't say for sure if mysqli_debug works");
if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
- die("skip: debug functionality not enabled");
+ die("skip: debug functionality not enabled");
if (!$IS_MYSQLND)
- die("SKIP Libmysql feature not sufficiently spec'd in MySQL C API documentation");
+ 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");
?>
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
done%s
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_debug'))
- die("skip: mysqli_debug() not available");
+ die("skip: mysqli_debug() not available");
if (!defined('MYSQLI_DEBUG_TRACE_ENABLED'))
- die("skip: can't say for sure if mysqli_debug works");
+ die("skip: can't say for sure if mysqli_debug works");
if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
- die("skip: debug functionality not enabled");
+ die("skip: debug functionality not enabled");
if (!$IS_MYSQLND)
- die("SKIP Libmysql feature not sufficiently spec'd in MySQL C API documentation");
+ die("SKIP Libmysql feature not sufficiently spec'd in MySQL C API documentation");
?>
--FILE--
<?php
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_debug'))
- die("skip mysqli_debug() not available");
+ die("skip mysqli_debug() not available");
if (!defined('MYSQLI_DEBUG_TRACE_ENABLED'))
- die("skip: can't say for sure if mysqli_debug works");
+ die("skip: can't say for sure if mysqli_debug works");
if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
- die("skip: debug functionality not enabled");
+ die("skip: debug functionality not enabled");
require_once('connect.inc');
if (!$IS_MYSQLND)
- die("skip needs 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");
+ die("skip PHP cannot create a file in /tmp/mysqli_debug_phpt");
else
- fclose($fp);
+ fclose($fp);
@unlink("/tmp/mysqli_debug_phpt.trace");
?>
--INI--
mysqlnd.debug="t:O,/tmp/mysqli_debug_phpt.trace"
--FILE--
<?php
- require_once('connect.inc');
- require_once('table.inc');
+ require_once('connect.inc');
+ require_once('table.inc');
- var_dump(ini_get('mysqlnd.debug'));
+ var_dump(ini_get('mysqlnd.debug'));
- $trace_file = '/tmp/mysqli_debug_phpt.trace';
- clearstatcache();
- 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));
+ $trace_file = '/tmp/mysqli_debug_phpt.trace';
+ clearstatcache();
+ 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));
- mysqli_close($link);
- unlink($trace_file);
+ mysqli_close($link);
+ unlink($trace_file);
- print "done!";
+ print "done!";
?>
--EXPECT--
string(32) "t:O,/tmp/mysqli_debug_phpt.trace"
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_debug'))
- die("skip: mysqli_debug() not available");
+ die("skip: mysqli_debug() not available");
if (!defined('MYSQLI_DEBUG_TRACE_ENABLED'))
- die("skip: can't say for sure if mysqli_debug works");
+ die("skip: can't say for sure if mysqli_debug works");
if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
- die("skip: debug functionality not enabled");
+ die("skip: debug functionality not enabled");
if (!$IS_MYSQLND)
- die("SKIP Libmysql feature not sufficiently spec'd in MySQL C API documentation");
+ die("SKIP Libmysql feature not sufficiently spec'd in MySQL C API documentation");
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
[083][control string 'n:O,%smysqli_debug_phpt.trace'] Trace file has not been written.
require_once('connect.inc');
if (!function_exists('mysqli_debug'))
- die("skip mysqli_debug() not available");
+ die("skip mysqli_debug() not available");
if (!defined('MYSQLI_DEBUG_TRACE_ENABLED'))
- die("skip: can't say for sure if mysqli_debug works");
+ die("skip: can't say for sure if mysqli_debug works");
if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
- die("skip: debug functionality not enabled");
+ die("skip: debug functionality not enabled");
if (!$IS_MYSQLND)
- die("skip mysqlnd only test");
+ die("skip mysqlnd only test");
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_disable_reads_from_master')) {
- die("skip mysqli_disable_reads_from_master() not available");
+ die("skip mysqli_disable_reads_from_master() not available");
}
?>
--FILE--
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_disable_reads_from_master(): Couldn't fetch mysqli in %s on line %d
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_enable_reads_from_master')) {
- die("skip function mysqli_enable_reads_from_master() not available\n");
+ die("skip function mysqli_enable_reads_from_master() not available\n");
}
?>
--FILE--
require_once('connect.inc');
if (!$link = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- die(sprintf("SKIP Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket));
+ die(sprintf("SKIP Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket));
}
if ($link->server_version < 50610)
- die(sprintf("SKIP Needs MySQL 5.6.10 or newer, found MySQL %s\n", $link->server_info));
+ die(sprintf("SKIP Needs MySQL 5.6.10 or newer, found MySQL %s\n", $link->server_info));
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()));
+ 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');
if (!mysqli_query($link, 'CREATE USER expiretest@"%"') ||
- !mysqli_query($link, 'CREATE USER expiretest@"localhost"')) {
- printf("skip Cannot create second DB user [%d] %s", mysqli_errno($link), mysqli_error($link));
- mysqli_close($link);
- die("skip CREATE USER failed");
+ !mysqli_query($link, 'CREATE USER expiretest@"localhost"')) {
+ printf("skip Cannot create second DB user [%d] %s", mysqli_errno($link), mysqli_error($link));
+ mysqli_close($link);
+ die("skip CREATE USER failed");
}
if (!mysqli_query($link, 'ALTER USER expiretest@"%" PASSWORD EXPIRE') ||
- !mysqli_query($link, 'ALTER USER expiretest@"localhost" PASSWORD EXPIRE')) {
- printf("skip Cannot modify second DB user [%d] %s", mysqli_errno($link), mysqli_error($link));
- mysqli_close($link);
- die("skip ALTER USER failed");
+ !mysqli_query($link, 'ALTER USER expiretest@"localhost" PASSWORD EXPIRE')) {
+ printf("skip Cannot modify second DB user [%d] %s", mysqli_errno($link), mysqli_error($link));
+ mysqli_close($link);
+ die("skip ALTER USER failed");
}
if (!$link->query("DROP TABLE IF EXISTS test") ||
- !$link->query("CREATE TABLE test (id INT)") || !$link->query("INSERT INTO test(id) VALUES (1)"))
- die(sprintf("SKIP [%d] %s\n", $link->errno, $link->error));
+ !$link->query("CREATE TABLE test (id INT)") || !$link->query("INSERT INTO test(id) VALUES (1)"))
+ die(sprintf("SKIP [%d] %s\n", $link->errno, $link->error));
if (!mysqli_query($link, sprintf("GRANT SELECT ON TABLE %s.test TO expiretest@'%%'", $db)) ||
- !mysqli_query($link, sprintf("GRANT SELECT ON TABLE %s.test TO expiretest@'localhost'", $db))) {
- printf("skip Cannot grant SELECT to user [%d] %s", mysqli_errno($link), mysqli_error($link));
- mysqli_close($link);
- die("skip GRANT failed");
+ !mysqli_query($link, sprintf("GRANT SELECT ON TABLE %s.test TO expiretest@'localhost'", $db))) {
+ printf("skip Cannot grant SELECT to user [%d] %s", mysqli_errno($link), mysqli_error($link));
+ mysqli_close($link);
+ die("skip GRANT failed");
}
?>
--FILE--
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
- mysqli_query($link, 'DROP USER expiretest');
- mysqli_query($link, 'DROP USER expiretest@localhost');
+ require_once("clean_table.inc");
+ mysqli_query($link, 'DROP USER expiretest');
+ mysqli_query($link, 'DROP USER expiretest@localhost');
?>
--EXPECTF--
Warning: mysqli%sconnect(): (HY000/1862): %s in %s on line %d
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_fetch_all'))
- die("skip: function only available with mysqlnd");
+ die("skip: function only available with mysqlnd");
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- // require_once("clean_table.inc");
+ // require_once("clean_table.inc");
?>
--EXPECTF--
[005]
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_fetch_all'))
- die("skip: function only available with mysqlnd");
+ die("skip: function only available with mysqlnd");
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
[005]
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
[002]
memory_limit=-1
--FILE--
<?php
- require_once("connect.inc");
-
- function mysqli_fetch_array_large($offset, $link, $package_size) {
-
- /* we are aiming for maximum compression to test MYSQLI_CLIENT_COMPRESS */
- $random_char = str_repeat('a', 255);
- $sql = "INSERT INTO test(label) VALUES ";
-
- while (strlen($sql) < ($package_size - 259))
- $sql .= sprintf("('%s'), ", $random_char);
-
- $sql = substr($sql, 0, -2);
- $len = strlen($sql);
- assert($len < $package_size);
-
- if (!@mysqli_query($link, $sql)) {
- if (1153 == mysqli_errno($link) || 2006 == mysqli_errno($link) || stristr(mysqli_error($link), 'max_allowed_packet'))
- /*
- myslqnd - [1153] Got a packet bigger than 'max_allowed_packet' bytes
- libmysql -[2006] MySQL server has gone away
- */
- return false;
-
- printf("[%03d + 1] len = %d, [%d] %s\n", $offset, $len, mysqli_errno($link), mysqli_error($link));
- return false;
- }
-
- /* buffered result set - let's hope we do not run into PHP memory limit... */
- if (!$res = mysqli_query($link, "SELECT id, label FROM test")) {
- printf("[%03d + 2] len = %d, [%d] %s\n", $offset, $len, mysqli_errno($link), mysqli_error($link));
- return false;
- }
-
- while ($row = mysqli_fetch_assoc($res)) {
- if ($row['label'] != $random_char) {
- printf("[%03d + 3] Wrong results - expecting '%s' got '%s', len = %d, [%d] %s\n",
- $offset, $random_char, $row['label'], $len, mysqli_errno($link), mysqli_error($link));
- return false;
- }
- }
- mysqli_free_result($res);
-
- if (!$stmt = mysqli_prepare($link, "SELECT id, label FROM test")) {
- printf("[%03d + 4] len = %d, [%d] %s\n", $offset, $len, mysqli_errno($link), mysqli_error($link));
- return false;
- }
-
- /* unbuffered result set */
- if (!mysqli_stmt_execute($stmt)) {
- printf("[%03d + 5] len = %d, [%d] %s, [%d] %s\n", $offset, $len, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), mysqli_errno($link), mysqli_error($link));
- return false;
- }
-
- $id = $label = NULL;
- if (!mysqli_stmt_bind_result($stmt, $id, $label)) {
- printf("[%03d + 6] len = %d, [%d] %s, [%d] %s\n", $offset, $len, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), mysqli_errno($link), mysqli_error($link));
- return false;
- }
-
- while (mysqli_stmt_fetch($stmt)) {
- if ($label != $random_char) {
- printf("[%03d + 7] Wrong results - expecting '%s' got '%s', len = %d, [%d] %s\n",
- $offset, $random_char, $label, $len, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- return false;
- }
- }
-
- mysqli_stmt_free_result($stmt);
- mysqli_stmt_close($stmt);
-
- return true;
- }
-
- function parse_memory_limit($limit) {
-
- $val = trim($limit);
- $last = strtolower($val[strlen($val)-1]);
-
- switch($last) {
- // The 'G' modifier is available since PHP 5.1.0
- case 'g':
- $val *= 1024;
- case 'm':
- $val *= 1024;
- case 'k':
- $val *= 1024;
- default:
- break;
- }
- return $val;
- }
-
-
- function test_fetch($host, $user, $passwd, $db, $port, $socket, $engine, $flags = null) {
-
- $link = mysqli_init();
- if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags)) {
- 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);
- return false;
- }
-
- if (!mysqli_query($link, "DROP TABLE IF EXISTS test") ||
- !mysqli_query($link, sprintf("CREATE TABLE test(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, label VARCHAR(255)) ENGINE = %s", $engine))) {
- printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- return false;
- }
-
- $package_size = 524288;
- $offset = 3;
- $limit = (ini_get('memory_limit') > 0) ? parse_memory_limit(ini_get('memory_limit')) : pow(2, 32);
-
- /* try to respect php.ini but make run time a soft limit */
- $max_runtime = (ini_get('max_execution_time') > 0) ? ini_get('max_execution_time') : 30;
- set_time_limit(0);
-
- do {
- if ($package_size > $limit) {
- printf("stop: memory limit - %s vs. %s\n", $package_size, $limit);
- break;
- }
-
- $start = microtime(true);
- if (!mysqli_fetch_array_large($offset++, $link, $package_size)) {
- printf("stop: packet size - %d\n", $package_size);
- break;
- }
-
- $duration = microtime(true) - $start;
- $max_runtime -= $duration;
- if ($max_runtime < ($duration * 3)) {
- /* likely the next iteration will not be within max_execution_time */
- printf("stop: time limit - %2.2fs\n", $max_runtime);
- break;
- }
-
- $package_size += $package_size;
-
- } while (true);
-
-
- mysqli_close($link);
- return true;
- }
-
-
- test_fetch($host, $user, $passwd, $db, $port, $socket, $engine, null);
- test_fetch($host, $user, $passwd, $db, $port, $socket, $engine, MYSQLI_CLIENT_COMPRESS);
- print "done!";
+ require_once("connect.inc");
+
+ function mysqli_fetch_array_large($offset, $link, $package_size) {
+
+ /* we are aiming for maximum compression to test MYSQLI_CLIENT_COMPRESS */
+ $random_char = str_repeat('a', 255);
+ $sql = "INSERT INTO test(label) VALUES ";
+
+ while (strlen($sql) < ($package_size - 259))
+ $sql .= sprintf("('%s'), ", $random_char);
+
+ $sql = substr($sql, 0, -2);
+ $len = strlen($sql);
+ assert($len < $package_size);
+
+ if (!@mysqli_query($link, $sql)) {
+ if (1153 == mysqli_errno($link) || 2006 == mysqli_errno($link) || stristr(mysqli_error($link), 'max_allowed_packet'))
+ /*
+ myslqnd - [1153] Got a packet bigger than 'max_allowed_packet' bytes
+ libmysql -[2006] MySQL server has gone away
+ */
+ return false;
+
+ printf("[%03d + 1] len = %d, [%d] %s\n", $offset, $len, mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+
+ /* buffered result set - let's hope we do not run into PHP memory limit... */
+ if (!$res = mysqli_query($link, "SELECT id, label FROM test")) {
+ printf("[%03d + 2] len = %d, [%d] %s\n", $offset, $len, mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+
+ while ($row = mysqli_fetch_assoc($res)) {
+ if ($row['label'] != $random_char) {
+ printf("[%03d + 3] Wrong results - expecting '%s' got '%s', len = %d, [%d] %s\n",
+ $offset, $random_char, $row['label'], $len, mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+ }
+ mysqli_free_result($res);
+
+ if (!$stmt = mysqli_prepare($link, "SELECT id, label FROM test")) {
+ printf("[%03d + 4] len = %d, [%d] %s\n", $offset, $len, mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+
+ /* unbuffered result set */
+ if (!mysqli_stmt_execute($stmt)) {
+ printf("[%03d + 5] len = %d, [%d] %s, [%d] %s\n", $offset, $len, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+
+ $id = $label = NULL;
+ if (!mysqli_stmt_bind_result($stmt, $id, $label)) {
+ printf("[%03d + 6] len = %d, [%d] %s, [%d] %s\n", $offset, $len, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+
+ while (mysqli_stmt_fetch($stmt)) {
+ if ($label != $random_char) {
+ printf("[%03d + 7] Wrong results - expecting '%s' got '%s', len = %d, [%d] %s\n",
+ $offset, $random_char, $label, $len, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ return false;
+ }
+ }
+
+ mysqli_stmt_free_result($stmt);
+ mysqli_stmt_close($stmt);
+
+ return true;
+ }
+
+ function parse_memory_limit($limit) {
+
+ $val = trim($limit);
+ $last = strtolower($val[strlen($val)-1]);
+
+ switch($last) {
+ // The 'G' modifier is available since PHP 5.1.0
+ case 'g':
+ $val *= 1024;
+ case 'm':
+ $val *= 1024;
+ case 'k':
+ $val *= 1024;
+ default:
+ break;
+ }
+ return $val;
+ }
+
+
+ function test_fetch($host, $user, $passwd, $db, $port, $socket, $engine, $flags = null) {
+
+ $link = mysqli_init();
+ if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags)) {
+ 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);
+ return false;
+ }
+
+ if (!mysqli_query($link, "DROP TABLE IF EXISTS test") ||
+ !mysqli_query($link, sprintf("CREATE TABLE test(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, label VARCHAR(255)) ENGINE = %s", $engine))) {
+ printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+
+ $package_size = 524288;
+ $offset = 3;
+ $limit = (ini_get('memory_limit') > 0) ? parse_memory_limit(ini_get('memory_limit')) : pow(2, 32);
+
+ /* try to respect php.ini but make run time a soft limit */
+ $max_runtime = (ini_get('max_execution_time') > 0) ? ini_get('max_execution_time') : 30;
+ set_time_limit(0);
+
+ do {
+ if ($package_size > $limit) {
+ printf("stop: memory limit - %s vs. %s\n", $package_size, $limit);
+ break;
+ }
+
+ $start = microtime(true);
+ if (!mysqli_fetch_array_large($offset++, $link, $package_size)) {
+ printf("stop: packet size - %d\n", $package_size);
+ break;
+ }
+
+ $duration = microtime(true) - $start;
+ $max_runtime -= $duration;
+ if ($max_runtime < ($duration * 3)) {
+ /* likely the next iteration will not be within max_execution_time */
+ printf("stop: time limit - %2.2fs\n", $max_runtime);
+ break;
+ }
+
+ $package_size += $package_size;
+
+ } while (true);
+
+
+ mysqli_close($link);
+ return true;
+ }
+
+
+ test_fetch($host, $user, $passwd, $db, $port, $socket, $engine, null);
+ test_fetch($host, $user, $passwd, $db, $port, $socket, $engine, MYSQLI_CLIENT_COMPRESS);
+ print "done!";
?>
--CLEAN--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
[005]
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
[005]
mysqli_fetch_assoc() - BIT
--SKIPIF--
<?php
- require_once('skipif.inc');
- require_once('skipifemb.inc');
- require_once('skipifconnectfailure.inc');
+ require_once('skipif.inc');
+ require_once('skipifemb.inc');
+ require_once('skipifconnectfailure.inc');
- require_once('connect.inc');
- require_once('table.inc');
- if (mysqli_get_server_version($link) < 50003)
- // b'001' syntax not supported before 5.0.3
- die("skip Syntax used for test not supported with MySQL Server before 5.0.3");
- if (!$IS_MYSQLND && (mysqli_get_client_version() < 50003))
- // better don't trust libmysql before 5.0.3
- die("skip Syntax used for test not supported with MySQL Server before 5.0.3");
+ require_once('connect.inc');
+ require_once('table.inc');
+ if (mysqli_get_server_version($link) < 50003)
+ // b'001' syntax not supported before 5.0.3
+ die("skip Syntax used for test not supported with MySQL Server before 5.0.3");
+ if (!$IS_MYSQLND && (mysqli_get_client_version() < 50003))
+ // better don't trust libmysql before 5.0.3
+ die("skip Syntax used for test not supported with MySQL Server before 5.0.3");
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
mysqli_fetch_assoc() - utf8
--SKIPIF--
<?php
- require_once('skipif.inc');
- require_once('skipifemb.inc');
- require_once('skipifconnectfailure.inc');
- require_once("connect.inc");
+ require_once('skipif.inc');
+ require_once('skipifemb.inc');
+ require_once('skipifconnectfailure.inc');
+ require_once("connect.inc");
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die("skip Cannot connect to server to check charsets");
+ if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ die("skip Cannot connect to server to check charsets");
- if (!$res = mysqli_query($link, "SHOW CHARACTER SET LIKE 'UTF8'"))
- die("skip Cannot run SHOW CHARACTER SET to check charsets");
+ if (!$res = mysqli_query($link, "SHOW CHARACTER SET LIKE 'UTF8'"))
+ die("skip Cannot run SHOW CHARACTER SET to check charsets");
- if (!$tmp = mysqli_fetch_assoc($res))
- die("skip Looks like UTF8 is not available on the server");
+ if (!$tmp = mysqli_fetch_assoc($res))
+ die("skip Looks like UTF8 is not available on the server");
- if (strtolower($tmp['Charset']) !== 'utf8')
- die("skip Not sure if UTF8 is available, canceling the test");
+ if (strtolower($tmp['Charset']) !== 'utf8')
+ die("skip Not sure if UTF8 is available, canceling the test");
- mysqli_free_result($res);
+ mysqli_free_result($res);
- if (!$res = mysqli_query($link, "SHOW CHARACTER SET LIKE 'UCS2'"))
- die("skip Cannot run SHOW CHARACTER SET to check charsets");
+ if (!$res = mysqli_query($link, "SHOW CHARACTER SET LIKE 'UCS2'"))
+ die("skip Cannot run SHOW CHARACTER SET to check charsets");
- if (!$tmp = mysqli_fetch_assoc($res))
- die("skip Looks like UCS2 is not available on the server");
+ if (!$tmp = mysqli_fetch_assoc($res))
+ die("skip Looks like UCS2 is not available on the server");
- if (strtolower($tmp['Charset']) !== 'ucs2')
- die("skip Not sure if UCS2 is available, canceling the test");
+ if (strtolower($tmp['Charset']) !== 'ucs2')
+ die("skip Not sure if UCS2 is available, canceling the test");
- mysqli_free_result($res);
- mysqli_close($link);
+ mysqli_free_result($res);
+ mysqli_close($link);
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
[005]
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
object(stdClass)#%d (13) {
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_fetch_field_direct(): Field offset is invalid for resultset in %s on line %d
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_result::fetch_field_direct(): Field offset is invalid for resultset in %s on line %d
require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die(printf("skip: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()));
+ die(printf("skip: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()));
if (mysqli_get_server_version($link) < 50041)
- die("skip: Due to many MySQL Server differences, the test requires 5.0.41+");
+ die("skip: Due to many MySQL Server differences, the test requires 5.0.41+");
mysqli_close($link);
?>
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
object(stdClass)#%d (13) {
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
object(stdClass)#%d (13) {
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
bool(false)
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
NULL
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
[E_WARNING] mysqli_fetch_object() expects at least 1 parameter, 0 given in %s on line %d
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
No exception with PHP:
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
%s(6) "object"
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
[E_WARNING] mysqli_result::__construct(): invalid object or resource mysql%s
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
[004]
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
int(0)
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_field_seek(): Invalid field offset in %s on line %d
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
int(0)
require_once('skipifconnectfailure.inc');
if (!function_exists('pcntl_fork'))
- die("skip Process Control Functions not available");
+ die("skip Process Control Functions not available");
if (!function_exists('posix_getpid'))
- die("skip POSIX functions not available");
+ die("skip POSIX functions not available");
require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
if (!have_innodb($link))
- die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
+ die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
?>
--FILE--
<?php
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "DROP TABLE IF EXISTS messages"))
- printf("[c003] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c003] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
a
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_get_charset'))
- die("skip: function not available");
+ die("skip: function not available");
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_get_charset(): Couldn't fetch mysqli in %s on line %d
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_get_client_stats')) {
- die("skip only available with mysqlnd");
+ die("skip only available with mysqlnd");
}
?>
--INI--
mysqli.allow_local_infile=1
--FILE--
<?php
- /*
- TODO
- no_index_used - difficult to simulate because server/engine dependent
- bad_index_used - difficult to simulate because server/engine dependent
- flushed_normal_sets
- flushed_ps_sets
- explicit_close
- implicit_close
- disconnect_close
- in_middle_of_command_close
- explicit_free_result
- implicit_free_result
- explicit_stmt_close
- implicit_stmt_close
- */
-
- function mysqli_get_client_stats_assert_eq($field, $current, $expected, &$test_counter, $desc = "") {
-
- $test_counter++;
- if (is_array($current) && is_array($expected)) {
- if ($current[$field] !== $expected[$field]) {
- printf("[%03d] %s Expecting %s = %s/%s, got %s/%s\n",
- $test_counter, $desc,
- $field, $expected[$field], gettype($expected[$field]),
- $current[$field], gettype($current[$field]));
- }
- } else if (is_array($current)) {
- if ($current[$field] !== $expected) {
- printf("[%03d] %s Expecting %s = %s/%s, got %s/%s\n",
- $test_counter, $desc,
- $field, $expected, gettype($expected),
- $current[$field], gettype($current[$field]));
- }
- } else {
- if ($current !== $expected) {
- printf("[%03d] %s Expecting %s = %s/%s, got %s/%s\n",
- $test_counter, $desc,
- $field, $expected, gettype($expected),
- $current, gettype($current));
- }
- }
-
- }
-
- function mysqli_get_client_stats_assert_gt($field, $current, $expected, &$test_counter, $desc = "") {
-
- $test_counter++;
- if (is_array($current) && is_array($expected)) {
- if ($current[$field] <= $expected[$field]) {
- printf("[%03d] %s Expecting %s > %s/%s, got %s/%s\n",
- $test_counter, $desc,
- $field, $expected[$field], gettype($expected[$field]),
- $current[$field], gettype($current[$field]));
- }
- } else {
- if ($current <= $expected) {
- printf("[%03d] %s Expecting %s > %s/%s, got %s/%s\n",
- $test_counter, $desc, $field,
- $expected, gettype($expected),
- $current, gettype($current));
- }
- }
-
- }
-
-
- $tmp = $link = null;
- if (!is_null($tmp = @mysqli_get_client_stats($link)))
- printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
-
- require_once("connect.inc");
-
- if (!is_array($info = mysqli_get_client_stats()) || empty($info))
- printf("[002] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info);
-
- var_dump($info);
-
- if (!$link = 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);
- }
-
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- printf("[004] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info);
-
- if (count($info) != count($new_info)) {
- printf("[005] Expecting the same number of entries in the arrays\n");
- var_dump($info);
- var_dump($new_info);
- }
-
- $test_counter = 6;
-
- mysqli_get_client_stats_assert_gt('bytes_sent', $new_info, $info, $test_counter);
- mysqli_get_client_stats_assert_gt('bytes_received', $new_info, $info, $test_counter);
- mysqli_get_client_stats_assert_gt('packets_sent', $new_info, $info, $test_counter);
- mysqli_get_client_stats_assert_gt('packets_received', $new_info, $info, $test_counter);
- mysqli_get_client_stats_assert_gt('protocol_overhead_in', $new_info, $info, $test_counter);
- mysqli_get_client_stats_assert_gt('protocol_overhead_out', $new_info, $info, $test_counter);
-
- // we assume the above as tested and in the following we check only those
- mysqli_get_client_stats_assert_eq('result_set_queries', $new_info, $info, $test_counter);
-
- /* we need to skip this test in unicode - we send set names utf8 during mysql_connect */
- mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, $info, $test_counter);
- mysqli_get_client_stats_assert_eq('buffered_sets', $new_info, $info, $test_counter);
- mysqli_get_client_stats_assert_eq('unbuffered_sets', $new_info, $info, $test_counter);
- mysqli_get_client_stats_assert_eq('ps_buffered_sets', $new_info, $info, $test_counter);
- mysqli_get_client_stats_assert_eq('ps_unbuffered_sets', $new_info, $info, $test_counter);
-
- mysqli_get_client_stats_assert_eq('rows_skipped_ps', $new_info, $info, $test_counter);
- mysqli_get_client_stats_assert_eq('copy_on_write_saved', $new_info, $info, $test_counter);
- mysqli_get_client_stats_assert_eq('copy_on_write_performed', $new_info, $info, $test_counter);
- mysqli_get_client_stats_assert_eq('command_buffer_too_small', $new_info, $info, $test_counter);
- // This is not a mistake that I use string(1) "1" here! Andrey did not go for int to avoid any
- // issues for very large numbers and 32 vs. 64bit systems
- mysqli_get_client_stats_assert_eq('connect_success', $new_info, "1", $test_counter);
- mysqli_get_client_stats_assert_eq('connect_failure', $new_info, $info, $test_counter);
- mysqli_get_client_stats_assert_eq('connection_reused', $new_info, $info, $test_counter);
-
- // No data fetched so far
- mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $new_info, "0", $test_counter);
- mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $new_info, "0", $test_counter);
-
- require('table.inc');
- if (!is_array($info = mysqli_get_client_stats()) || empty($info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($info), $info);
-
- // fetch stats
- $expected = $info;
-
- // buffered normal
- print "Testing buffered normal...\n";
- if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS _num FROM test', MYSQLI_STORE_RESULT))
- printf("[%03d] SELECT COUNT() FROM test failed, [%d] %s\n",
- ++$test_counter, mysqli_errno($link), mysqli_error($link));
-
- $expected['rows_fetched_from_server_normal'] = (string)($expected['rows_fetched_from_server_normal'] + 1);
- $expected['buffered_sets'] = (string)($expected['buffered_sets'] + 1);
- $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
- $expected['rows_buffered_from_client_normal'] = (string)($expected['rows_buffered_from_client_normal'] + 1);
-
- if (!is_array($info = mysqli_get_client_stats()) || empty($info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($info), $info);
-
- mysqli_get_client_stats_assert_gt('bytes_sent', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_gt('bytes_received', $info, $expected, $test_counter);
-
- // real_data_* get incremented after mysqli_*fetch*()
+ /*
+ TODO
+ no_index_used - difficult to simulate because server/engine dependent
+ bad_index_used - difficult to simulate because server/engine dependent
+ flushed_normal_sets
+ flushed_ps_sets
+ explicit_close
+ implicit_close
+ disconnect_close
+ in_middle_of_command_close
+ explicit_free_result
+ implicit_free_result
+ explicit_stmt_close
+ implicit_stmt_close
+ */
+
+ function mysqli_get_client_stats_assert_eq($field, $current, $expected, &$test_counter, $desc = "") {
+
+ $test_counter++;
+ if (is_array($current) && is_array($expected)) {
+ if ($current[$field] !== $expected[$field]) {
+ printf("[%03d] %s Expecting %s = %s/%s, got %s/%s\n",
+ $test_counter, $desc,
+ $field, $expected[$field], gettype($expected[$field]),
+ $current[$field], gettype($current[$field]));
+ }
+ } else if (is_array($current)) {
+ if ($current[$field] !== $expected) {
+ printf("[%03d] %s Expecting %s = %s/%s, got %s/%s\n",
+ $test_counter, $desc,
+ $field, $expected, gettype($expected),
+ $current[$field], gettype($current[$field]));
+ }
+ } else {
+ if ($current !== $expected) {
+ printf("[%03d] %s Expecting %s = %s/%s, got %s/%s\n",
+ $test_counter, $desc,
+ $field, $expected, gettype($expected),
+ $current, gettype($current));
+ }
+ }
+
+ }
+
+ function mysqli_get_client_stats_assert_gt($field, $current, $expected, &$test_counter, $desc = "") {
+
+ $test_counter++;
+ if (is_array($current) && is_array($expected)) {
+ if ($current[$field] <= $expected[$field]) {
+ printf("[%03d] %s Expecting %s > %s/%s, got %s/%s\n",
+ $test_counter, $desc,
+ $field, $expected[$field], gettype($expected[$field]),
+ $current[$field], gettype($current[$field]));
+ }
+ } else {
+ if ($current <= $expected) {
+ printf("[%03d] %s Expecting %s > %s/%s, got %s/%s\n",
+ $test_counter, $desc, $field,
+ $expected, gettype($expected),
+ $current, gettype($current));
+ }
+ }
+
+ }
+
+
+ $tmp = $link = null;
+ if (!is_null($tmp = @mysqli_get_client_stats($link)))
+ printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+ require_once("connect.inc");
+
+ if (!is_array($info = mysqli_get_client_stats()) || empty($info))
+ printf("[002] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info);
+
+ var_dump($info);
+
+ if (!$link = 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);
+ }
+
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ printf("[004] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info);
+
+ if (count($info) != count($new_info)) {
+ printf("[005] Expecting the same number of entries in the arrays\n");
+ var_dump($info);
+ var_dump($new_info);
+ }
+
+ $test_counter = 6;
+
+ mysqli_get_client_stats_assert_gt('bytes_sent', $new_info, $info, $test_counter);
+ mysqli_get_client_stats_assert_gt('bytes_received', $new_info, $info, $test_counter);
+ mysqli_get_client_stats_assert_gt('packets_sent', $new_info, $info, $test_counter);
+ mysqli_get_client_stats_assert_gt('packets_received', $new_info, $info, $test_counter);
+ mysqli_get_client_stats_assert_gt('protocol_overhead_in', $new_info, $info, $test_counter);
+ mysqli_get_client_stats_assert_gt('protocol_overhead_out', $new_info, $info, $test_counter);
+
+ // we assume the above as tested and in the following we check only those
+ mysqli_get_client_stats_assert_eq('result_set_queries', $new_info, $info, $test_counter);
+
+ /* we need to skip this test in unicode - we send set names utf8 during mysql_connect */
+ mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, $info, $test_counter);
+ mysqli_get_client_stats_assert_eq('buffered_sets', $new_info, $info, $test_counter);
+ mysqli_get_client_stats_assert_eq('unbuffered_sets', $new_info, $info, $test_counter);
+ mysqli_get_client_stats_assert_eq('ps_buffered_sets', $new_info, $info, $test_counter);
+ mysqli_get_client_stats_assert_eq('ps_unbuffered_sets', $new_info, $info, $test_counter);
+
+ mysqli_get_client_stats_assert_eq('rows_skipped_ps', $new_info, $info, $test_counter);
+ mysqli_get_client_stats_assert_eq('copy_on_write_saved', $new_info, $info, $test_counter);
+ mysqli_get_client_stats_assert_eq('copy_on_write_performed', $new_info, $info, $test_counter);
+ mysqli_get_client_stats_assert_eq('command_buffer_too_small', $new_info, $info, $test_counter);
+ // This is not a mistake that I use string(1) "1" here! Andrey did not go for int to avoid any
+ // issues for very large numbers and 32 vs. 64bit systems
+ mysqli_get_client_stats_assert_eq('connect_success', $new_info, "1", $test_counter);
+ mysqli_get_client_stats_assert_eq('connect_failure', $new_info, $info, $test_counter);
+ mysqli_get_client_stats_assert_eq('connection_reused', $new_info, $info, $test_counter);
+
+ // No data fetched so far
+ mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $new_info, "0", $test_counter);
+ mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $new_info, "0", $test_counter);
+
+ require('table.inc');
+ if (!is_array($info = mysqli_get_client_stats()) || empty($info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($info), $info);
+
+ // fetch stats
+ $expected = $info;
+
+ // buffered normal
+ print "Testing buffered normal...\n";
+ if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS _num FROM test', MYSQLI_STORE_RESULT))
+ printf("[%03d] SELECT COUNT() FROM test failed, [%d] %s\n",
+ ++$test_counter, mysqli_errno($link), mysqli_error($link));
+
+ $expected['rows_fetched_from_server_normal'] = (string)($expected['rows_fetched_from_server_normal'] + 1);
+ $expected['buffered_sets'] = (string)($expected['buffered_sets'] + 1);
+ $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
+ $expected['rows_buffered_from_client_normal'] = (string)($expected['rows_buffered_from_client_normal'] + 1);
+
+ if (!is_array($info = mysqli_get_client_stats()) || empty($info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($info), $info);
+
+ mysqli_get_client_stats_assert_gt('bytes_sent', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_gt('bytes_received', $info, $expected, $test_counter);
+
+ // real_data_* get incremented after mysqli_*fetch*()
mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, "0", $test_counter);
- mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, "0", $test_counter);
+ mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, "0", $test_counter);
- mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_buffered', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('buffered_sets', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_buffered_from_client_normal', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_buffered', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('buffered_sets', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_buffered_from_client_normal', $info, $expected, $test_counter);
- /* no change to rows_fetched_from_client_normal_buffered! */
- if (!$row = mysqli_fetch_assoc($res))
- printf("[%03d] fetch_assoc - SELECT COUNT() FROM test failed, [%d] %s\n",
- ++$test_counter, mysqli_errno($link), mysqli_error($link));
+ /* no change to rows_fetched_from_client_normal_buffered! */
+ if (!$row = mysqli_fetch_assoc($res))
+ printf("[%03d] fetch_assoc - SELECT COUNT() FROM test failed, [%d] %s\n",
+ ++$test_counter, mysqli_errno($link), mysqli_error($link));
- $expected['rows_fetched_from_client_normal_buffered'] = (string)($expected['rows_fetched_from_client_normal_buffered'] + 1);
+ $expected['rows_fetched_from_client_normal_buffered'] = (string)($expected['rows_fetched_from_client_normal_buffered'] + 1);
- if (!is_array($info = mysqli_get_client_stats()) || empty($info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($info), $info);
+ if (!is_array($info = mysqli_get_client_stats()) || empty($info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($info), $info);
- // fetch will increment
- mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter);
- $expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal'];
- mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, "0", $test_counter);
+ // fetch will increment
+ mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter);
+ $expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal'];
+ mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, "0", $test_counter);
- mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_buffered', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_buffered_from_client_normal', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_buffered', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_buffered_from_client_normal', $info, $expected, $test_counter);
- $num_rows = $row['_num'];
- mysqli_free_result($res);
+ $num_rows = $row['_num'];
+ mysqli_free_result($res);
- print "Testing buffered normal... - SELECT id, label FROM test\n";
- if (!$res = mysqli_query($link, 'SELECT id, label FROM test', MYSQLI_STORE_RESULT))
- printf("[%03d] SELECT id, label FROM test failed, [%d] %s\n",
- ++$test_counter, mysqli_errno($link), mysqli_error($link));
+ print "Testing buffered normal... - SELECT id, label FROM test\n";
+ if (!$res = mysqli_query($link, 'SELECT id, label FROM test', MYSQLI_STORE_RESULT))
+ printf("[%03d] SELECT id, label FROM test failed, [%d] %s\n",
+ ++$test_counter, mysqli_errno($link), mysqli_error($link));
- assert(mysqli_num_rows($res) == $num_rows);
+ assert(mysqli_num_rows($res) == $num_rows);
- if (!is_array($info = mysqli_get_client_stats()) || empty($info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($info), $info);
+ if (!is_array($info = mysqli_get_client_stats()) || empty($info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($info), $info);
- $expected['rows_fetched_from_server_normal'] = (string)($expected['rows_fetched_from_server_normal'] + $num_rows);
- $expected['rows_buffered_from_client_normal'] = (string)($expected['rows_buffered_from_client_normal'] + $num_rows);
- $expected['buffered_sets'] = (string)($expected['buffered_sets'] + 1);
- $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
+ $expected['rows_fetched_from_server_normal'] = (string)($expected['rows_fetched_from_server_normal'] + $num_rows);
+ $expected['rows_buffered_from_client_normal'] = (string)($expected['rows_buffered_from_client_normal'] + $num_rows);
+ $expected['buffered_sets'] = (string)($expected['buffered_sets'] + 1);
+ $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
- mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_buffered', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('buffered_sets', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_buffered_from_client_normal', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_buffered_from_client_normal', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_buffered', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('buffered_sets', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_buffered_from_client_normal', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_buffered_from_client_normal', $info, $expected, $test_counter);
- /* fetching none, but stats should not be affected - current implementation */
- mysqli_free_result($res);
+ /* fetching none, but stats should not be affected - current implementation */
+ mysqli_free_result($res);
- if (!is_array($info = mysqli_get_client_stats()) || empty($info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($info), $info);
+ if (!is_array($info = mysqli_get_client_stats()) || empty($info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($info), $info);
- mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_buffered', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_buffered', $info, $expected, $test_counter);
- print "Testing unbuffered normal...\n";
- if (!$res = mysqli_query($link, 'SELECT id, label FROM test', MYSQLI_USE_RESULT))
- printf("[%03d] SELECT id, label FROM test failed, [%d] %s\n",
- ++$test_counter, mysqli_errno($link), mysqli_error($link));
+ print "Testing unbuffered normal...\n";
+ if (!$res = mysqli_query($link, 'SELECT id, label FROM test', MYSQLI_USE_RESULT))
+ printf("[%03d] SELECT id, label FROM test failed, [%d] %s\n",
+ ++$test_counter, mysqli_errno($link), mysqli_error($link));
- if (!is_array($info = mysqli_get_client_stats()) || empty($info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($info), $info);
+ if (!is_array($info = mysqli_get_client_stats()) || empty($info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($info), $info);
- mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
- 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);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
+ 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))
- ;
- mysqli_free_result($res);
+ while ($row = mysqli_fetch_assoc($res))
+ ;
+ mysqli_free_result($res);
- $expected['rows_fetched_from_server_normal'] = (string)($expected['rows_fetched_from_server_normal'] + $num_rows);
- $expected['rows_fetched_from_client_normal_unbuffered'] = (string)($expected['rows_fetched_from_client_normal_unbuffered'] + $num_rows);
- $expected['unbuffered_sets'] = (string)($expected['unbuffered_sets'] + 1);
- $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
+ $expected['rows_fetched_from_server_normal'] = (string)($expected['rows_fetched_from_server_normal'] + $num_rows);
+ $expected['rows_fetched_from_client_normal_unbuffered'] = (string)($expected['rows_fetched_from_client_normal_unbuffered'] + $num_rows);
+ $expected['unbuffered_sets'] = (string)($expected['unbuffered_sets'] + 1);
+ $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
- if (!is_array($info = mysqli_get_client_stats()) || empty($info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($info), $info);
+ if (!is_array($info = mysqli_get_client_stats()) || empty($info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($info), $info);
- mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter);
- $expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal'];
+ mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter);
+ $expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal'];
- mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_unbuffered', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('unbuffered_sets', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_unbuffered', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('unbuffered_sets', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
- print "Testing unbuffered normal... - SELECT id, label FROM test, not all fetched\n";
- if (!$res = mysqli_query($link, 'SELECT id, label FROM test', MYSQLI_USE_RESULT))
- printf("[%03d] SELECT id, label FROM test failed, [%d] %s\n",
- ++$test_counter, mysqli_errno($link), mysqli_error($link));
+ print "Testing unbuffered normal... - SELECT id, label FROM test, not all fetched\n";
+ if (!$res = mysqli_query($link, 'SELECT id, label FROM test', MYSQLI_USE_RESULT))
+ printf("[%03d] SELECT id, label FROM test failed, [%d] %s\n",
+ ++$test_counter, mysqli_errno($link), mysqli_error($link));
- for ($i = 0; $i < $num_rows - 1; $i++)
- $row = mysqli_fetch_assoc($res);
+ for ($i = 0; $i < $num_rows - 1; $i++)
+ $row = 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);
- $expected['unbuffered_sets'] = (string)($expected['unbuffered_sets'] + 1);
- $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
+ $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);
+ $expected['unbuffered_sets'] = (string)($expected['unbuffered_sets'] + 1);
+ $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
- if (!is_array($info = mysqli_get_client_stats()) || empty($info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($info), $info);
+ if (!is_array($info = mysqli_get_client_stats()) || empty($info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($info), $info);
- mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter);
- $expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal'];
+ mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter);
+ $expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal'];
- mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_unbuffered', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('unbuffered_sets', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_unbuffered', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('unbuffered_sets', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
- print "Testing if implicit fetching and cleaning happens...\n";
- mysqli_free_result($res);
+ print "Testing if implicit fetching and cleaning happens...\n";
+ mysqli_free_result($res);
- /* last row has been implicitly cleaned from the wire by freeing the result set */
- $expected['rows_fetched_from_server_normal'] = (string)($expected['rows_fetched_from_server_normal'] + 1);
- $expected['rows_fetched_from_client_normal_unbuffered'] = (string)($expected['rows_fetched_from_client_normal_unbuffered'] + 1);
- $expected['rows_skipped_normal'] = (string)($info['rows_skipped_normal'] + 1);
- $expected['flushed_normal_sets'] = (string)($expected['flushed_normal_sets'] + 1);
+ /* last row has been implicitly cleaned from the wire by freeing the result set */
+ $expected['rows_fetched_from_server_normal'] = (string)($expected['rows_fetched_from_server_normal'] + 1);
+ $expected['rows_fetched_from_client_normal_unbuffered'] = (string)($expected['rows_fetched_from_client_normal_unbuffered'] + 1);
+ $expected['rows_skipped_normal'] = (string)($info['rows_skipped_normal'] + 1);
+ $expected['flushed_normal_sets'] = (string)($expected['flushed_normal_sets'] + 1);
- if (!is_array($info = mysqli_get_client_stats()) || empty($info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($info), $info);
+ if (!is_array($info = mysqli_get_client_stats()) || empty($info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($info), $info);
- mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_unbuffered', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_skipped_normal', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('flushed_normal_sets', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_unbuffered', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_skipped_normal', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('flushed_normal_sets', $info, $expected, $test_counter);
- print "Testing buffered Prepared Statements...\n";
- if (!$stmt = mysqli_stmt_init($link))
- printf("[%03d] stmt_init() failed, [%d] %s\n",
- ++$test_counter, mysqli_errno($link), mysqli_error($link));
+ print "Testing buffered Prepared Statements...\n";
+ if (!$stmt = mysqli_stmt_init($link))
+ printf("[%03d] stmt_init() failed, [%d] %s\n",
+ ++$test_counter, mysqli_errno($link), mysqli_error($link));
- if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') ||
- !mysqli_stmt_execute($stmt))
- printf("[%03d] prepare/execute failed, [%d] %s\n",
- ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') ||
+ !mysqli_stmt_execute($stmt))
+ printf("[%03d] prepare/execute failed, [%d] %s\n",
+ ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- /* by default PS is unbuffered - no change */
- mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_buffered', $info, $expected, $test_counter);
+ /* by default PS is unbuffered - no change */
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_buffered', $info, $expected, $test_counter);
- if (!mysqli_stmt_store_result($stmt))
- printf("[%03d] store_result failed, [%d] %s\n",
- ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- mysqli_stmt_free_result($stmt);
+ if (!mysqli_stmt_store_result($stmt))
+ printf("[%03d] store_result failed, [%d] %s\n",
+ ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ mysqli_stmt_free_result($stmt);
- mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, "0", $test_counter);
- mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, "0", $test_counter);
+ mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
- $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows);
- $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
- $expected['ps_buffered_sets'] = (string)($expected['ps_buffered_sets'] + 1);
- $expected['rows_buffered_from_client_ps'] = (string)($expected['rows_buffered_from_client_ps'] + $num_rows);
+ $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows);
+ $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
+ $expected['ps_buffered_sets'] = (string)($expected['ps_buffered_sets'] + 1);
+ $expected['rows_buffered_from_client_ps'] = (string)($expected['rows_buffered_from_client_ps'] + $num_rows);
- if (!is_array($info = mysqli_get_client_stats()) || empty($info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($info), $info);
+ if (!is_array($info = mysqli_get_client_stats()) || empty($info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($info), $info);
- mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_buffered', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('ps_buffered_sets', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_buffered', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('ps_buffered_sets', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, "0", $test_counter);
+ mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, "0", $test_counter);
- print "Testing buffered Prepared Statements... - fetching all\n";
+ print "Testing buffered Prepared Statements... - fetching all\n";
- if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') ||
- !mysqli_stmt_execute($stmt))
- printf("[%03d] prepare/execute failed, [%d] %s\n",
- ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') ||
+ !mysqli_stmt_execute($stmt))
+ printf("[%03d] prepare/execute failed, [%d] %s\n",
+ ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- $id = $label = null;
- if (!mysqli_stmt_bind_result($stmt, $id, $label))
- printf("[%03d] bind_result failed, [%d] %s\n",
- ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ $id = $label = null;
+ if (!mysqli_stmt_bind_result($stmt, $id, $label))
+ printf("[%03d] bind_result failed, [%d] %s\n",
+ ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- if (!mysqli_stmt_store_result($stmt))
- printf("[%03d] store_result failed, [%d] %s\n",
- ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ if (!mysqli_stmt_store_result($stmt))
+ printf("[%03d] store_result failed, [%d] %s\n",
+ ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- while (mysqli_stmt_fetch($stmt))
- ;
+ while (mysqli_stmt_fetch($stmt))
+ ;
- $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows);
- $expected['rows_fetched_from_client_ps_buffered'] = (string)($expected['rows_fetched_from_client_ps_buffered'] + $num_rows);
- $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
- $expected['ps_buffered_sets'] = (string)($expected['ps_buffered_sets'] + 1);
- $expected['rows_buffered_from_client_ps'] = (string)($expected['rows_buffered_from_client_ps'] + $num_rows);
+ $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows);
+ $expected['rows_fetched_from_client_ps_buffered'] = (string)($expected['rows_fetched_from_client_ps_buffered'] + $num_rows);
+ $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
+ $expected['ps_buffered_sets'] = (string)($expected['ps_buffered_sets'] + 1);
+ $expected['rows_buffered_from_client_ps'] = (string)($expected['rows_buffered_from_client_ps'] + $num_rows);
- if (!is_array($info = mysqli_get_client_stats()) || empty($info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($info), $info);
+ if (!is_array($info = mysqli_get_client_stats()) || empty($info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($info), $info);
- mysqli_get_client_stats_assert_gt('bytes_received_real_data_ps', $info, $expected, $test_counter);
- $expected['bytes_received_real_data_ps'] = $info['bytes_received_real_data_ps'];
+ mysqli_get_client_stats_assert_gt('bytes_received_real_data_ps', $info, $expected, $test_counter);
+ $expected['bytes_received_real_data_ps'] = $info['bytes_received_real_data_ps'];
- mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_buffered', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('ps_buffered_sets', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_buffered', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('ps_buffered_sets', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter);
- mysqli_stmt_free_result($stmt);
+ mysqli_stmt_free_result($stmt);
- print "Testing buffered Prepared Statements... - fetching all but one\n";
+ print "Testing buffered Prepared Statements... - fetching all but one\n";
- if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') ||
- !mysqli_stmt_execute($stmt))
- printf("[%03d] prepare/execute failed, [%d] %s\n",
- ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') ||
+ !mysqli_stmt_execute($stmt))
+ printf("[%03d] prepare/execute failed, [%d] %s\n",
+ ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- $id = $label = null;
- if (!mysqli_stmt_bind_result($stmt, $id, $label))
- printf("[%03d] bind_result failed, [%d] %s\n",
- ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ $id = $label = null;
+ if (!mysqli_stmt_bind_result($stmt, $id, $label))
+ printf("[%03d] bind_result failed, [%d] %s\n",
+ ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- if (!mysqli_stmt_store_result($stmt))
- printf("[%03d] store_result failed, [%d] %s\n",
- ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ if (!mysqli_stmt_store_result($stmt))
+ printf("[%03d] store_result failed, [%d] %s\n",
+ ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- for ($i = 0; $i < $num_rows - 1; $i++)
- mysqli_stmt_fetch($stmt);
+ for ($i = 0; $i < $num_rows - 1; $i++)
+ mysqli_stmt_fetch($stmt);
- $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows);
- $expected['rows_fetched_from_client_ps_buffered'] = (string)($expected['rows_fetched_from_client_ps_buffered'] + $num_rows - 1);
- $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
- $expected['ps_buffered_sets'] = (string)($expected['ps_buffered_sets'] + 1);
- $expected['rows_buffered_from_client_ps'] = (string)($expected['rows_buffered_from_client_ps'] + $num_rows);
+ $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows);
+ $expected['rows_fetched_from_client_ps_buffered'] = (string)($expected['rows_fetched_from_client_ps_buffered'] + $num_rows - 1);
+ $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
+ $expected['ps_buffered_sets'] = (string)($expected['ps_buffered_sets'] + 1);
+ $expected['rows_buffered_from_client_ps'] = (string)($expected['rows_buffered_from_client_ps'] + $num_rows);
- if (!is_array($info = mysqli_get_client_stats()) || empty($info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($info), $info);
+ if (!is_array($info = mysqli_get_client_stats()) || empty($info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($info), $info);
- mysqli_get_client_stats_assert_gt('bytes_received_real_data_ps', $info, $expected, $test_counter);
- $expected['bytes_received_real_data_ps'] = $info['bytes_received_real_data_ps'];
+ mysqli_get_client_stats_assert_gt('bytes_received_real_data_ps', $info, $expected, $test_counter);
+ $expected['bytes_received_real_data_ps'] = $info['bytes_received_real_data_ps'];
- mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_buffered', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('ps_buffered_sets', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_buffered', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('ps_buffered_sets', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter);
- $expected['rows_skipped_ps'] = $info['rows_skipped_ps'];
- mysqli_stmt_free_result($stmt);
+ $expected['rows_skipped_ps'] = $info['rows_skipped_ps'];
+ mysqli_stmt_free_result($stmt);
- if (!is_array($info = mysqli_get_client_stats()) || empty($info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($info), $info);
+ if (!is_array($info = mysqli_get_client_stats()) || empty($info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($info), $info);
- /* buffered result set - no skipping possible! */
- mysqli_get_client_stats_assert_eq('rows_skipped_ps', $info, $expected, $test_counter);
+ /* buffered result set - no skipping possible! */
+ mysqli_get_client_stats_assert_eq('rows_skipped_ps', $info, $expected, $test_counter);
- print "Testing unbuffered Prepared Statements... - fetching all\n";
+ print "Testing unbuffered Prepared Statements... - fetching all\n";
- if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') ||
- !mysqli_stmt_execute($stmt))
- printf("[%03d] prepare/execute failed, [%d] %s\n",
- ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') ||
+ !mysqli_stmt_execute($stmt))
+ printf("[%03d] prepare/execute failed, [%d] %s\n",
+ ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- $id = $label = null;
- if (!mysqli_stmt_bind_result($stmt, $id, $label))
- printf("[%03d] bind_result failed, [%d] %s\n",
- ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ $id = $label = null;
+ if (!mysqli_stmt_bind_result($stmt, $id, $label))
+ printf("[%03d] bind_result failed, [%d] %s\n",
+ ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- $i = 0;
- while (mysqli_stmt_fetch($stmt))
- $i++;
- assert($num_rows = $i);
+ $i = 0;
+ while (mysqli_stmt_fetch($stmt))
+ $i++;
+ assert($num_rows = $i);
- $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows);
- $expected['rows_fetched_from_client_ps_unbuffered'] = (string)($expected['rows_fetched_from_client_ps_unbuffered'] + $num_rows);
- $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
- $expected['ps_unbuffered_sets'] = (string)($expected['ps_unbuffered_sets'] + 1);
+ $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows);
+ $expected['rows_fetched_from_client_ps_unbuffered'] = (string)($expected['rows_fetched_from_client_ps_unbuffered'] + $num_rows);
+ $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
+ $expected['ps_unbuffered_sets'] = (string)($expected['ps_unbuffered_sets'] + 1);
- if (!is_array($info = mysqli_get_client_stats()) || empty($info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($info), $info);
+ if (!is_array($info = mysqli_get_client_stats()) || empty($info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($info), $info);
- mysqli_get_client_stats_assert_gt('bytes_received_real_data_ps', $info, $expected, $test_counter);
- $expected['bytes_received_real_data_ps'] = $info['bytes_received_real_data_ps'];
+ mysqli_get_client_stats_assert_gt('bytes_received_real_data_ps', $info, $expected, $test_counter);
+ $expected['bytes_received_real_data_ps'] = $info['bytes_received_real_data_ps'];
- mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_unbuffered', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('ps_unbuffered_sets', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_unbuffered', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('ps_unbuffered_sets', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter);
- mysqli_stmt_free_result($stmt);
+ mysqli_stmt_free_result($stmt);
- print "Testing unbuffered Prepared Statements... - fetching all but one\n";
+ print "Testing unbuffered Prepared Statements... - fetching all but one\n";
- if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') ||
- !mysqli_stmt_execute($stmt))
- printf("[%03d] prepare/execute failed, [%d] %s\n",
- ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') ||
+ !mysqli_stmt_execute($stmt))
+ printf("[%03d] prepare/execute failed, [%d] %s\n",
+ ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- $id = $label = null;
- if (!mysqli_stmt_bind_result($stmt, $id, $label))
- printf("[%03d] bind_result failed, [%d] %s\n",
- ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
-
- for ($i = 0; $i < $num_rows - 1; $i++)
- mysqli_stmt_fetch($stmt);
-
- $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows - 1);
- $expected['rows_fetched_from_client_ps_unbuffered'] = (string)($expected['rows_fetched_from_client_ps_unbuffered'] + $num_rows - 1);
- $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
- $expected['ps_unbuffered_sets'] = (string)($expected['ps_unbuffered_sets'] + 1);
-
- if (!is_array($info = mysqli_get_client_stats()) || empty($info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($info), $info);
-
- mysqli_get_client_stats_assert_gt('bytes_received_real_data_ps', $info, $expected, $test_counter);
- $expected['bytes_received_real_data_ps'] = $info['bytes_received_real_data_ps'];
-
- mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_unbuffered', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('ps_unbuffered_sets', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter);
-
- mysqli_stmt_free_result($stmt);
- $expected['rows_skipped_ps'] = (string)($expected['rows_skipped_ps'] + 1);
- $expected['flushed_ps_sets'] = (string)($expected['flushed_ps_sets'] + 1);
- $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + 1);
-
- if (!is_array($info = mysqli_get_client_stats()) || empty($info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($info), $info);
-
- mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter);
-
- mysqli_get_client_stats_assert_eq('rows_skipped_ps', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('flushed_ps_sets', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
-
- /*
- print "Checking for normal buffered side effects...\n";
- foreach ($info as $k => $v)
- if ($info[$k] != $expected[$k])
- printf("$k - $v != %s\n", $expected[$k]);
- */
- print "... done with fetch statistics\n";
-
- if (!is_array($info = mysqli_get_client_stats()) || empty($info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($info), $info);
-
- mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter);
-
- //
- // result_set_queries statistics
- //
-
- if (!is_array($info = mysqli_get_client_stats()) || empty($info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($info), $info);
-
- if (!$res = mysqli_query($link, "SELECT id, label FROM test"))
- printf("[%03d] SELECT failed, [%d] %s\n", ++$test_counter,
- mysqli_errno($link), mysqli_error($link));
-
- $rows = 0;
- while ($row = mysqli_fetch_assoc($res))
- $rows++;
-
- if (0 == $rows)
- printf("[%03d] Expecting at least one result, [%d] %s\n", ++$test_counter,
- mysqli_errno($link), mysqli_error($link));
-
- mysqli_free_result($res);
-
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($new_info), $new_info);
-
- mysqli_get_client_stats_assert_eq('result_set_queries', $new_info, (string)($info['result_set_queries'] + 1), $test_counter);
- $info = $new_info;
-
- mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter);
- $expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal'];
-
- //
- // non_result_set_queries - DDL
- //
-
- // CREATE TABLE, DROP TABLE
- if (!mysqli_query($link, "DROP TABLE IF EXISTS non_result_set_queries_test"))
- printf("[%03d] DROP TABLE failed, [%d] %s\n", ++$test_counter,
- mysqli_errno($link), mysqli_error($link));
-
- if (!mysqli_query($link, "CREATE TABLE non_result_set_queries_test(id INT) ENGINE = " . $engine)) {
- printf("[%03d] CREATE TABLE failed, [%d] %s\n", ++$test_counter,
- mysqli_errno($link), mysqli_error($link));
- } else {
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- 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'] + 2), $test_counter, 'CREATE/DROP TABLE');
- }
- $info = $new_info;
-
- // ALERT TABLE
- if (!mysqli_query($link, "ALTER TABLE non_result_set_queries_test ADD label CHAR(1)")) {
- printf("[%03d] ALTER TABLE failed, [%d] %s\n", ++$test_counter,
- mysqli_errno($link), mysqli_error($link));
- } else {
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- 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, 'ALTER TABLE');
- }
- $info = $new_info;
-
- // CREATE INDEX, DROP INDEX
- if (!mysqli_query($link, "CREATE INDEX idx_1 ON non_result_set_queries_test(id)")) {
- printf("[%03d] CREATE INDEX failed, [%d] %s\n", ++$test_counter,
- mysqli_errno($link), mysqli_error($link));
- } else {
-
- if (!mysqli_query($link, "DROP INDEX idx_1 ON non_result_set_queries_test"))
- printf("[%03d] DROP INDEX failed, [%d] %s\n", ++$test_counter,
- mysqli_errno($link), mysqli_error($link));
-
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- 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'] + 2), $test_counter, 'DROP INDEX');
- }
- $info = $new_info;
-
- // RENAME TABLE
- if (!mysqli_query($link, "DROP TABLE IF EXISTS client_stats_test"))
- printf("[%03d] Cleanup, DROP TABLE client_stats_test failed, [%d] %s\n", ++$test_counter,
- mysqli_errno($link), mysqli_error($link));
-
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($new_info), $new_info);
- $info = $new_info;
-
- if (!mysqli_query($link, "RENAME TABLE non_result_set_queries_test TO client_stats_test")) {
- printf("[%03d] RENAME TABLE failed, [%d] %s\n", ++$test_counter,
- mysqli_errno($link), mysqli_error($link));
-
- } else {
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- 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, '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,
- mysqli_errno($link), mysqli_error($link));
-
- if (!mysqli_query($link, "DROP TABLE IF EXISTS client_stats_test"))
- printf("[%03d] Cleanup, DROP TABLE failed, [%d] %s\n", ++$test_counter,
- mysqli_errno($link), mysqli_error($link));
-
- // Let's see if we have privileges for CREATE DATABASE
- mysqli_query($link, "DROP DATABASE IF EXISTS mysqli_get_client_stats");
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($new_info), $new_info);
- $info = $new_info;
-
-
- // CREATE, ALTER, DROP DATABASE
- if (mysqli_query($link, "CREATE DATABASE mysqli_get_client_stats")) {
-
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- 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, "ALTER DATABASE DEFAULT CHARACTER SET latin1"))
- printf("[%03d] ALTER DATABASE failed, [%d] %s\n", ++$test_counter,
- mysqli_errno($link), mysqli_error($link));
-
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- 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,
- mysqli_errno($link), mysqli_error($link));
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($new_info), $new_info);
- $info = $new_info;
-
- if (!mysqli_query($link, "DROP DATABASE mysqli_get_client_stats_"))
- printf("[%03d] DROP DATABASE failed, [%d] %s\n", ++$test_counter,
- mysqli_errno($link), mysqli_error($link));
-
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- 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
- // We don't really try to use federated, we just want to see if the syntax works
- mysqli_query($link, "DROP SERVER IF EXISTS myself");
-
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($new_info), $new_info);
- $info = $new_info;
-
- $sql = sprintf("CREATE SERVER myself FOREIGN DATA WRAPPER mysql OPTIONS (user '%s', password '%s', database '%s')",
- $user, $passwd, $db);
- if (mysqli_query($link, $sql)) {
- // server knows about it
-
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- 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 SERVER');
- $info = $new_info;
-
- if (!mysqli_query($link, sprintf("ALTER SERVER myself OPTIONS(user '%s_')", $user)))
- printf("[%03d] ALTER SERVER failed, [%d] %s\n", ++$test_counter,
- mysqli_errno($link), mysqli_error($link));
-
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- 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, 'ALTER SERVER');
- $info = $new_info;
-
- if (!mysqli_query($link, "DROP SERVER myself"))
- printf("[%03d] DROP SERVER failed, [%d] %s\n", ++$test_counter,
- mysqli_errno($link), mysqli_error($link));
-
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- 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 SERVER');
- $info = $new_info;
- }
-
- mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter);
-
- /*
- We don't test the NDB ones.
- 13.1. Data Definition Statements
- 13.1.3. ALTER LOGFILE GROUP Syntax
- 13.1.4. ALTER TABLESPACE Syntax
- 13.1.9. CREATE LOGFILE GROUP Syntax
- 13.1.10. CREATE TABLESPACE Syntax
- 13.1.15. DROP LOGFILE GROUP Syntax
- 13.1.16. DROP TABLESPACE Syntax
- */
-
- //
- // DML
- //
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($new_info), $new_info);
- $info = $new_info;
-
- if (!mysqli_query($link, "INSERT INTO test(id) VALUES (100)"))
- printf("[%03d] INSERT failed, [%d] %s\n", ++$test_counter,
- mysqli_errno($link), mysqli_error($link));
-
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- 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, 'INSERT');
- $info = $new_info;
-
- if (!mysqli_query($link, "UPDATE test SET label ='z' WHERE id = 100"))
- printf("[%03d] UPDATE failed, [%d] %s\n", ++$test_counter,
- mysqli_errno($link), mysqli_error($link));
-
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- 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, 'UPDATE');
- $info = $new_info;
-
- if (!mysqli_query($link, "REPLACE INTO test(id, label) VALUES (100, 'b')"))
- printf("[%03d] INSERT failed, [%d] %s\n", ++$test_counter,
- mysqli_errno($link), mysqli_error($link));
-
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- 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, 'REPLACE');
- $info = $new_info;
-
- // NOTE: this will NOT update dbl_ddls counter
- if (!$res = mysqli_query($link, "SELECT id, label FROM test WHERE id = 100"))
- printf("[%03d] SELECT@dml failed, [%d] %s\n", ++$test_counter,
- mysqli_errno($link), mysqli_error($link));
- mysqli_free_result($res);
-
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- 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, $info, $test_counter, 'SELECT@dml');
- $info = $new_info;
-
- if (!mysqli_query($link, "DELETE FROM test WHERE id = 100"))
- printf("[%03d] DELETE failed, [%d] %s\n", ++$test_counter,
- mysqli_errno($link), mysqli_error($link));
-
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- 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, 'DELETE');
- $info = $new_info;
-
- if (!$res = mysqli_query($link, "TRUNCATE TABLE test"))
- printf("[%03d] TRUNCATE failed, [%d] %s\n", ++$test_counter,
- mysqli_errno($link), mysqli_error($link));
-
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- 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, 'TRUNCATE');
- $info = $new_info;
-
-
- $file = tempnam(sys_get_temp_dir(), 'mysqli_test');
- if ($fp = fopen($file, 'w')) {
- @fwrite($fp, '1;"a"');
- fclose($fp);
- chmod($file, 0644);
- $sql = sprintf('LOAD DATA LOCAL INFILE "%s" INTO TABLE test', mysqli_real_escape_string($link, $file));
- if (mysqli_query($link, $sql)) {
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- 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, 'LOAD DATA LOCAL');
- $info = $new_info;
- }
- unlink($file);
- }
-
- mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
- mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter);
-
- /*
- We skip those:
- 13.2. Data Manipulation Statements
- 13.2.2. DO Syntax
- 13.2.3. HANDLER Syntax
- 13.2.5. LOAD DATA INFILE Syntax
- */
- mysqli_query($link, "DELETE FROM test");
- if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES (1, 'a'), (2, 'b')"))
- 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"))
- printf("[%03d] Cannot SELECT with mysqli_real_query(), [%d] %s\n", ++$test_counter,
- mysqli_errno($link), mysqli_error($link));
-
- if (!is_object($res = mysqli_use_result($link)))
- printf("[%03d] mysqli_use_result() failed, [%d] %s\n", ++$test_counter,
- mysqli_errno($link), mysqli_error($link));
-
- while ($row = mysqli_fetch_assoc($res))
- ;
- mysqli_free_result($res);
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($new_info), $new_info);
- 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"))
- printf("[%03d] Cannot SELECT with mysqli_real_query() II, [%d] %s\n", ++$test_counter,
- mysqli_errno($link), mysqli_error($link));
-
- if (!is_object($res = mysqli_store_result($link)))
- printf("[%03d] mysqli_use_result() failed, [%d] %s\n", ++$test_counter,
- mysqli_errno($link), mysqli_error($link));
-
- while ($row = mysqli_fetch_assoc($res))
- ;
- mysqli_free_result($res);
- if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
- printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
- ++$test_counter, gettype($new_info), $new_info);
- mysqli_get_client_stats_assert_eq('buffered_sets', $new_info, (string)($info['buffered_sets'] + 1), $test_counter, 'mysqli_use_result()');
- $info = $new_info;
-
- mysqli_close($link);
-
- mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter);
- $expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal'];
- mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter);
-
- /*
- no_index_used
- bad_index_used
- flushed_normal_sets
- flushed_ps_sets
- explicit_close
- implicit_close
- disconnect_close
- in_middle_of_command_close
- explicit_free_result
- implicit_free_result
- explicit_stmt_close
- implicit_stmt_close
- */
-
- print "done!";
+ $id = $label = null;
+ if (!mysqli_stmt_bind_result($stmt, $id, $label))
+ printf("[%03d] bind_result failed, [%d] %s\n",
+ ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+
+ for ($i = 0; $i < $num_rows - 1; $i++)
+ mysqli_stmt_fetch($stmt);
+
+ $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows - 1);
+ $expected['rows_fetched_from_client_ps_unbuffered'] = (string)($expected['rows_fetched_from_client_ps_unbuffered'] + $num_rows - 1);
+ $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
+ $expected['ps_unbuffered_sets'] = (string)($expected['ps_unbuffered_sets'] + 1);
+
+ if (!is_array($info = mysqli_get_client_stats()) || empty($info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($info), $info);
+
+ mysqli_get_client_stats_assert_gt('bytes_received_real_data_ps', $info, $expected, $test_counter);
+ $expected['bytes_received_real_data_ps'] = $info['bytes_received_real_data_ps'];
+
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_unbuffered', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('ps_unbuffered_sets', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter);
+
+ mysqli_stmt_free_result($stmt);
+ $expected['rows_skipped_ps'] = (string)($expected['rows_skipped_ps'] + 1);
+ $expected['flushed_ps_sets'] = (string)($expected['flushed_ps_sets'] + 1);
+ $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + 1);
+
+ if (!is_array($info = mysqli_get_client_stats()) || empty($info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($info), $info);
+
+ mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter);
+
+ mysqli_get_client_stats_assert_eq('rows_skipped_ps', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('flushed_ps_sets', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
+
+ /*
+ print "Checking for normal buffered side effects...\n";
+ foreach ($info as $k => $v)
+ if ($info[$k] != $expected[$k])
+ printf("$k - $v != %s\n", $expected[$k]);
+ */
+ print "... done with fetch statistics\n";
+
+ if (!is_array($info = mysqli_get_client_stats()) || empty($info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($info), $info);
+
+ mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter);
+
+ //
+ // result_set_queries statistics
+ //
+
+ if (!is_array($info = mysqli_get_client_stats()) || empty($info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($info), $info);
+
+ if (!$res = mysqli_query($link, "SELECT id, label FROM test"))
+ printf("[%03d] SELECT failed, [%d] %s\n", ++$test_counter,
+ mysqli_errno($link), mysqli_error($link));
+
+ $rows = 0;
+ while ($row = mysqli_fetch_assoc($res))
+ $rows++;
+
+ if (0 == $rows)
+ printf("[%03d] Expecting at least one result, [%d] %s\n", ++$test_counter,
+ mysqli_errno($link), mysqli_error($link));
+
+ mysqli_free_result($res);
+
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($new_info), $new_info);
+
+ mysqli_get_client_stats_assert_eq('result_set_queries', $new_info, (string)($info['result_set_queries'] + 1), $test_counter);
+ $info = $new_info;
+
+ mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter);
+ $expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal'];
+
+ //
+ // non_result_set_queries - DDL
+ //
+
+ // CREATE TABLE, DROP TABLE
+ if (!mysqli_query($link, "DROP TABLE IF EXISTS non_result_set_queries_test"))
+ printf("[%03d] DROP TABLE failed, [%d] %s\n", ++$test_counter,
+ mysqli_errno($link), mysqli_error($link));
+
+ if (!mysqli_query($link, "CREATE TABLE non_result_set_queries_test(id INT) ENGINE = " . $engine)) {
+ printf("[%03d] CREATE TABLE failed, [%d] %s\n", ++$test_counter,
+ mysqli_errno($link), mysqli_error($link));
+ } else {
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ 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'] + 2), $test_counter, 'CREATE/DROP TABLE');
+ }
+ $info = $new_info;
+
+ // ALERT TABLE
+ if (!mysqli_query($link, "ALTER TABLE non_result_set_queries_test ADD label CHAR(1)")) {
+ printf("[%03d] ALTER TABLE failed, [%d] %s\n", ++$test_counter,
+ mysqli_errno($link), mysqli_error($link));
+ } else {
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ 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, 'ALTER TABLE');
+ }
+ $info = $new_info;
+
+ // CREATE INDEX, DROP INDEX
+ if (!mysqli_query($link, "CREATE INDEX idx_1 ON non_result_set_queries_test(id)")) {
+ printf("[%03d] CREATE INDEX failed, [%d] %s\n", ++$test_counter,
+ mysqli_errno($link), mysqli_error($link));
+ } else {
+
+ if (!mysqli_query($link, "DROP INDEX idx_1 ON non_result_set_queries_test"))
+ printf("[%03d] DROP INDEX failed, [%d] %s\n", ++$test_counter,
+ mysqli_errno($link), mysqli_error($link));
+
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ 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'] + 2), $test_counter, 'DROP INDEX');
+ }
+ $info = $new_info;
+
+ // RENAME TABLE
+ if (!mysqli_query($link, "DROP TABLE IF EXISTS client_stats_test"))
+ printf("[%03d] Cleanup, DROP TABLE client_stats_test failed, [%d] %s\n", ++$test_counter,
+ mysqli_errno($link), mysqli_error($link));
+
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($new_info), $new_info);
+ $info = $new_info;
+
+ if (!mysqli_query($link, "RENAME TABLE non_result_set_queries_test TO client_stats_test")) {
+ printf("[%03d] RENAME TABLE failed, [%d] %s\n", ++$test_counter,
+ mysqli_errno($link), mysqli_error($link));
+
+ } else {
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ 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, '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,
+ mysqli_errno($link), mysqli_error($link));
+
+ if (!mysqli_query($link, "DROP TABLE IF EXISTS client_stats_test"))
+ printf("[%03d] Cleanup, DROP TABLE failed, [%d] %s\n", ++$test_counter,
+ mysqli_errno($link), mysqli_error($link));
+
+ // Let's see if we have privileges for CREATE DATABASE
+ mysqli_query($link, "DROP DATABASE IF EXISTS mysqli_get_client_stats");
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($new_info), $new_info);
+ $info = $new_info;
+
+
+ // CREATE, ALTER, DROP DATABASE
+ if (mysqli_query($link, "CREATE DATABASE mysqli_get_client_stats")) {
+
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ 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, "ALTER DATABASE DEFAULT CHARACTER SET latin1"))
+ printf("[%03d] ALTER DATABASE failed, [%d] %s\n", ++$test_counter,
+ mysqli_errno($link), mysqli_error($link));
+
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ 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,
+ mysqli_errno($link), mysqli_error($link));
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($new_info), $new_info);
+ $info = $new_info;
+
+ if (!mysqli_query($link, "DROP DATABASE mysqli_get_client_stats_"))
+ printf("[%03d] DROP DATABASE failed, [%d] %s\n", ++$test_counter,
+ mysqli_errno($link), mysqli_error($link));
+
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ 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
+ // We don't really try to use federated, we just want to see if the syntax works
+ mysqli_query($link, "DROP SERVER IF EXISTS myself");
+
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($new_info), $new_info);
+ $info = $new_info;
+
+ $sql = sprintf("CREATE SERVER myself FOREIGN DATA WRAPPER mysql OPTIONS (user '%s', password '%s', database '%s')",
+ $user, $passwd, $db);
+ if (mysqli_query($link, $sql)) {
+ // server knows about it
+
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ 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 SERVER');
+ $info = $new_info;
+
+ if (!mysqli_query($link, sprintf("ALTER SERVER myself OPTIONS(user '%s_')", $user)))
+ printf("[%03d] ALTER SERVER failed, [%d] %s\n", ++$test_counter,
+ mysqli_errno($link), mysqli_error($link));
+
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ 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, 'ALTER SERVER');
+ $info = $new_info;
+
+ if (!mysqli_query($link, "DROP SERVER myself"))
+ printf("[%03d] DROP SERVER failed, [%d] %s\n", ++$test_counter,
+ mysqli_errno($link), mysqli_error($link));
+
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ 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 SERVER');
+ $info = $new_info;
+ }
+
+ mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter);
+
+ /*
+ We don't test the NDB ones.
+ 13.1. Data Definition Statements
+ 13.1.3. ALTER LOGFILE GROUP Syntax
+ 13.1.4. ALTER TABLESPACE Syntax
+ 13.1.9. CREATE LOGFILE GROUP Syntax
+ 13.1.10. CREATE TABLESPACE Syntax
+ 13.1.15. DROP LOGFILE GROUP Syntax
+ 13.1.16. DROP TABLESPACE Syntax
+ */
+
+ //
+ // DML
+ //
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($new_info), $new_info);
+ $info = $new_info;
+
+ if (!mysqli_query($link, "INSERT INTO test(id) VALUES (100)"))
+ printf("[%03d] INSERT failed, [%d] %s\n", ++$test_counter,
+ mysqli_errno($link), mysqli_error($link));
+
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ 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, 'INSERT');
+ $info = $new_info;
+
+ if (!mysqli_query($link, "UPDATE test SET label ='z' WHERE id = 100"))
+ printf("[%03d] UPDATE failed, [%d] %s\n", ++$test_counter,
+ mysqli_errno($link), mysqli_error($link));
+
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ 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, 'UPDATE');
+ $info = $new_info;
+
+ if (!mysqli_query($link, "REPLACE INTO test(id, label) VALUES (100, 'b')"))
+ printf("[%03d] INSERT failed, [%d] %s\n", ++$test_counter,
+ mysqli_errno($link), mysqli_error($link));
+
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ 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, 'REPLACE');
+ $info = $new_info;
+
+ // NOTE: this will NOT update dbl_ddls counter
+ if (!$res = mysqli_query($link, "SELECT id, label FROM test WHERE id = 100"))
+ printf("[%03d] SELECT@dml failed, [%d] %s\n", ++$test_counter,
+ mysqli_errno($link), mysqli_error($link));
+ mysqli_free_result($res);
+
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ 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, $info, $test_counter, 'SELECT@dml');
+ $info = $new_info;
+
+ if (!mysqli_query($link, "DELETE FROM test WHERE id = 100"))
+ printf("[%03d] DELETE failed, [%d] %s\n", ++$test_counter,
+ mysqli_errno($link), mysqli_error($link));
+
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ 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, 'DELETE');
+ $info = $new_info;
+
+ if (!$res = mysqli_query($link, "TRUNCATE TABLE test"))
+ printf("[%03d] TRUNCATE failed, [%d] %s\n", ++$test_counter,
+ mysqli_errno($link), mysqli_error($link));
+
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ 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, 'TRUNCATE');
+ $info = $new_info;
+
+
+ $file = tempnam(sys_get_temp_dir(), 'mysqli_test');
+ if ($fp = fopen($file, 'w')) {
+ @fwrite($fp, '1;"a"');
+ fclose($fp);
+ chmod($file, 0644);
+ $sql = sprintf('LOAD DATA LOCAL INFILE "%s" INTO TABLE test', mysqli_real_escape_string($link, $file));
+ if (mysqli_query($link, $sql)) {
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ 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, 'LOAD DATA LOCAL');
+ $info = $new_info;
+ }
+ unlink($file);
+ }
+
+ mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
+ mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter);
+
+ /*
+ We skip those:
+ 13.2. Data Manipulation Statements
+ 13.2.2. DO Syntax
+ 13.2.3. HANDLER Syntax
+ 13.2.5. LOAD DATA INFILE Syntax
+ */
+ mysqli_query($link, "DELETE FROM test");
+ if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES (1, 'a'), (2, 'b')"))
+ 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"))
+ printf("[%03d] Cannot SELECT with mysqli_real_query(), [%d] %s\n", ++$test_counter,
+ mysqli_errno($link), mysqli_error($link));
+
+ if (!is_object($res = mysqli_use_result($link)))
+ printf("[%03d] mysqli_use_result() failed, [%d] %s\n", ++$test_counter,
+ mysqli_errno($link), mysqli_error($link));
+
+ while ($row = mysqli_fetch_assoc($res))
+ ;
+ mysqli_free_result($res);
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($new_info), $new_info);
+ 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"))
+ printf("[%03d] Cannot SELECT with mysqli_real_query() II, [%d] %s\n", ++$test_counter,
+ mysqli_errno($link), mysqli_error($link));
+
+ if (!is_object($res = mysqli_store_result($link)))
+ printf("[%03d] mysqli_use_result() failed, [%d] %s\n", ++$test_counter,
+ mysqli_errno($link), mysqli_error($link));
+
+ while ($row = mysqli_fetch_assoc($res))
+ ;
+ mysqli_free_result($res);
+ if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
+ printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+ ++$test_counter, gettype($new_info), $new_info);
+ mysqli_get_client_stats_assert_eq('buffered_sets', $new_info, (string)($info['buffered_sets'] + 1), $test_counter, 'mysqli_use_result()');
+ $info = $new_info;
+
+ mysqli_close($link);
+
+ mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter);
+ $expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal'];
+ mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter);
+
+ /*
+ no_index_used
+ bad_index_used
+ flushed_normal_sets
+ flushed_ps_sets
+ explicit_close
+ implicit_close
+ disconnect_close
+ in_middle_of_command_close
+ explicit_free_result
+ implicit_free_result
+ explicit_stmt_close
+ implicit_stmt_close
+ */
+
+ print "done!";
?>
--CLEAN--
<?php
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_get_client_stats')) {
- die("skip only available with mysqlnd");
+ die("skip only available with mysqlnd");
}
?>
--INI--
mysqlnd.collect_memory_statistics=1
--FILE--
<?php
- require_once('connect.inc');
- require_once('table.inc');
+ require_once('connect.inc');
+ require_once('table.inc');
- $stats = mysqli_get_client_stats();
- printf("BEGINNING: implicit_free_result = %d\n", $stats['implicit_free_result']);
+ $stats = mysqli_get_client_stats();
+ printf("BEGINNING: implicit_free_result = %d\n", $stats['implicit_free_result']);
- if (!$res = mysqli_query($link, 'SELECT id FROM test'))
- printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!$res = mysqli_query($link, 'SELECT id FROM test'))
+ printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- mysqli_free_result($res);
- mysqli_close($link);
+ mysqli_free_result($res);
+ mysqli_close($link);
- $after = mysqli_get_client_stats();
- if ($after['implicit_free_result'] != $stats['implicit_free_result'])
- printf("[002] Where is the missing mysqli_free_result() call? implicit_free_result has changed by %d.\n",
- $after['implicit_free_result'] - $stats['implicit_free_result']);
+ $after = mysqli_get_client_stats();
+ if ($after['implicit_free_result'] != $stats['implicit_free_result'])
+ printf("[002] Where is the missing mysqli_free_result() call? implicit_free_result has changed by %d.\n",
+ $after['implicit_free_result'] - $stats['implicit_free_result']);
- $stats = $after;
- printf("END: implicit_free_result = %d\n", $stats['implicit_free_result']);
+ $stats = $after;
+ printf("END: implicit_free_result = %d\n", $stats['implicit_free_result']);
- print "done!";
+ print "done!";
?>
--CLEAN--
<?php
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_get_client_stats')) {
- die("skip only available with mysqlnd");
+ die("skip only available with mysqlnd");
}
?>
--INI--
mysqlnd.collect_memory_statistics=0
--FILE--
<?php
- $before = mysqli_get_client_stats();
- if (!is_array($before) || empty($before)) {
- printf("[001] Expecting non-empty array, got %s.\n", gettype($before));
- var_dump($before);
- }
+ $before = mysqli_get_client_stats();
+ if (!is_array($before) || empty($before)) {
+ printf("[001] Expecting non-empty array, got %s.\n", gettype($before));
+ var_dump($before);
+ }
- // connect and table inc connect to mysql and create tables
- require_once('connect.inc');
- require_once('table.inc');
- $after = mysqli_get_client_stats();
+ // connect and table inc connect to mysql and create tables
+ require_once('connect.inc');
+ require_once('table.inc');
+ $after = mysqli_get_client_stats();
- if ($before !== $after) {
- printf("[002] Statistics have changed\n");
- var_dump($before);
- var_dump($after);
- }
+ if ($before !== $after) {
+ printf("[002] Statistics have changed\n");
+ var_dump($before);
+ var_dump($after);
+ }
- foreach ($after as $k => $v)
- if ($v != 0) {
- printf("[003] Field %s should not have any other value but 0, got %s.\n",
- $k, $v);
- }
+ foreach ($after as $k => $v)
+ if ($v != 0) {
+ printf("[003] Field %s should not have any other value but 0, got %s.\n",
+ $k, $v);
+ }
- mysqli_close($link);
- print "done!";
+ mysqli_close($link);
+ print "done!";
?>
--CLEAN--
<?php
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_get_client_stats')) {
- die("skip only available with mysqlnd");
+ die("skip only available with mysqlnd");
}
?>
--INI--
mysqlnd.collect_memory_statistics=1
--FILE--
<?php
- require_once('connect.inc');
- require_once('table.inc');
-
- $stats = mysqli_get_client_stats();
- printf("BEGINNING: rows_fetched_from_client_ps_unbuffered = %d\n", $stats['rows_fetched_from_client_ps_unbuffered']);
- printf("BEGINNING: rows_fetched_from_client_ps_buffered = %d\n", $stats['rows_fetched_from_client_ps_buffered']);
- printf("BEGINNING: rows_fetched_from_client_ps_cursor = %d\n", $stats['rows_fetched_from_client_ps_cursor']);
-
- if (!$stmt = mysqli_stmt_init($link))
- printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
- $id = null;
- if (!mysqli_stmt_prepare($stmt, 'SELECT id FROM test') ||
- !mysqli_stmt_execute($stmt) ||
- !mysqli_stmt_store_result($stmt) ||
- !mysqli_stmt_bind_result($stmt, $id))
- printf("[002] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
-
- $num_rows = 0;
- while (mysqli_stmt_fetch($stmt))
- $num_rows++;
-
- mysqli_stmt_free_result($stmt);
-
- $after = mysqli_get_client_stats();
-
- if ($after['rows_fetched_from_client_ps_unbuffered'] != $stats['rows_fetched_from_client_ps_unbuffered'])
- printf("[003] Unbuffered rows got increased after buffered PS, expecting %d got %d.\n",
- $stats['rows_fetched_from_client_ps_unbuffered'],
- $after['rows_fetched_from_client_ps_unbuffered']);
-
- $stats['rows_fetched_from_client_ps_buffered'] += $num_rows;
- if ($after['rows_fetched_from_client_ps_buffered'] != $stats['rows_fetched_from_client_ps_buffered'] )
- printf("[005] Buffered rows should be %d got %d.\n",
- $stats['rows_fetched_from_client_ps_buffered'],
- $after['rows_fetched_from_client_ps_buffered']);
-
- $stats = $after;
- printf("BUFFERED: rows_fetched_from_client_ps_unbuffered = %d\n", $stats['rows_fetched_from_client_ps_unbuffered']);
- printf("BUFFERED: rows_fetched_from_client_ps_buffered = %d\n", $stats['rows_fetched_from_client_ps_buffered']);
- printf("BUFFERED: rows_fetched_from_client_ps_cursor = %d\n", $stats['rows_fetched_from_client_ps_cursor']);
-
- $id = null;
- if (!mysqli_stmt_prepare($stmt, 'SELECT id FROM test') ||
- !mysqli_stmt_execute($stmt) ||
- !mysqli_stmt_bind_result($stmt, $id))
- printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
-
- $num_rows = 0;
- while (mysqli_stmt_fetch($stmt))
- $num_rows++;
-
- $after = mysqli_get_client_stats();
- $stats['rows_fetched_from_client_ps_unbuffered'] += $num_rows;
- if ($after['rows_fetched_from_client_ps_unbuffered'] != $stats['rows_fetched_from_client_ps_unbuffered'])
- printf("[007] Unbuffered rows should be %d got %d.\n",
- $stats['rows_fetched_from_client_ps_unbuffered'],
- $after['rows_fetched_from_client_ps_unbuffered']);
-
- if ($after['rows_fetched_from_client_ps_buffered'] != $stats['rows_fetched_from_client_ps_buffered'] )
- printf("[005] Buffered rows should be unchanged, expecting %d got %d.\n",
- $stats['rows_fetched_from_client_ps_buffered'],
- $after['rows_fetched_from_client_ps_buffered']);
-
- mysqli_stmt_free_result($stmt);
- mysqli_stmt_close($stmt);
-
- $stats = $after;
- printf("UNBUFFERED: rows_fetched_from_client_ps_unbuffered = %d\n", $stats['rows_fetched_from_client_ps_unbuffered']);
- printf("UNBUFFERED: rows_fetched_from_client_ps_buffered = %d\n", $stats['rows_fetched_from_client_ps_buffered']);
- printf("UNBUFFERED: rows_fetched_from_client_ps_cursor = %d\n", $stats['rows_fetched_from_client_ps_cursor']);
-
- mysqli_close($link);
- print "done!";
+ require_once('connect.inc');
+ require_once('table.inc');
+
+ $stats = mysqli_get_client_stats();
+ printf("BEGINNING: rows_fetched_from_client_ps_unbuffered = %d\n", $stats['rows_fetched_from_client_ps_unbuffered']);
+ printf("BEGINNING: rows_fetched_from_client_ps_buffered = %d\n", $stats['rows_fetched_from_client_ps_buffered']);
+ printf("BEGINNING: rows_fetched_from_client_ps_cursor = %d\n", $stats['rows_fetched_from_client_ps_cursor']);
+
+ if (!$stmt = mysqli_stmt_init($link))
+ printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ $id = null;
+ if (!mysqli_stmt_prepare($stmt, 'SELECT id FROM test') ||
+ !mysqli_stmt_execute($stmt) ||
+ !mysqli_stmt_store_result($stmt) ||
+ !mysqli_stmt_bind_result($stmt, $id))
+ printf("[002] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+
+ $num_rows = 0;
+ while (mysqli_stmt_fetch($stmt))
+ $num_rows++;
+
+ mysqli_stmt_free_result($stmt);
+
+ $after = mysqli_get_client_stats();
+
+ if ($after['rows_fetched_from_client_ps_unbuffered'] != $stats['rows_fetched_from_client_ps_unbuffered'])
+ printf("[003] Unbuffered rows got increased after buffered PS, expecting %d got %d.\n",
+ $stats['rows_fetched_from_client_ps_unbuffered'],
+ $after['rows_fetched_from_client_ps_unbuffered']);
+
+ $stats['rows_fetched_from_client_ps_buffered'] += $num_rows;
+ if ($after['rows_fetched_from_client_ps_buffered'] != $stats['rows_fetched_from_client_ps_buffered'] )
+ printf("[005] Buffered rows should be %d got %d.\n",
+ $stats['rows_fetched_from_client_ps_buffered'],
+ $after['rows_fetched_from_client_ps_buffered']);
+
+ $stats = $after;
+ printf("BUFFERED: rows_fetched_from_client_ps_unbuffered = %d\n", $stats['rows_fetched_from_client_ps_unbuffered']);
+ printf("BUFFERED: rows_fetched_from_client_ps_buffered = %d\n", $stats['rows_fetched_from_client_ps_buffered']);
+ printf("BUFFERED: rows_fetched_from_client_ps_cursor = %d\n", $stats['rows_fetched_from_client_ps_cursor']);
+
+ $id = null;
+ if (!mysqli_stmt_prepare($stmt, 'SELECT id FROM test') ||
+ !mysqli_stmt_execute($stmt) ||
+ !mysqli_stmt_bind_result($stmt, $id))
+ printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+
+ $num_rows = 0;
+ while (mysqli_stmt_fetch($stmt))
+ $num_rows++;
+
+ $after = mysqli_get_client_stats();
+ $stats['rows_fetched_from_client_ps_unbuffered'] += $num_rows;
+ if ($after['rows_fetched_from_client_ps_unbuffered'] != $stats['rows_fetched_from_client_ps_unbuffered'])
+ printf("[007] Unbuffered rows should be %d got %d.\n",
+ $stats['rows_fetched_from_client_ps_unbuffered'],
+ $after['rows_fetched_from_client_ps_unbuffered']);
+
+ if ($after['rows_fetched_from_client_ps_buffered'] != $stats['rows_fetched_from_client_ps_buffered'] )
+ printf("[005] Buffered rows should be unchanged, expecting %d got %d.\n",
+ $stats['rows_fetched_from_client_ps_buffered'],
+ $after['rows_fetched_from_client_ps_buffered']);
+
+ mysqli_stmt_free_result($stmt);
+ mysqli_stmt_close($stmt);
+
+ $stats = $after;
+ printf("UNBUFFERED: rows_fetched_from_client_ps_unbuffered = %d\n", $stats['rows_fetched_from_client_ps_unbuffered']);
+ printf("UNBUFFERED: rows_fetched_from_client_ps_buffered = %d\n", $stats['rows_fetched_from_client_ps_buffered']);
+ printf("UNBUFFERED: rows_fetched_from_client_ps_cursor = %d\n", $stats['rows_fetched_from_client_ps_cursor']);
+
+ mysqli_close($link);
+ print "done!";
?>
--CLEAN--
<?php
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_get_client_stats')) {
- die("skip only available with mysqlnd");
+ die("skip only available with mysqlnd");
}
?>
--FILE--
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_get_connection_stats')) {
- die("skip only available with mysqlnd");
+ die("skip only available with mysqlnd");
}
?>
--FILE--
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_get_connection_stats')) {
- die("skip only available with mysqlnd");
+ die("skip only available with mysqlnd");
}
?>
--FILE--
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
require_once('skipifconnectfailure.inc');
require_once('connect.inc');
if (!$TEST_EXPERIMENTAL)
- die("skip - experimental (= unsupported) feature");
+ die("skip - experimental (= unsupported) feature");
?>
--FILE--
<?php
mysqli.allow_local_infile=1
--FILE--
<?php
- require_once("connect.inc");
+ require_once("connect.inc");
- if (!is_null($tmp = @mysqli_info()))
- printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+ if (!is_null($tmp = @mysqli_info()))
+ printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
- if (!is_null($tmp = @mysqli_info(NULL)))
- printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+ if (!is_null($tmp = @mysqli_info(NULL)))
+ printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
- require "table.inc";
- if (!$res = mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, 'a')"))
- printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ require "table.inc";
+ if (!$res = 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);
+ // 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')"))
- printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!$res = 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 (!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'))
- printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!$res = 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 (!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)'))
- printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!$res = 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 (!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"))
- printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!$res = 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 (!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"))
- printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!$res = 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);
+ 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()) {
- do {
- $file = $dir . '/' . 'mysqli_info_phpt.cvs';
- if (!$fp = fopen($file, 'w'))
- /* ignore this error */
- break;
+ // NOTE: no LOAD DATA INFILE test
+ if ($dir = sys_get_temp_dir()) {
+ do {
+ $file = $dir . '/' . 'mysqli_info_phpt.cvs';
+ if (!$fp = fopen($file, 'w'))
+ /* ignore this error */
+ break;
- if (!fwrite($fp, "100;'a';\n") ||
- !fwrite($fp, "101;'b';\n") ||
- !fwrite($fp, "102;'c';\n")) {
- @unlink($file);
- break;
- }
- fclose($fp);
- if (!mysqli_query($link, "DELETE FROM test")) {
- printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- break;
- }
+ if (!fwrite($fp, "100;'a';\n") ||
+ !fwrite($fp, "101;'b';\n") ||
+ !fwrite($fp, "102;'c';\n")) {
+ @unlink($file);
+ break;
+ }
+ fclose($fp);
+ if (!mysqli_query($link, "DELETE FROM test")) {
+ printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ break;
+ }
- if (!@mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s' INTO TABLE test FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\'' LINES TERMINATED BY '\n'", $file))) {
- /* ok, because we might not be allowed to do this */
- @unlink($file);
- break;
- }
+ if (!@mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s' INTO TABLE test FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\'' LINES TERMINATED BY '\n'", $file))) {
+ /* ok, because we might not be allowed to do this */
+ @unlink($file);
+ break;
+ }
- if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp))
- printf("[016] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
+ if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp))
+ printf("[016] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
- unlink($file);
- } while (false);
- }
+ unlink($file);
+ } while (false);
+ }
- print "done!";
+ print "done!";
?>
--CLEAN--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_insert_id(): Couldn't fetch mysqli in %s on line %d
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_insert_id_var"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
require_once('skipifconnectfailure.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die(sprintf("SKIP [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()));
+ 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)));
+ 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)));
+ die(sprintf("SKIP [%d] %s\n", mysqli_errno($link), mysqli_error($link)));
mysqli_close($link);
?>
memory_limit=256M
--FILE--
<?php
- require('connect.inc');
- if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ require('connect.inc');
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
- if (!$res = mysqli_query($link, "SHOW GLOBAL VARIABLES LIKE 'max_allowed_packet'"))
- printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!$res = mysqli_query($link, "SHOW GLOBAL VARIABLES LIKE 'max_allowed_packet'"))
+ printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- if (!$row = mysqli_fetch_assoc($res))
- printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!$row = mysqli_fetch_assoc($res))
+ printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- mysqli_free_result($res);
+ mysqli_free_result($res);
- if (0 === ($org_max_allowed_packet = (int)$row['Value']))
- printf("[004] Cannot determine max_allowed_packet size and/or bogus max_allowed_packet setting used.\n");
+ if (0 === ($org_max_allowed_packet = (int)$row['Value']))
+ printf("[004] Cannot determine max_allowed_packet size and/or bogus max_allowed_packet setting used.\n");
- $max_len = pow(2, 24);
- if ($org_max_allowed_packet < $max_len) {
- if (!mysqli_query($link, "SET GLOBAL max_allowed_packet = " . ($max_len + 100))) {
- if (1227 == mysqli_errno($link)) {
- /* [1227] Access denied; you need the SUPER privilege for this operation */
- print "done!";
- exit(0);
- } else {
- printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- }
- }
- }
- mysqli_close($link);
- if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- printf("[006] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ $max_len = pow(2, 24);
+ if ($org_max_allowed_packet < $max_len) {
+ if (!mysqli_query($link, "SET GLOBAL max_allowed_packet = " . ($max_len + 100))) {
+ if (1227 == mysqli_errno($link)) {
+ /* [1227] Access denied; you need the SUPER privilege for this operation */
+ print "done!";
+ exit(0);
+ } else {
+ printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ }
+ }
+ }
+ mysqli_close($link);
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[006] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
- if (!mysqli_query($link, "SET NAMES 'latin1'"))
- printf("[007] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ if (!mysqli_query($link, "SET NAMES 'latin1'"))
+ printf("[007] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
- if (!$res = mysqli_query($link, "SHOW GLOBAL VARIABLES LIKE 'max_allowed_packet'"))
- printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!$res = mysqli_query($link, "SHOW GLOBAL VARIABLES LIKE 'max_allowed_packet'"))
+ printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- if (!$row = mysqli_fetch_assoc($res))
- printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!$row = mysqli_fetch_assoc($res))
+ printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- mysqli_free_result($res);
+ mysqli_free_result($res);
- if (0 === ($max_allowed_packet = (int)$row['Value']))
- printf("[010] Cannot determine max_allowed_packet size and/or bogus max_allowed_packet setting used.\n");
+ if (0 === ($max_allowed_packet = (int)$row['Value']))
+ printf("[010] Cannot determine max_allowed_packet size and/or bogus max_allowed_packet setting used.\n");
- $max_len = pow(2, 24);
- if ($max_allowed_packet < $max_len) {
- printf("[011] Failed to change max_allowed_packet");
- }
+ $max_len = pow(2, 24);
+ if ($max_allowed_packet < $max_len) {
+ printf("[011] Failed to change max_allowed_packet");
+ }
- if (!mysqli_query($link, "CREATE TABLE test(col_blob LONGBLOB) ENGINE=" . $engine))
- printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!mysqli_query($link, "CREATE TABLE test(col_blob LONGBLOB) ENGINE=" . $engine))
+ printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- $query_prefix = "INSERT INTO test(col_blob) VALUES ('";
- $query_postfix = "')";
- $query_len = strlen($query_prefix) + strlen($query_postfix);
- $com_query_len = 2;
+ $query_prefix = "INSERT INTO test(col_blob) VALUES ('";
+ $query_postfix = "')";
+ $query_len = strlen($query_prefix) + strlen($query_postfix);
+ $com_query_len = 2;
- $blob = str_repeat('a', $max_len - $com_query_len - $query_len);
- $query = sprintf("%s%s%s", $query_prefix, $blob, $query_postfix);
+ $blob = str_repeat('a', $max_len - $com_query_len - $query_len);
+ $query = sprintf("%s%s%s", $query_prefix, $blob, $query_postfix);
- if (!mysqli_query($link, $query))
- printf("[013] max_allowed_packet = %d, strlen(query) = %d, [%d] %s\n", $max_allowed_packet, strlen($query), mysqli_errno($link), mysqli_error($link));
+ if (!mysqli_query($link, $query))
+ printf("[013] max_allowed_packet = %d, strlen(query) = %d, [%d] %s\n", $max_allowed_packet, strlen($query), mysqli_errno($link), mysqli_error($link));
- if (!$res = mysqli_query($link, "SELECT col_blob FROM test"))
- printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!$res = mysqli_query($link, "SELECT col_blob FROM test"))
+ printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- if (!$row = mysqli_fetch_assoc($res)) {
- printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- } else {
- if ($row['col_blob'] != $blob) {
- printf("[016] Blob seems wrong, dumping data\n");
- var_dump(strlen($row['col_blob']));
- var_dump(strlen($blob));
- }
- mysqli_free_result($res);
- }
+ if (!$row = mysqli_fetch_assoc($res)) {
+ printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ } else {
+ if ($row['col_blob'] != $blob) {
+ printf("[016] Blob seems wrong, dumping data\n");
+ var_dump(strlen($row['col_blob']));
+ var_dump(strlen($blob));
+ }
+ mysqli_free_result($res);
+ }
- if (!mysqli_query($link, "SET GLOBAL max_allowed_packet = " . $org_max_allowed_packet))
- if (1227 != mysqli_errno($link))
- printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!mysqli_query($link, "SET GLOBAL max_allowed_packet = " . $org_max_allowed_packet))
+ if (1227 != mysqli_errno($link))
+ printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- mysqli_close($link);
+ mysqli_close($link);
- print "done!";
+ print "done!";
?>
--CLEAN--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_kill(): processid should have positive value in %s on line %d
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
API: %d, SQL: %d
mysqli.max_links=1
--FILE--
<?php
- require_once("connect.inc");
- require_once("table.inc");
-
- // to make sure we have at least one working connection...
- var_dump(mysqli_ping($link));
- // to make sure that max_links is really set to one
- var_dump((int)ini_get('mysqli.max_links'));
-
- $links = array();
- for ($i = 1; $i <= 5; $i++)
- if ($links[$i] = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- printf("[%03d] One link is already open, it should not be possible to open more, [%d] %s, [%d] %s\n",
- $i, mysqli_connect_errno(), mysqli_connect_error(),
- mysqli_errno($links[$i]), mysqli_error($links[$i]));
-
- for ($i = 1; $i <= 5; $i++) {
- if ($res = mysqli_query($links[$i], 'SELECT id FROM test LIMIT 1')) {
- printf("[%03d] Can run query on link %d\n", 5 + $i, $i);
- mysqli_free_result($res);
- }
- mysqli_close($links[$i]);
- }
-
- mysqli_close($link);
- print "done!";
+ require_once("connect.inc");
+ require_once("table.inc");
+
+ // to make sure we have at least one working connection...
+ var_dump(mysqli_ping($link));
+ // to make sure that max_links is really set to one
+ var_dump((int)ini_get('mysqli.max_links'));
+
+ $links = array();
+ for ($i = 1; $i <= 5; $i++)
+ if ($links[$i] = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[%03d] One link is already open, it should not be possible to open more, [%d] %s, [%d] %s\n",
+ $i, mysqli_connect_errno(), mysqli_connect_error(),
+ mysqli_errno($links[$i]), mysqli_error($links[$i]));
+
+ for ($i = 1; $i <= 5; $i++) {
+ if ($res = mysqli_query($links[$i], 'SELECT id FROM test LIMIT 1')) {
+ printf("[%03d] Can run query on link %d\n", 5 + $i, $i);
+ mysqli_free_result($res);
+ }
+ mysqli_close($links[$i]);
+ }
+
+ mysqli_close($link);
+ print "done!";
?>
--CLEAN--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
[004]
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
[006] 3
require_once('skipifconnectfailure.inc');
require_once('connect.inc');
if (!$IS_MYSQLND)
- /* The libmysql read_timeout limit default is 365 * 24 * 3600 seconds. It cannot be altered through PHP API calls */
- die("skip mysqlnd only test");
+ /* The libmysql read_timeout limit default is 365 * 24 * 3600 seconds. It cannot be altered through PHP API calls */
+ die("skip mysqlnd only test");
?>
--INI--
default_socket_timeout=60
mysqlnd.net_read_timeout=1
--FILE--
<?php
- include ("connect.inc");
+ include ("connect.inc");
- if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
- }
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ }
- if (!$res = mysqli_query($link, "SELECT SLEEP(5)"))
- printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!$res = mysqli_query($link, "SELECT SLEEP(5)"))
+ printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- mysqli_close($link);
+ mysqli_close($link);
- print "done!";
+ print "done!";
?>
--EXPECT--
[002] [2006] MySQL server has gone away
require_once('skipifconnectfailure.inc');
if (!$IS_MYSQLND) {
- die("skip: test applies only to mysqlnd");
+ die("skip: test applies only to mysqlnd");
}
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
}
if (mysqli_get_server_version($link) <= 50011) {
- die(sprintf('skip Needs MySQL 5.0.12+, found version %d.', mysqli_get_server_version($link)));
+ die(sprintf('skip Needs MySQL 5.0.12+, found version %d.', mysqli_get_server_version($link)));
}
?>
--INI--
max_execution_time=12
--FILE--
<?php
- set_time_limit(12);
- include ("connect.inc");
+ set_time_limit(12);
+ include ("connect.inc");
- if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
- }
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ }
- if (!$res = mysqli_query($link, "SELECT SLEEP(6)"))
- printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!$res = mysqli_query($link, "SELECT SLEEP(6)"))
+ printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- var_dump($res->fetch_assoc());
+ var_dump($res->fetch_assoc());
- mysqli_free_result($res);
- mysqli_close($link);
+ mysqli_free_result($res);
+ mysqli_close($link);
- print "done!";
+ print "done!";
?>
--EXPECT--
array(1) {
require_once('skipifconnectfailure.inc');
if (!$IS_MYSQLND) {
- die("skip: test applies only to mysqlnd");
+ die("skip: test applies only to mysqlnd");
}
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
}
if (mysqli_get_server_version($link) <= 50011) {
- die(sprintf('skip Needs MySQL 5.0.12+, found version %d.', mysqli_get_server_version($link)));
+ die(sprintf('skip Needs MySQL 5.0.12+, found version %d.', mysqli_get_server_version($link)));
}
?>
--INI--
mysqlnd.net_read_timeout=0
--FILE--
<?php
- include ("connect.inc");
+ include ("connect.inc");
- if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
- }
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ }
- if (!$res = mysqli_query($link, "SELECT SLEEP(2)"))
- printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!$res = mysqli_query($link, "SELECT SLEEP(2)"))
+ printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- var_dump($res->fetch_assoc());
+ var_dump($res->fetch_assoc());
- mysqli_free_result($res);
- mysqli_close($link);
+ mysqli_free_result($res);
+ mysqli_close($link);
- print "done!";
+ print "done!";
?>
--EXPECT--
array(1) {
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
mysqli.reconnect=0
--FILE--
<?php
- require_once("connect.inc");
- require_once("table.inc");
-
- if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- printf("[001] Cannot create second database connection, [%d] %s\n",
- mysqli_connect_errno(), mysqli_connect_error());
-
- $thread_id_timeout = mysqli_thread_id($link);
- $thread_id_control = mysqli_thread_id($link2);
-
- if (!$res = mysqli_query($link2, "SHOW FULL PROCESSLIST"))
- printf("[002] Cannot get full processlist, [%d] %s\n",
- mysqli_errno($link2), mysqli_error($link));
-
- $running_threads = array();
- while ($row = mysqli_fetch_assoc($res))
- $running_threads[$row['Id']] = $row;
- mysqli_free_result($res);
-
- if (!isset($running_threads[$thread_id_timeout]) ||
- !isset($running_threads[$thread_id_control]))
- printf("[003] Processlist is borked, [%d] %s\n",
- mysqli_errno($link2), mysqli_error($link));
-
- if (!mysqli_query($link, "SET SESSION wait_timeout = 2"))
- printf("[004] Cannot set wait_timeout, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
- if (!$res = mysqli_query($link, "SHOW VARIABLES LIKE 'wait_timeout'"))
- printf("[005] Cannot check if wait_timeout has been set, [%d] %s\n",
- mysqli_errno($link), mysqli_error($link));
-
- if (!$row = mysqli_fetch_assoc($res))
- printf("[006] Cannot get wait_timeout, [%d] %s\n",
- mysqli_errno($link), mysqli_error($link));
- mysqli_free_result($res);
-
- if ($row['Value'] != 2)
- printf("[007] Failed setting the wait_timeout, test will not work, [%d] %s\n",
- mysqli_errno($link), mysqli_error($link));
-
- // after 2+ seconds the server should kill the connection
- sleep(3);
-
- if (!$res = mysqli_query($link2, "SHOW FULL PROCESSLIST"))
- printf("[008] Cannot get full processlist, [%d] %s\n",
- mysqli_errno($link2), mysqli_error($link));
-
- $running_threads = array();
- while ($row = mysqli_fetch_assoc($res))
- $running_threads[$row['Id']] = $row;
- mysqli_free_result($res);
-
- if (isset($running_threads[$thread_id_timeout]))
- printf("[009] Server should have killed the timeout connection, [%d] %s\n",
- mysqli_errno($link2), mysqli_error($link));
-
- if (false !== @mysqli_ping($link))
- printf("[010] Reconnect should not have happened");
-
- if ($res = @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));
-
- if (!$link = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- printf("[012] Cannot create database connection, [%d] %s\n",
- mysqli_connect_errno(), mysqli_connect_error());
-
- $thread_id_timeout = mysqli_thread_id($link);
- /*
- Don't test for the mysqli_query() return value here.
- It is undefined if the server replies to the query and how.
- For example, it seems that on Linux when connecting to MySQL 5.1,
- the server always manages to send a full a reply. Whereas MySQl 5.5
- may not. The behaviour is undefined. Any return value is fine.
- */
- if ($IS_MYSQLND) {
- /*
- mysqlnd is a bit more verbose than libmysql. mysqlnd should print:
- Warning: mysqli_query(): MySQL server has gone away in %s on line %d
-
- Warning: mysqli_query(): Error reading result set's header in %d on line %d
- */
- @mysqli_query($link, sprintf('KILL %d', $thread_id_timeout));
- } else {
- mysqli_query($link, sprintf('KILL %d', $thread_id_timeout));
- }
- // Give the server a second to really kill the other thread...
- sleep(1);
-
- if (!$res = mysqli_query($link2, "SHOW FULL PROCESSLIST"))
- printf("[014] Cannot get full processlist, [%d] %s\n",
- mysqli_errno($link2), mysqli_error($link));
-
- $running_threads = array();
- while ($row = mysqli_fetch_assoc($res))
- $running_threads[$row['Id']] = $row;
- mysqli_free_result($res);
-
- if (isset($running_threads[$thread_id_timeout]) ||
- !isset($running_threads[$thread_id_control]))
- printf("[015] Processlist is borked, [%d] %s\n",
- mysqli_errno($link2), mysqli_error($link));
-
- 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"))
- printf("[017] Running a query should not be possible, connection should be gone, [%d] %s\n",
- mysqli_errno($link), mysqli_error($link));
-
- mysqli_close($link2);
- print "done!";
+ require_once("connect.inc");
+ require_once("table.inc");
+
+ if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[001] Cannot create second database connection, [%d] %s\n",
+ mysqli_connect_errno(), mysqli_connect_error());
+
+ $thread_id_timeout = mysqli_thread_id($link);
+ $thread_id_control = mysqli_thread_id($link2);
+
+ if (!$res = mysqli_query($link2, "SHOW FULL PROCESSLIST"))
+ printf("[002] Cannot get full processlist, [%d] %s\n",
+ mysqli_errno($link2), mysqli_error($link));
+
+ $running_threads = array();
+ while ($row = mysqli_fetch_assoc($res))
+ $running_threads[$row['Id']] = $row;
+ mysqli_free_result($res);
+
+ if (!isset($running_threads[$thread_id_timeout]) ||
+ !isset($running_threads[$thread_id_control]))
+ printf("[003] Processlist is borked, [%d] %s\n",
+ mysqli_errno($link2), mysqli_error($link));
+
+ if (!mysqli_query($link, "SET SESSION wait_timeout = 2"))
+ printf("[004] Cannot set wait_timeout, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (!$res = mysqli_query($link, "SHOW VARIABLES LIKE 'wait_timeout'"))
+ printf("[005] Cannot check if wait_timeout has been set, [%d] %s\n",
+ mysqli_errno($link), mysqli_error($link));
+
+ if (!$row = mysqli_fetch_assoc($res))
+ printf("[006] Cannot get wait_timeout, [%d] %s\n",
+ mysqli_errno($link), mysqli_error($link));
+ mysqli_free_result($res);
+
+ if ($row['Value'] != 2)
+ printf("[007] Failed setting the wait_timeout, test will not work, [%d] %s\n",
+ mysqli_errno($link), mysqli_error($link));
+
+ // after 2+ seconds the server should kill the connection
+ sleep(3);
+
+ if (!$res = mysqli_query($link2, "SHOW FULL PROCESSLIST"))
+ printf("[008] Cannot get full processlist, [%d] %s\n",
+ mysqli_errno($link2), mysqli_error($link));
+
+ $running_threads = array();
+ while ($row = mysqli_fetch_assoc($res))
+ $running_threads[$row['Id']] = $row;
+ mysqli_free_result($res);
+
+ if (isset($running_threads[$thread_id_timeout]))
+ printf("[009] Server should have killed the timeout connection, [%d] %s\n",
+ mysqli_errno($link2), mysqli_error($link));
+
+ if (false !== @mysqli_ping($link))
+ printf("[010] Reconnect should not have happened");
+
+ if ($res = @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));
+
+ if (!$link = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[012] Cannot create database connection, [%d] %s\n",
+ mysqli_connect_errno(), mysqli_connect_error());
+
+ $thread_id_timeout = mysqli_thread_id($link);
+ /*
+ Don't test for the mysqli_query() return value here.
+ It is undefined if the server replies to the query and how.
+ For example, it seems that on Linux when connecting to MySQL 5.1,
+ the server always manages to send a full a reply. Whereas MySQl 5.5
+ may not. The behaviour is undefined. Any return value is fine.
+ */
+ if ($IS_MYSQLND) {
+ /*
+ mysqlnd is a bit more verbose than libmysql. mysqlnd should print:
+ Warning: mysqli_query(): MySQL server has gone away in %s on line %d
+
+ Warning: mysqli_query(): Error reading result set's header in %d on line %d
+ */
+ @mysqli_query($link, sprintf('KILL %d', $thread_id_timeout));
+ } else {
+ mysqli_query($link, sprintf('KILL %d', $thread_id_timeout));
+ }
+ // Give the server a second to really kill the other thread...
+ sleep(1);
+
+ if (!$res = mysqli_query($link2, "SHOW FULL PROCESSLIST"))
+ printf("[014] Cannot get full processlist, [%d] %s\n",
+ mysqli_errno($link2), mysqli_error($link));
+
+ $running_threads = array();
+ while ($row = mysqli_fetch_assoc($res))
+ $running_threads[$row['Id']] = $row;
+ mysqli_free_result($res);
+
+ if (isset($running_threads[$thread_id_timeout]) ||
+ !isset($running_threads[$thread_id_control]))
+ printf("[015] Processlist is borked, [%d] %s\n",
+ mysqli_errno($link2), mysqli_error($link));
+
+ 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"))
+ printf("[017] Running a query should not be possible, connection should be gone, [%d] %s\n",
+ mysqli_errno($link), mysqli_error($link));
+
+ mysqli_close($link2);
+ print "done!";
?>
--EXPECT--
done!
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_num_fields(): Couldn't fetch mysqli_result in %s on line %d
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, bool given in %s on line %d
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_real_connect(): (%s/%d): %s in %s on line %d
require_once('connect.inc');
if (!$IS_MYSQLND)
- die("skip mysqlnd only test");
+ die("skip mysqlnd only test");
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
$tmp = ob_get_contents();
ob_end_clean();
if (!stristr($tmp, "auth_plugin_sha256_password"))
- die("skip SHA256 auth plugin not built-in to mysqlnd");
+ die("skip SHA256 auth plugin not built-in to mysqlnd");
require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die(printf("skip: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()));
+ die(printf("skip: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()));
if (mysqli_get_server_version($link) < 50606)
- die("skip: SHA-256 requires MySQL 5.6.6+");
+ die("skip: SHA-256 requires MySQL 5.6.6+");
if (!($res = $link->query("SHOW PLUGINS"))) {
- die(sprintf("skip [%d] %s\n", $link->errno, $link->error));
+ die(sprintf("skip [%d] %s\n", $link->errno, $link->error));
}
$found = false;
while ($row = $res->fetch_assoc()) {
- if (($row['Name'] == 'sha256_password') && ($row['Status'] == 'ACTIVE')) {
- $found = true;
- break;
- }
+ if (($row['Name'] == 'sha256_password') && ($row['Status'] == 'ACTIVE')) {
+ $found = true;
+ break;
+ }
}
if (!$found)
- die("skip SHA-256 server plugin unavailable");
+ die("skip SHA-256 server plugin unavailable");
if (!($res = $link->query("SHOW STATUS LIKE 'Rsa_public_key'"))) {
- die(sprintf("skip [%d] %s\n", $link->errno, $link->error));
+ die(sprintf("skip [%d] %s\n", $link->errno, $link->error));
}
if (!($row = $res->fetch_assoc())) {
- die(sprintf("skip Failed to check RSA pub key, [%d] %s\n", $link->errno, $link->error));
+ die(sprintf("skip Failed to check RSA pub key, [%d] %s\n", $link->errno, $link->error));
}
if (strlen($row['Value']) < 100) {
- die(sprintf("skip Server misconfiguration? RSA pub key is suspicious, [%d] %s\n", $link->errno, $link->error));
+ die(sprintf("skip Server misconfiguration? RSA pub key is suspicious, [%d] %s\n", $link->errno, $link->error));
}
if (!$link->query("SET @@session.old_passwords=2")) {
- die(sprintf("skip Cannot set @@session.old_passwords=2 [%d] %s", $link->errno, $link->error));
+ die(sprintf("skip Cannot set @@session.old_passwords=2 [%d] %s", $link->errno, $link->error));
}
$link->query('DROP USER shatest');
if (!$link->query('CREATE USER shatest@"%" IDENTIFIED WITH sha256_password') ||
- !$link->query('CREATE USER shatest@"localhost" IDENTIFIED WITH sha256_password')) {
- die(sprintf("skip CREATE USER failed [%d] %s", $link->errno, $link->error));
+ !$link->query('CREATE USER shatest@"localhost" IDENTIFIED WITH sha256_password')) {
+ die(sprintf("skip CREATE USER failed [%d] %s", $link->errno, $link->error));
}
if (!$link->query('SET PASSWORD FOR shatest@"%" = PASSWORD("shatest")') ||
- !$link->query('SET PASSWORD FOR shatest@"localhost" = PASSWORD("shatest")')) {
- die(sprintf("skip SET PASSWORD failed [%d] %s", $link->errno, $link->error));
+ !$link->query('SET PASSWORD FOR shatest@"localhost" = PASSWORD("shatest")')) {
+ die(sprintf("skip SET PASSWORD failed [%d] %s", $link->errno, $link->error));
}
if (!$link->query("DROP TABLE IF EXISTS test") ||
- !$link->query("CREATE TABLE test (id INT)") ||
- !$link->query("INSERT INTO test(id) VALUES (1), (2), (3)"))
- die(sprintf("SKIP [%d] %s\n", $link->errno, $link->error));
+ !$link->query("CREATE TABLE test (id INT)") ||
+ !$link->query("INSERT INTO test(id) VALUES (1), (2), (3)"))
+ die(sprintf("SKIP [%d] %s\n", $link->errno, $link->error));
if (!$link->query(sprintf("GRANT SELECT ON TABLE %s.test TO shatest@'%%'", $db)) ||
- !$link->query(sprintf("GRANT SELECT ON TABLE %s.test TO shatest@'localhost'", $db))) {
- die(sprintf("skip Cannot grant SELECT to user [%d] %s", mysqli_errno($link), mysqli_error($link)));
+ !$link->query(sprintf("GRANT SELECT ON TABLE %s.test TO shatest@'localhost'", $db))) {
+ die(sprintf("skip Cannot grant SELECT to user [%d] %s", mysqli_errno($link), mysqli_error($link)));
}
$link->close();
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
- $link->query('DROP USER shatest');
- $link->query('DROP USER shatest@localhost');
+ require_once("clean_table.inc");
+ $link->query('DROP USER shatest');
+ $link->query('DROP USER shatest@localhost');
?>
--EXPECT--
done!
$tmp = ob_get_contents();
ob_end_clean();
if (!stristr($tmp, "auth_plugin_sha256_password"))
- die("skip SHA256 auth plugin not built-in to mysqlnd");
+ die("skip SHA256 auth plugin not built-in to mysqlnd");
require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die(printf("skip: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()));
+ die(printf("skip: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()));
if (mysqli_get_server_version($link) < 50606)
- die("skip: SHA-256 requires MySQL 5.6.6+");
+ die("skip: SHA-256 requires MySQL 5.6.6+");
if (!($res = $link->query("SHOW PLUGINS"))) {
- die(sprintf("skip [%d] %s\n", $link->errno, $link->error));
+ die(sprintf("skip [%d] %s\n", $link->errno, $link->error));
}
$found = false;
while ($row = $res->fetch_assoc()) {
- if (($row['Name'] == 'sha256_password') && ($row['Status'] == 'ACTIVE')) {
- $found = true;
- break;
- }
+ if (($row['Name'] == 'sha256_password') && ($row['Status'] == 'ACTIVE')) {
+ $found = true;
+ break;
+ }
}
if (!$found)
- die("skip SHA-256 server plugin unavailable");
+ die("skip SHA-256 server plugin unavailable");
if (!($res = $link->query("SHOW STATUS LIKE 'Rsa_public_key'"))) {
- die(sprintf("skip [%d] %s\n", $link->errno, $link->error));
+ die(sprintf("skip [%d] %s\n", $link->errno, $link->error));
}
if (!($row = $res->fetch_assoc())) {
- die(sprintf("skip Failed to check RSA pub key, [%d] %s\n", $link->errno, $link->error));
+ die(sprintf("skip Failed to check RSA pub key, [%d] %s\n", $link->errno, $link->error));
}
$key = $row['Value'];
if (strlen($key) < 100) {
- die(sprintf("skip Server misconfiguration? RSA pub key is suspicious, [%d] %s\n", $link->errno, $link->error));
+ die(sprintf("skip Server misconfiguration? RSA pub key is suspicious, [%d] %s\n", $link->errno, $link->error));
}
/* date changes may give false positive */
$file = "test_sha256_ini";
if ((file_exists($file) && !unlink($file)) || !($fp = @fopen($file, "w"))) {
- die(sprintf("skip Cannot create RSA pub key file '%s'", $file));
+ die(sprintf("skip Cannot create RSA pub key file '%s'", $file));
}
$key = str_replace("A", "a", $key);
$key = str_replace("M", "m", $key);
if (strlen($key) != fwrite($fp, $key)) {
- die(sprintf("skip Failed to create pub key file"));
+ die(sprintf("skip Failed to create pub key file"));
}
if (!$link->query("SET @@session.old_passwords=2")) {
- die(sprintf("skip Cannot set @@session.old_passwords=2 [%d] %s", $link->errno, $link->error));
+ die(sprintf("skip Cannot set @@session.old_passwords=2 [%d] %s", $link->errno, $link->error));
}
$link->query('DROP USER shatest');
if (!$link->query('CREATE USER shatest@"%" IDENTIFIED WITH sha256_password') ||
- !$link->query('CREATE USER shatest@"localhost" IDENTIFIED WITH sha256_password')) {
- die(sprintf("skip CREATE USER failed [%d] %s", $link->errno, $link->error));
+ !$link->query('CREATE USER shatest@"localhost" IDENTIFIED WITH sha256_password')) {
+ die(sprintf("skip CREATE USER failed [%d] %s", $link->errno, $link->error));
}
if (!$link->query('SET PASSWORD FOR shatest@"%" = PASSWORD("shatest")') ||
- !$link->query('SET PASSWORD FOR shatest@"localhost" = PASSWORD("shatest")')) {
- die(sprintf("skip SET PASSWORD failed [%d] %s", $link->errno, $link->error));
+ !$link->query('SET PASSWORD FOR shatest@"localhost" = PASSWORD("shatest")')) {
+ die(sprintf("skip SET PASSWORD failed [%d] %s", $link->errno, $link->error));
}
if (!$link->query("DROP TABLE IF EXISTS test") ||
- !$link->query("CREATE TABLE test (id INT)") ||
- !$link->query("INSERT INTO test(id) VALUES (1), (2), (3)"))
- die(sprintf("SKIP [%d] %s\n", $link->errno, $link->error));
+ !$link->query("CREATE TABLE test (id INT)") ||
+ !$link->query("INSERT INTO test(id) VALUES (1), (2), (3)"))
+ die(sprintf("SKIP [%d] %s\n", $link->errno, $link->error));
if (!$link->query(sprintf("GRANT SELECT ON TABLE %s.test TO shatest@'%%'", $db)) ||
- !$link->query(sprintf("GRANT SELECT ON TABLE %s.test TO shatest@'localhost'", $db))) {
- die(sprintf("skip Cannot grant SELECT to user [%d] %s", mysqli_errno($link), mysqli_error($link)));
+ !$link->query(sprintf("GRANT SELECT ON TABLE %s.test TO shatest@'localhost'", $db))) {
+ die(sprintf("skip Cannot grant SELECT to user [%d] %s", mysqli_errno($link), mysqli_error($link)));
}
$link->close();
mysqlnd.sha256_server_public_key="test_sha256_ini"
--FILE--
<?php
- require_once("connect.inc");
+ require_once("connect.inc");
- $link = new mysqli($host, 'shatest', 'shatest', $db, $port, $socket);
- if ($link->connect_errno) {
- printf("[001] [%d] %s\n", $link->connect_errno, $link->connect_error);
- } else {
- if (!$res = $link->query("SELECT id FROM test WHERE id = 1"))
- printf("[002] [%d] %s\n", $link->errno, $link->error);
+ $link = new mysqli($host, 'shatest', 'shatest', $db, $port, $socket);
+ if ($link->connect_errno) {
+ printf("[001] [%d] %s\n", $link->connect_errno, $link->connect_error);
+ } else {
+ if (!$res = $link->query("SELECT id FROM test WHERE id = 1"))
+ printf("[002] [%d] %s\n", $link->errno, $link->error);
- if (!$row = mysqli_fetch_assoc($res)) {
- printf("[003] [%d] %s\n", $link->errno, $link->error);
- }
+ if (!$row = mysqli_fetch_assoc($res)) {
+ printf("[003] [%d] %s\n", $link->errno, $link->error);
+ }
- if ($row['id'] != 1) {
- printf("[004] Expecting 1 got %s/'%s'", gettype($row['id']), $row['id']);
- }
- }
- print "done!";
+ if ($row['id'] != 1) {
+ printf("[004] Expecting 1 got %s/'%s'", gettype($row['id']), $row['id']);
+ }
+ }
+ print "done!";
?>
--CLEAN--
<?php
$tmp = ob_get_contents();
ob_end_clean();
if (!stristr($tmp, "auth_plugin_sha256_password"))
- die("skip SHA256 auth plugin not built-in to mysqlnd");
+ die("skip SHA256 auth plugin not built-in to mysqlnd");
require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die(printf("skip: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()));
+ die(printf("skip: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()));
if (mysqli_get_server_version($link) < 50606)
- die("skip: SHA-256 requires MySQL 5.6.6+");
+ die("skip: SHA-256 requires MySQL 5.6.6+");
if (!($res = $link->query("SHOW PLUGINS"))) {
- die(sprintf("skip [%d] %s\n", $link->errno, $link->error));
+ die(sprintf("skip [%d] %s\n", $link->errno, $link->error));
}
$found = false;
while ($row = $res->fetch_assoc()) {
- if (($row['Name'] == 'sha256_password') && ($row['Status'] == 'ACTIVE')) {
- $found = true;
- break;
- }
+ if (($row['Name'] == 'sha256_password') && ($row['Status'] == 'ACTIVE')) {
+ $found = true;
+ break;
+ }
}
if (!$found)
- die("skip SHA-256 server plugin unavailable");
+ die("skip SHA-256 server plugin unavailable");
if (!($res = $link->query("SHOW STATUS LIKE 'Rsa_public_key'"))) {
- die(sprintf("skip [%d] %s\n", $link->errno, $link->error));
+ die(sprintf("skip [%d] %s\n", $link->errno, $link->error));
}
if (!($row = $res->fetch_assoc())) {
- die(sprintf("skip Failed to check RSA pub key, [%d] %s\n", $link->errno, $link->error));
+ die(sprintf("skip Failed to check RSA pub key, [%d] %s\n", $link->errno, $link->error));
}
if (strlen($row['Value']) < 100) {
- die(sprintf("skip Server misconfiguration? RSA pub key is suspicious, [%d] %s\n", $link->errno, $link->error));
+ die(sprintf("skip Server misconfiguration? RSA pub key is suspicious, [%d] %s\n", $link->errno, $link->error));
}
/* date changes may give false positive */
$file = sprintf("%s%s%s_%s", sys_get_temp_dir(), DIRECTORY_SEPARATOR, "test_sha256_" , @date("Ymd"));
if ((file_exists($file) && !unlink($file)) || !($fp = @fopen($file, "w"))) {
- die(sprintf("skip Cannot create RSA pub key file '%s'", $file));
+ die(sprintf("skip Cannot create RSA pub key file '%s'", $file));
}
if (strlen($row['Value']) != fwrite($fp, $row['Value'])) {
- die(sprintf("skip Failed to create pub key file"));
+ die(sprintf("skip Failed to create pub key file"));
}
if (!$link->query("SET @@session.old_passwords=2")) {
- die(sprintf("skip Cannot set @@session.old_passwords=2 [%d] %s", $link->errno, $link->error));
+ die(sprintf("skip Cannot set @@session.old_passwords=2 [%d] %s", $link->errno, $link->error));
}
$link->query('DROP USER shatest');
if (!$link->query('CREATE USER shatest@"%" IDENTIFIED WITH sha256_password') ||
- !$link->query('CREATE USER shatest@"localhost" IDENTIFIED WITH sha256_password')) {
- die(sprintf("skip CREATE USER failed [%d] %s", $link->errno, $link->error));
+ !$link->query('CREATE USER shatest@"localhost" IDENTIFIED WITH sha256_password')) {
+ die(sprintf("skip CREATE USER failed [%d] %s", $link->errno, $link->error));
}
if (!$link->query('SET PASSWORD FOR shatest@"%" = PASSWORD("shatest")') ||
- !$link->query('SET PASSWORD FOR shatest@"localhost" = PASSWORD("shatest")')) {
- die(sprintf("skip SET PASSWORD failed [%d] %s", $link->errno, $link->error));
+ !$link->query('SET PASSWORD FOR shatest@"localhost" = PASSWORD("shatest")')) {
+ die(sprintf("skip SET PASSWORD failed [%d] %s", $link->errno, $link->error));
}
if (!$link->query("DROP TABLE IF EXISTS test") ||
- !$link->query("CREATE TABLE test (id INT)") ||
- !$link->query("INSERT INTO test(id) VALUES (1), (2), (3)"))
- die(sprintf("SKIP [%d] %s\n", $link->errno, $link->error));
+ !$link->query("CREATE TABLE test (id INT)") ||
+ !$link->query("INSERT INTO test(id) VALUES (1), (2), (3)"))
+ die(sprintf("SKIP [%d] %s\n", $link->errno, $link->error));
if (!$link->query(sprintf("GRANT SELECT ON TABLE %s.test TO shatest@'%%'", $db)) ||
- !$link->query(sprintf("GRANT SELECT ON TABLE %s.test TO shatest@'localhost'", $db))) {
- die(sprintf("skip Cannot grant SELECT to user [%d] %s", mysqli_errno($link), mysqli_error($link)));
+ !$link->query(sprintf("GRANT SELECT ON TABLE %s.test TO shatest@'localhost'", $db))) {
+ die(sprintf("skip Cannot grant SELECT to user [%d] %s", mysqli_errno($link), mysqli_error($link)));
}
$link->close();
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
- $link->query('DROP USER shatest');
- $link->query('DROP USER shatest@localhost');
- $file = sprintf("%s%s%s_%s", sys_get_temp_dir(), DIRECTORY_SEPARATOR, "test_sha256_" , @date("Ymd"));
- @unlink($file);
+ require_once("clean_table.inc");
+ $link->query('DROP USER shatest');
+ $link->query('DROP USER shatest@localhost');
+ $file = sprintf("%s%s%s_%s", sys_get_temp_dir(), DIRECTORY_SEPARATOR, "test_sha256_" , @date("Ymd"));
+ @unlink($file);
?>
--EXPECT--
done!
$tmp = ob_get_contents();
ob_end_clean();
if (!stristr($tmp, "auth_plugin_sha256_password"))
- die("skip SHA256 auth plugin not built-in to mysqlnd");
+ die("skip SHA256 auth plugin not built-in to mysqlnd");
require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die(printf("skip: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()));
+ die(printf("skip: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()));
if (mysqli_get_server_version($link) < 50606)
- die("skip: SHA-256 requires MySQL 5.6.6+");
+ die("skip: SHA-256 requires MySQL 5.6.6+");
if (!($res = $link->query("SHOW PLUGINS"))) {
- die(sprintf("skip [%d] %s\n", $link->errno, $link->error));
+ die(sprintf("skip [%d] %s\n", $link->errno, $link->error));
}
$found = false;
while ($row = $res->fetch_assoc()) {
- if (($row['Name'] == 'sha256_password') && ($row['Status'] == 'ACTIVE')) {
- $found = true;
- break;
- }
+ if (($row['Name'] == 'sha256_password') && ($row['Status'] == 'ACTIVE')) {
+ $found = true;
+ break;
+ }
}
if (!$found)
- die("skip SHA-256 server plugin unavailable");
+ die("skip SHA-256 server plugin unavailable");
if (!($res = $link->query("SHOW STATUS LIKE 'Rsa_public_key'"))) {
- die(sprintf("skip [%d] %s\n", $link->errno, $link->error));
+ die(sprintf("skip [%d] %s\n", $link->errno, $link->error));
}
if (!($row = $res->fetch_assoc())) {
- die(sprintf("skip Failed to check RSA pub key, [%d] %s\n", $link->errno, $link->error));
+ die(sprintf("skip Failed to check RSA pub key, [%d] %s\n", $link->errno, $link->error));
}
if (strlen($row['Value']) < 100) {
- die(sprintf("skip Server misconfiguration? RSA pub key is suspicious, [%d] %s\n", $link->errno, $link->error));
+ die(sprintf("skip Server misconfiguration? RSA pub key is suspicious, [%d] %s\n", $link->errno, $link->error));
}
/* date changes may give false positive */
$file = sprintf("%s%s%s_%s", sys_get_temp_dir(), DIRECTORY_SEPARATOR, "test_sha256_" , @date("Ymd"));
if ((file_exists($file) && !unlink($file)) || !($fp = @fopen($file, "w"))) {
- die(sprintf("skip Cannot create RSA pub key file '%s'", $file));
+ die(sprintf("skip Cannot create RSA pub key file '%s'", $file));
}
if (strlen($row['Value']) != fwrite($fp, $row['Value'])) {
- die(sprintf("skip Failed to create pub key file"));
+ die(sprintf("skip Failed to create pub key file"));
}
if (!$link->query("SET @@session.old_passwords=2")) {
- die(sprintf("skip Cannot set @@session.old_passwords=2 [%d] %s", $link->errno, $link->error));
+ die(sprintf("skip Cannot set @@session.old_passwords=2 [%d] %s", $link->errno, $link->error));
}
$link->query('DROP USER shatest');
if (!$link->query('CREATE USER shatest@"%" IDENTIFIED WITH sha256_password') ||
- !$link->query('CREATE USER shatest@"localhost" IDENTIFIED WITH sha256_password')) {
- die(sprintf("skip CREATE USER failed [%d] %s", $link->errno, $link->error));
+ !$link->query('CREATE USER shatest@"localhost" IDENTIFIED WITH sha256_password')) {
+ die(sprintf("skip CREATE USER failed [%d] %s", $link->errno, $link->error));
}
if (!$link->query('SET PASSWORD FOR shatest@"%" = PASSWORD("shatest")') ||
- !$link->query('SET PASSWORD FOR shatest@"localhost" = PASSWORD("shatest")')) {
- die(sprintf("skip SET PASSWORD failed [%d] %s", $link->errno, $link->error));
+ !$link->query('SET PASSWORD FOR shatest@"localhost" = PASSWORD("shatest")')) {
+ die(sprintf("skip SET PASSWORD failed [%d] %s", $link->errno, $link->error));
}
if (!$link->query("DROP TABLE IF EXISTS test") ||
- !$link->query("CREATE TABLE test (id INT)") ||
- !$link->query("INSERT INTO test(id) VALUES (1), (2), (3)"))
- die(sprintf("SKIP [%d] %s\n", $link->errno, $link->error));
+ !$link->query("CREATE TABLE test (id INT)") ||
+ !$link->query("INSERT INTO test(id) VALUES (1), (2), (3)"))
+ die(sprintf("SKIP [%d] %s\n", $link->errno, $link->error));
if (!$link->query(sprintf("GRANT SELECT ON TABLE %s.test TO shatest@'%%'", $db)) ||
- !$link->query(sprintf("GRANT SELECT ON TABLE %s.test TO shatest@'localhost'", $db))) {
- die(sprintf("skip Cannot grant SELECT to user [%d] %s", mysqli_errno($link), mysqli_error($link)));
+ !$link->query(sprintf("GRANT SELECT ON TABLE %s.test TO shatest@'localhost'", $db))) {
+ die(sprintf("skip Cannot grant SELECT to user [%d] %s", mysqli_errno($link), mysqli_error($link)));
}
$link->close();
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
- $link->query('DROP USER shatest');
- $link->query('DROP USER shatest@localhost');
- $file = sprintf("%s%s%s_%s", sys_get_temp_dir(), DIRECTORY_SEPARATOR, "test_sha256_" , @date("Ymd"));
- @unlink($file);
- $file_wrong = sprintf("%s%s%s_%s", sys_get_temp_dir(), DIRECTORY_SEPARATOR, "test_sha256_wrong" , @date("Ymd"));
- @unlink($file_wrong);
+ require_once("clean_table.inc");
+ $link->query('DROP USER shatest');
+ $link->query('DROP USER shatest@localhost');
+ $file = sprintf("%s%s%s_%s", sys_get_temp_dir(), DIRECTORY_SEPARATOR, "test_sha256_" , @date("Ymd"));
+ @unlink($file);
+ $file_wrong = sprintf("%s%s%s_%s", sys_get_temp_dir(), DIRECTORY_SEPARATOR, "test_sha256_wrong" , @date("Ymd"));
+ @unlink($file_wrong);
?>
--EXPECTF--
Warning: mysqli::real_connect(): (HY000/1045): %s in %s on line %d
mysqli.max_links=-1
--FILE--
<?php
- require_once("connect.inc");
+ require_once("connect.inc");
- $phost = 'p:' . $host;
+ $phost = 'p:' . $host;
- if (!$link = my_mysqli_connect($phost, $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",
- $phost, $user, $db, $port, $socket);
+ if (!$link = my_mysqli_connect($phost, $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",
+ $phost, $user, $db, $port, $socket);
- if (!$thread_id = $link->thread_id)
- printf("[002] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!$thread_id = $link->thread_id)
+ printf("[002] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- if (true !== ($tmp = my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)))
- printf("[003] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
+ if (true !== ($tmp = my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)))
+ printf("[003] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
- if (!is_int($new_thread_id = mysqli_thread_id($link)) || ($new_thread_id < 0))
- printf("[004] Expecting int/any got %s/%s\n", gettype($tmp), $tmp);
+ if (!is_int($new_thread_id = mysqli_thread_id($link)) || ($new_thread_id < 0))
+ printf("[004] Expecting int/any got %s/%s\n", gettype($tmp), $tmp);
- if ($thread_id == $new_thread_id)
- printf("[005] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id);
+ if ($thread_id == $new_thread_id)
+ printf("[005] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id);
- if (!($res = mysqli_query($link, "SELECT 'ok' AS it_works")) ||
- !($row = mysqli_fetch_assoc($res)))
- printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!($res = mysqli_query($link, "SELECT 'ok' AS it_works")) ||
+ !($row = mysqli_fetch_assoc($res)))
+ printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- var_dump($row);
- mysqli_free_result($res);
+ var_dump($row);
+ mysqli_free_result($res);
- mysqli_close($link);
+ mysqli_close($link);
- if (!$link = new my_mysqli($phost, $user, $passwd, $db, $port, $socket))
- printf("[007] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $phost, $user, $db, $port, $socket);
+ if (!$link = new my_mysqli($phost, $user, $passwd, $db, $port, $socket))
+ printf("[007] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $phost, $user, $db, $port, $socket);
- if (!$thread_id = $link->thread_id)
- printf("[008] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!$thread_id = $link->thread_id)
+ printf("[008] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- if (true !== ($tmp = $link->real_connect($host, $user, $passwd, $db, $port, $socket)))
- printf("[009] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
+ if (true !== ($tmp = $link->real_connect($host, $user, $passwd, $db, $port, $socket)))
+ printf("[009] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
- if (!is_int($new_thread_id = $link->thread_id) || ($new_thread_id < 0))
- printf("[010] Expecting int/any got %s/%s\n", gettype($tmp), $tmp);
+ if (!is_int($new_thread_id = $link->thread_id) || ($new_thread_id < 0))
+ printf("[010] Expecting int/any got %s/%s\n", gettype($tmp), $tmp);
- if ($thread_id == $new_thread_id)
- printf("[011] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id);
+ if ($thread_id == $new_thread_id)
+ printf("[011] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id);
- if (!($res = $link->query("SELECT 'works also with oo' AS syntax")) ||
- !($row = $res->fetch_assoc()))
- printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!($res = $link->query("SELECT 'works also with oo' AS syntax")) ||
+ !($row = $res->fetch_assoc()))
+ printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- var_dump($row);
- mysqli_free_result($res);
+ var_dump($row);
+ mysqli_free_result($res);
- mysqli_close($link);
+ mysqli_close($link);
- if (NULL !== ($tmp = $link->connect($phost, $user, $passwd, $db, $port, $socket)))
- printf("[013] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
+ if (NULL !== ($tmp = $link->connect($phost, $user, $passwd, $db, $port, $socket)))
+ printf("[013] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
- if (!$link = mysqli_connect($phost, $user, $passwd, $db, $port, $socket))
- printf("[014] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $phost, $user, $db, $port, $socket);
+ if (!$link = mysqli_connect($phost, $user, $passwd, $db, $port, $socket))
+ printf("[014] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $phost, $user, $db, $port, $socket);
- if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
- printf("[015] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
+ if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
+ printf("[015] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
- printf("Flipping phost/host order\n");
+ printf("Flipping phost/host order\n");
- if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- printf("[016] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket);
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[016] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
- if (!$thread_id = mysqli_thread_id($link))
- printf("[017] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!$thread_id = mysqli_thread_id($link))
+ printf("[017] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- if (true !== ($tmp = my_mysqli_real_connect($link, $phost, $user, $passwd, $db, $port, $socket)))
- printf("[018] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
+ if (true !== ($tmp = my_mysqli_real_connect($link, $phost, $user, $passwd, $db, $port, $socket)))
+ printf("[018] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
- if (!is_int($new_thread_id = mysqli_thread_id($link)) || ($new_thread_id < 0))
- printf("[019] Expecting int/any got %s/%s\n", gettype($tmp), $tmp);
+ if (!is_int($new_thread_id = mysqli_thread_id($link)) || ($new_thread_id < 0))
+ printf("[019] Expecting int/any got %s/%s\n", gettype($tmp), $tmp);
- if ($thread_id == $new_thread_id)
- printf("[020] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id);
+ if ($thread_id == $new_thread_id)
+ printf("[020] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id);
- if (!($res = mysqli_query($link, "SELECT 'ok' AS it_works")) ||
- !($row = mysqli_fetch_assoc($res)))
- printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!($res = mysqli_query($link, "SELECT 'ok' AS it_works")) ||
+ !($row = mysqli_fetch_assoc($res)))
+ printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- var_dump($row);
- mysqli_free_result($res);
+ var_dump($row);
+ mysqli_free_result($res);
- mysqli_close($link);
+ mysqli_close($link);
- if (!$link = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
- printf("[022] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket);
+ if (!$link = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
+ printf("[022] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
- if (!$thread_id = $link->thread_id)
- printf("[023] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!$thread_id = $link->thread_id)
+ printf("[023] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- if (true !== ($tmp = $link->real_connect($phost, $user, $passwd, $db, $port, $socket)))
- printf("[024] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
+ if (true !== ($tmp = $link->real_connect($phost, $user, $passwd, $db, $port, $socket)))
+ printf("[024] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
- if (!is_int($new_thread_id = $link->thread_id) || ($new_thread_id < 0))
- printf("[025] Expecting int/any got %s/%s\n", gettype($tmp), $tmp);
+ if (!is_int($new_thread_id = $link->thread_id) || ($new_thread_id < 0))
+ printf("[025] Expecting int/any got %s/%s\n", gettype($tmp), $tmp);
- if ($thread_id == $new_thread_id)
- printf("[026] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id);
+ if ($thread_id == $new_thread_id)
+ printf("[026] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id);
- if (!($res = $link->query("SELECT 'works also with oo' AS syntax")) ||
- !($row = $res->fetch_assoc()))
- printf("[027] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!($res = $link->query("SELECT 'works also with oo' AS syntax")) ||
+ !($row = $res->fetch_assoc()))
+ printf("[027] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- var_dump($row);
- mysqli_free_result($res);
+ var_dump($row);
+ mysqli_free_result($res);
- mysqli_close($link);
+ mysqli_close($link);
- if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
- printf("[028] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
+ if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
+ printf("[028] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- printf("[029] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket);
+ if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[029] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
- if (NULL !== ($tmp = $link->connect($phost, $user, $passwd, $db, $port, $socket)))
- printf("[030] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
+ if (NULL !== ($tmp = $link->connect($phost, $user, $passwd, $db, $port, $socket)))
+ printf("[030] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
- print "done!";
+ print "done!";
?>
--EXPECT--
array(1) {
mysqli.max_links=2
--FILE--
<?php
- require_once("connect.inc");
-
- $host = 'p:' . $host;
- if (!$link1 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- // automatic downgrade to normal connections has failed
- printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
- $host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error());
- }
- if (!mysqli_query($link1, "SET @pcondisabled = 'Connection 1'"))
- printf("[002] Cannot set user variable to check if we got the same persistent connection, [%d] %s\n",
- mysqli_errno($link1), mysqli_error($link1));
-
- if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- // automatic downgrade to normal connections has failed
- printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
- $host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error());
- }
-
- if (!$res = mysqli_query($link1, 'SELECT @pcondisabled AS _test'))
- printf("[004] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2));
-
- $row = mysqli_fetch_assoc($res);
- printf("Connecction 1 - SELECT @pcondisabled -> '%s'\n", $row['_test']);
- mysqli_free_result($res);
-
- if (!$res = mysqli_query($link2, 'SELECT @pcondisabled AS _test'))
- printf("[005] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2));
-
- $row = mysqli_fetch_assoc($res);
- printf("Connecction 2 - SELECT @pcondisabled -> '%s'\n", $row['_test']);
- mysqli_free_result($res);
-
- if ($link1 === $link2)
- printf("[006] Links should not be identical\n");
-
- mysqli_close($link1);
- mysqli_close($link2);
- print "done!";
+ require_once("connect.inc");
+
+ $host = 'p:' . $host;
+ if (!$link1 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ // automatic downgrade to normal connections has failed
+ printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
+ $host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error());
+ }
+ if (!mysqli_query($link1, "SET @pcondisabled = 'Connection 1'"))
+ printf("[002] Cannot set user variable to check if we got the same persistent connection, [%d] %s\n",
+ mysqli_errno($link1), mysqli_error($link1));
+
+ if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ // automatic downgrade to normal connections has failed
+ printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
+ $host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error());
+ }
+
+ if (!$res = mysqli_query($link1, 'SELECT @pcondisabled AS _test'))
+ printf("[004] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2));
+
+ $row = mysqli_fetch_assoc($res);
+ printf("Connecction 1 - SELECT @pcondisabled -> '%s'\n", $row['_test']);
+ mysqli_free_result($res);
+
+ if (!$res = mysqli_query($link2, 'SELECT @pcondisabled AS _test'))
+ printf("[005] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2));
+
+ $row = mysqli_fetch_assoc($res);
+ printf("Connecction 2 - SELECT @pcondisabled -> '%s'\n", $row['_test']);
+ mysqli_free_result($res);
+
+ if ($link1 === $link2)
+ printf("[006] Links should not be identical\n");
+
+ mysqli_close($link1);
+ mysqli_close($link2);
+ print "done!";
?>
--EXPECTF--
Warning: my_mysqli_connect(): Persistent connections are disabled. Downgrading to normal in %s on line %d
mysqli.max_persistent=2
--FILE--
<?php
- require_once("connect.inc");
- require_once("table.inc");
-
- $host = 'p:' . $host;
- if (!$plink = 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);
-
- // get the thread ids of the two connections...
- $thread_id = mysqli_thread_id($link);
- $pthread_id = mysqli_thread_id($plink);
-
- if (!$res = mysqli_query($link, 'SHOW FULL PROCESSLIST'))
- printf("[002] Cannot get processlist, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
- $running_threads = array();
- while ($row = mysqli_fetch_assoc($res))
- $running_threads[$row['Id']] = $row;
- mysqli_free_result($res);
-
- if (count($running_threads) < 2)
- printf("[003] Processlist is too short, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
- if (!isset($running_threads[$thread_id]))
- printf("[004] Cannot find thread id of the regular link, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
- if (!isset($running_threads[$pthread_id]))
- printf("[005] Cannot find thread id of the persistent link, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
- // Kill the persistent connection - don't use mysqli_kill, mysqlnd will catch that...
- if (!mysqli_query($link, sprintf('KILL %d', $pthread_id)))
- printf("[006] Cannot kill persistent connection, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- mysqli_close($plink);
- // Give the server think-time to kill the pthread
- sleep(1);
-
- if (!$res = mysqli_query($link, 'SHOW FULL PROCESSLIST'))
- printf("[007] Cannot get processlist, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
- $running_threads2 = array();
- while ($row = mysqli_fetch_assoc($res))
- $running_threads2[$row['Id']] = $row;
- mysqli_free_result($res);
-
- if (isset($running_threads2[$pthread_id]))
- printf("[008] Thread of the persistent connection should have been gone, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- if (!isset($running_threads2[$thread_id]))
- printf("[009] Thread of the regular connection should be still there, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
- // On PHP side this should do nothing. PHP should not try to close the connection or something.
- @mysqli_close($plink);
-
- if (!$plink = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- printf("[011] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket);
- if (!$res3 = @mysqli_query($plink, 'SELECT id FROM test ORDER BY id LIMIT 1')) {
- printf("[012] New persistent connection cannot execute queries, [%d] %s\n", @mysqli_errno($plink), @mysqli_error($plink));
- }
-
- @mysqli_free_result($res3);
- @mysqli_close($plink);
- mysqli_close($link);
-
- // remove the "p:<host>" from the host variable
- $host = substr($host, 2);
- if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- printf("[013] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket);
- if (!$res4 = mysqli_query($link, 'SELECT id FROM test ORDER BY id LIMIT 1'))
- printf("[014] New regular connection cannot execute queries, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
- mysqli_free_result($res4);
- mysqli_close($link);
- print "done!";
+ require_once("connect.inc");
+ require_once("table.inc");
+
+ $host = 'p:' . $host;
+ if (!$plink = 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);
+
+ // get the thread ids of the two connections...
+ $thread_id = mysqli_thread_id($link);
+ $pthread_id = mysqli_thread_id($plink);
+
+ if (!$res = mysqli_query($link, 'SHOW FULL PROCESSLIST'))
+ printf("[002] Cannot get processlist, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ $running_threads = array();
+ while ($row = mysqli_fetch_assoc($res))
+ $running_threads[$row['Id']] = $row;
+ mysqli_free_result($res);
+
+ if (count($running_threads) < 2)
+ printf("[003] Processlist is too short, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (!isset($running_threads[$thread_id]))
+ printf("[004] Cannot find thread id of the regular link, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (!isset($running_threads[$pthread_id]))
+ printf("[005] Cannot find thread id of the persistent link, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ // Kill the persistent connection - don't use mysqli_kill, mysqlnd will catch that...
+ if (!mysqli_query($link, sprintf('KILL %d', $pthread_id)))
+ printf("[006] Cannot kill persistent connection, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ mysqli_close($plink);
+ // Give the server think-time to kill the pthread
+ sleep(1);
+
+ if (!$res = mysqli_query($link, 'SHOW FULL PROCESSLIST'))
+ printf("[007] Cannot get processlist, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ $running_threads2 = array();
+ while ($row = mysqli_fetch_assoc($res))
+ $running_threads2[$row['Id']] = $row;
+ mysqli_free_result($res);
+
+ if (isset($running_threads2[$pthread_id]))
+ printf("[008] Thread of the persistent connection should have been gone, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!isset($running_threads2[$thread_id]))
+ printf("[009] Thread of the regular connection should be still there, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ // On PHP side this should do nothing. PHP should not try to close the connection or something.
+ @mysqli_close($plink);
+
+ if (!$plink = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[011] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
+ if (!$res3 = @mysqli_query($plink, 'SELECT id FROM test ORDER BY id LIMIT 1')) {
+ printf("[012] New persistent connection cannot execute queries, [%d] %s\n", @mysqli_errno($plink), @mysqli_error($plink));
+ }
+
+ @mysqli_free_result($res3);
+ @mysqli_close($plink);
+ mysqli_close($link);
+
+ // remove the "p:<host>" from the host variable
+ $host = substr($host, 2);
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[013] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
+ if (!$res4 = mysqli_query($link, 'SELECT id FROM test ORDER BY id LIMIT 1'))
+ printf("[014] New regular connection cannot execute queries, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ mysqli_free_result($res4);
+ mysqli_close($link);
+ print "done!";
?>
--CLEAN--
<?php
mysqli.max_links=-1
--FILE--
<?php
- require_once("connect.inc");
- // opens a regular connection
- require_once("table.inc");
+ require_once("connect.inc");
+ // opens a regular connection
+ require_once("table.inc");
- if (!$res = mysqli_query($link, "SELECT 'works..' as _desc"))
- printf("[001] Cannot run query, [%d] %s\n",
- mysqli_errno($link), mysqli_error($link));
+ if (!$res = mysqli_query($link, "SELECT 'works..' as _desc"))
+ printf("[001] Cannot run query, [%d] %s\n",
+ mysqli_errno($link), mysqli_error($link));
- $row = mysqli_fetch_assoc($res);
- mysqli_free_result($res);
- printf("Regular connection 1 - '%s'\n", $row['_desc']);
+ $row = mysqli_fetch_assoc($res);
+ mysqli_free_result($res);
+ printf("Regular connection 1 - '%s'\n", $row['_desc']);
- if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- printf("[002] Cannot open second regular connection, [%d] %s\n",
- mysqli_connect_errno(), mysqli_connect_error());
+ if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[002] Cannot open second regular connection, [%d] %s\n",
+ mysqli_connect_errno(), mysqli_connect_error());
- if (!$res = mysqli_query($link2, "SELECT 'works...' as _desc"))
- printf("[003] Cannot run query, [%d] %s\n",
- mysqli_errno($link2), mysqli_error($link2));
+ if (!$res = mysqli_query($link2, "SELECT 'works...' as _desc"))
+ printf("[003] Cannot run query, [%d] %s\n",
+ mysqli_errno($link2), mysqli_error($link2));
- $row = mysqli_fetch_assoc($res);
- mysqli_free_result($res);
- printf("Regular connection 2 - '%s'\n", $row['_desc']);
+ $row = mysqli_fetch_assoc($res);
+ mysqli_free_result($res);
+ printf("Regular connection 2 - '%s'\n", $row['_desc']);
- $host = 'p:' . $host;
- if (!$plink = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- printf("[004] Cannot create persistent connection using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
- $host, $user, $db, $port, $socket,
- mysqli_connect_errno(), mysqli_connect_error());
+ $host = 'p:' . $host;
+ if (!$plink = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[004] Cannot create persistent connection using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
+ $host, $user, $db, $port, $socket,
+ mysqli_connect_errno(), mysqli_connect_error());
- if (!$res = mysqli_query($plink, "SELECT 'works...' as _desc"))
- printf("[005] Cannot run query, [%d] %s\n",
- mysqli_errno($plink), mysqli_error($plink));
+ if (!$res = mysqli_query($plink, "SELECT 'works...' as _desc"))
+ printf("[005] Cannot run query, [%d] %s\n",
+ mysqli_errno($plink), mysqli_error($plink));
- $row = mysqli_fetch_assoc($res);
- mysqli_free_result($res);
- printf("Persistent connection 1 - '%s'\n", $row['_desc']);
+ $row = mysqli_fetch_assoc($res);
+ mysqli_free_result($res);
+ printf("Persistent connection 1 - '%s'\n", $row['_desc']);
- if (!$plink2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- printf("[006] Cannot create persistent connection using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
- $host, $user, $db, $port, $socket,
- mysqli_connect_errno(), mysqli_connect_error());
+ if (!$plink2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[006] Cannot create persistent connection using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
+ $host, $user, $db, $port, $socket,
+ mysqli_connect_errno(), mysqli_connect_error());
- if (!$res = mysqli_query($plink2, "SELECT 'works...' as _desc"))
- printf("[007] Cannot run query, [%d] %s\n",
- mysqli_errno($plink2), mysqli_error($plink2));
+ if (!$res = mysqli_query($plink2, "SELECT 'works...' as _desc"))
+ printf("[007] Cannot run query, [%d] %s\n",
+ mysqli_errno($plink2), mysqli_error($plink2));
- $row = mysqli_fetch_assoc($res);
- mysqli_free_result($res);
- printf("Persistent connection 2 - '%s'\n", $row['_desc']);
+ $row = mysqli_fetch_assoc($res);
+ mysqli_free_result($res);
+ printf("Persistent connection 2 - '%s'\n", $row['_desc']);
- $plink3 = mysqli_init();
- if (!my_mysqli_real_connect($plink3, $host, $user, $passwd, $db, $port, $socket))
- printf("[008] Cannot create persistent connection using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
- $host, $user, $db, $port, $socket,
- mysqli_connect_errno(), mysqli_connect_error());
+ $plink3 = mysqli_init();
+ if (!my_mysqli_real_connect($plink3, $host, $user, $passwd, $db, $port, $socket))
+ printf("[008] Cannot create persistent connection using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
+ $host, $user, $db, $port, $socket,
+ mysqli_connect_errno(), mysqli_connect_error());
- if (!$res = mysqli_query($plink3, "SELECT 'works...' as _desc"))
- printf("[009] Cannot run query, [%d] %s\n",
- mysqli_errno($plink2), mysqli_error($plink2));
+ if (!$res = mysqli_query($plink3, "SELECT 'works...' as _desc"))
+ printf("[009] Cannot run query, [%d] %s\n",
+ mysqli_errno($plink2), mysqli_error($plink2));
- $row = mysqli_fetch_assoc($res);
- mysqli_free_result($res);
- printf("Persistent connection 3 - '%s'\n", $row['_desc']);
+ $row = mysqli_fetch_assoc($res);
+ mysqli_free_result($res);
+ printf("Persistent connection 3 - '%s'\n", $row['_desc']);
- mysqli_close($link);
- mysqli_close($link2);
- mysqli_close($plink);
- mysqli_close($plink2);
- mysqli_close($plink3);
- print "done!";
+ mysqli_close($link);
+ mysqli_close($link2);
+ mysqli_close($plink);
+ mysqli_close($plink2);
+ mysqli_close($plink3);
+ print "done!";
?>
--CLEAN--
<?php
Persistent connections and mysqli.max_links
--SKIPIF--
<?php
- require_once('skipif.inc');
- require_once('skipifemb.inc');
- require_once('skipifconnectfailure.inc');
- require_once('table.inc');
-
- mysqli_query($link, 'DROP USER pcontest');
- mysqli_query($link, 'DROP USER pcontest@localhost');
-
- if (!mysqli_query($link, 'CREATE USER pcontest@"%" IDENTIFIED BY "pcontest"') ||
- !mysqli_query($link, 'CREATE USER pcontest@localhost IDENTIFIED BY "pcontest"')) {
- printf("skip Cannot create second DB user [%d] %s", mysqli_errno($link), mysqli_error($link));
- mysqli_close($link);
- die("skip CREATE USER failed");
- }
-
- // we might be able to specify the host using CURRENT_USER(), but...
- if (!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("skip Cannot GRANT SELECT to second DB user [%d] %s", mysqli_errno($link), mysqli_error($link));
- 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');
- mysqli_query($link, 'DROP USER pcontest');
- mysqli_close($link);
- die("skip GRANT failed");
- }
-
- if (!($link_pcontest = @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');
- mysqli_query($link, 'DROP USER pcontest');
- mysqli_close($link);
- die("skip CONNECT using new user failed");
+ require_once('skipif.inc');
+ require_once('skipifemb.inc');
+ require_once('skipifconnectfailure.inc');
+ require_once('table.inc');
+
+ mysqli_query($link, 'DROP USER pcontest');
+ mysqli_query($link, 'DROP USER pcontest@localhost');
+
+ if (!mysqli_query($link, 'CREATE USER pcontest@"%" IDENTIFIED BY "pcontest"') ||
+ !mysqli_query($link, 'CREATE USER pcontest@localhost IDENTIFIED BY "pcontest"')) {
+ printf("skip Cannot create second DB user [%d] %s", mysqli_errno($link), mysqli_error($link));
+ mysqli_close($link);
+ die("skip CREATE USER failed");
}
- mysqli_close($link);
+
+ // we might be able to specify the host using CURRENT_USER(), but...
+ if (!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("skip Cannot GRANT SELECT to second DB user [%d] %s", mysqli_errno($link), mysqli_error($link));
+ 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');
+ mysqli_query($link, 'DROP USER pcontest');
+ mysqli_close($link);
+ die("skip GRANT failed");
+ }
+
+ if (!($link_pcontest = @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');
+ mysqli_query($link, 'DROP USER pcontest');
+ mysqli_close($link);
+ die("skip CONNECT using new user failed");
+ }
+ mysqli_close($link);
?>
--INI--
mysqli.allow_persistent=1
mysqli.rollback_on_cached_plink=1
--FILE--
<?php
- require_once("connect.inc");
- require_once('table.inc');
-
-
- if (!mysqli_query($link, 'DROP USER pcontest') ||
- !mysqli_query($link, 'DROP USER pcontest@localhost') ||
- !mysqli_query($link, 'CREATE USER pcontest@"%" IDENTIFIED BY "pcontest"') ||
- !mysqli_query($link, 'CREATE USER pcontest@localhost IDENTIFIED BY "pcontest"') ||
- !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));
- }
-
- var_dump(mysqli_get_links_stats(1));
-
- echo "Before pconnect:";
- var_dump(mysqli_get_links_stats());
-
- if (!$plink = my_mysqli_connect('p:' . $host, 'pcontest', 'pcontest', $db, $port, $socket))
- printf("[001] Cannot connect using the second DB user created during SKIPIF, [%d] %s\n",
- mysqli_connect_errno(), mysqli_connect_error());
-
- echo "After pconnect:";
- var_dump(mysqli_get_links_stats());
-
- ob_start();
- phpinfo();
- $phpinfo = strip_tags(ob_get_contents());
- ob_end_clean();
-
- $phpinfo = substr($phpinfo, strpos($phpinfo, 'MysqlI Support => enabled'), 500);
- if (!preg_match('@Active Persistent Links\s+=>\s+(\d+)@ismU', $phpinfo, $matches))
- printf("[002] Cannot get # active persistent links from phpinfo()\n");
- $num_plinks = $matches[1];
-
- if (!$res = mysqli_query($plink, 'SELECT id, label FROM test WHERE id = 1'))
- printf("[003] Cannot run query on persistent connection of second DB user, [%d] %s\n",
- mysqli_errno($plink), mysqli_error($plink));
-
- if (!$row = mysqli_fetch_assoc($res))
- printf("[004] Cannot run fetch result, [%d] %s\n",
- mysqli_errno($plink), mysqli_error($plink));
- mysqli_free_result($res);
- var_dump($row);
-
- // change the password for the second DB user and kill the persistent connection
- if ((!mysqli_query($link, 'SET PASSWORD FOR pcontest = "newpass"') &&
- !mysqli_query($link, 'SET PASSWORD FOR pcontest = PASSWORD("newpass")'))||
- !mysqli_query($link, 'FLUSH PRIVILEGES'))
- printf("[005] Cannot change PW of second DB user, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ require_once("connect.inc");
+ require_once('table.inc');
+
+
+ if (!mysqli_query($link, 'DROP USER pcontest') ||
+ !mysqli_query($link, 'DROP USER pcontest@localhost') ||
+ !mysqli_query($link, 'CREATE USER pcontest@"%" IDENTIFIED BY "pcontest"') ||
+ !mysqli_query($link, 'CREATE USER pcontest@localhost IDENTIFIED BY "pcontest"') ||
+ !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));
+ }
+
+ var_dump(mysqli_get_links_stats(1));
+
+ echo "Before pconnect:";
+ var_dump(mysqli_get_links_stats());
+
+ if (!$plink = my_mysqli_connect('p:' . $host, 'pcontest', 'pcontest', $db, $port, $socket))
+ printf("[001] Cannot connect using the second DB user created during SKIPIF, [%d] %s\n",
+ mysqli_connect_errno(), mysqli_connect_error());
+
+ echo "After pconnect:";
+ var_dump(mysqli_get_links_stats());
+
+ ob_start();
+ phpinfo();
+ $phpinfo = strip_tags(ob_get_contents());
+ ob_end_clean();
+
+ $phpinfo = substr($phpinfo, strpos($phpinfo, 'MysqlI Support => enabled'), 500);
+ if (!preg_match('@Active Persistent Links\s+=>\s+(\d+)@ismU', $phpinfo, $matches))
+ printf("[002] Cannot get # active persistent links from phpinfo()\n");
+ $num_plinks = $matches[1];
+
+ if (!$res = mysqli_query($plink, 'SELECT id, label FROM test WHERE id = 1'))
+ printf("[003] Cannot run query on persistent connection of second DB user, [%d] %s\n",
+ mysqli_errno($plink), mysqli_error($plink));
+
+ if (!$row = mysqli_fetch_assoc($res))
+ printf("[004] Cannot run fetch result, [%d] %s\n",
+ mysqli_errno($plink), mysqli_error($plink));
+ mysqli_free_result($res);
+ var_dump($row);
+
+ // change the password for the second DB user and kill the persistent connection
+ if ((!mysqli_query($link, 'SET PASSWORD FOR pcontest = "newpass"') &&
+ !mysqli_query($link, 'SET PASSWORD FOR pcontest = PASSWORD("newpass")'))||
+ !mysqli_query($link, 'FLUSH PRIVILEGES'))
+ printf("[005] Cannot change PW of second DB user, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
// change the password for the second DB user and kill the persistent connection
- if ((!mysqli_query($link, 'SET PASSWORD FOR pcontest@localhost = "newpass"') &&
- !mysqli_query($link, 'SET PASSWORD FOR pcontest@localhost = PASSWORD("newpass")')) ||
- !mysqli_query($link, 'FLUSH PRIVILEGES'))
- printf("[006] Cannot change PW of second DB user, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
- // persistent connections cannot be closed but only be killed
- $pthread_id = mysqli_thread_id($plink);
- if (!mysqli_query($link, sprintf('KILL %d', $pthread_id)))
- printf("[007] Cannot KILL persistent connection of second DB user, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- // give the server a second to really kill the thread
- sleep(1);
-
- if (!$res = mysqli_query($link, "SHOW FULL PROCESSLIST"))
- printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
- $running_threads = array();
- while ($row = mysqli_fetch_assoc($res))
- $running_threads[$row['Id']] = $row;
- mysqli_free_result($res);
-
- if (isset($running_threads[$pthread_id]))
- printf("[009] Persistent connection has not been killed\n");
-
- echo "Before second pconnect:";
- var_dump(mysqli_get_links_stats());
-
- // this fails and we have 0 (<= $num_plinks) 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));
-
- echo "After second pconnect:";
- var_dump(mysqli_get_links_stats());
-
- ob_start();
- phpinfo();
- $phpinfo = strip_tags(ob_get_contents());
- ob_end_clean();
- $phpinfo = substr($phpinfo, stripos($phpinfo, 'MysqlI Support => enabled'), 500);
- if (!preg_match('@Active Persistent Links\s+=>\s+(\d+)@ismU', $phpinfo, $matches))
- printf("[010] Cannot get # of active persistent links from phpinfo()\n");
-
- var_dump(mysqli_get_links_stats());
-
- $num_plinks_kill = $matches[1];
- $sstats = mysqli_get_links_stats();
- if ($sstats['active_plinks'] != $num_plinks_kill) {
- printf("[010.2] Num of active plinks differ %s %s\n", $sstats['active_plinks'], $num_plinks_kill);
- }
- if ($num_plinks_kill > $num_plinks)
- printf("[011] Expecting Active Persistent Links < %d, got %d\n", $num_plinks, $num_plinks_kill);
-
- if (!$plink = my_mysqli_connect('p:' . $host, 'pcontest', 'newpass', $db, $port, $socket))
- printf("[012] Cannot connect using the new password, [%d] %s\n",
- mysqli_connect_errno(), mysqli_connect_error());
-
- if (!$res = mysqli_query($plink, 'SELECT id, label FROM test WHERE id = 1'))
- printf("[013] Cannot run query on persistent connection of second DB user, [%d] %s\n",
- mysqli_errno($plink), mysqli_error($plink));
-
- if (!$row = mysqli_fetch_assoc($res))
- printf("[014] Cannot run fetch result, [%d] %s\n",
- mysqli_errno($plink), mysqli_error($plink));
- mysqli_free_result($res);
- var_dump($row);
-
- 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());
- var_dump(mysqli_get_links_stats());
- }
-
- ob_start();
- phpinfo();
- $phpinfo = strip_tags(ob_get_contents());
- ob_end_clean();
- $phpinfo = substr($phpinfo, stripos($phpinfo, 'MysqlI Support => enabled'), 500);
- if (!preg_match('@Active Persistent Links\s+=>\s+(\d+)@ismU', $phpinfo, $matches))
- printf("[016] Cannot get # of active persistent links from phpinfo()\n");
-
- $num_plinks = $matches[1];
- if ($num_plinks > (int)ini_get('mysqli.max_persistent'))
- printf("[017] mysqli.max_persistent=%d allows %d open connections!\n", ini_get('mysqli.max_persistent'),$num_plinks);
-
- mysqli_query($link, 'REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest');
- mysqli_query($link, 'DROP USER pcontest');
- mysqli_close($link);
- print "done!";
+ if ((!mysqli_query($link, 'SET PASSWORD FOR pcontest@localhost = "newpass"') &&
+ !mysqli_query($link, 'SET PASSWORD FOR pcontest@localhost = PASSWORD("newpass")')) ||
+ !mysqli_query($link, 'FLUSH PRIVILEGES'))
+ printf("[006] Cannot change PW of second DB user, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ // persistent connections cannot be closed but only be killed
+ $pthread_id = mysqli_thread_id($plink);
+ if (!mysqli_query($link, sprintf('KILL %d', $pthread_id)))
+ printf("[007] Cannot KILL persistent connection of second DB user, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ // give the server a second to really kill the thread
+ sleep(1);
+
+ if (!$res = mysqli_query($link, "SHOW FULL PROCESSLIST"))
+ printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ $running_threads = array();
+ while ($row = mysqli_fetch_assoc($res))
+ $running_threads[$row['Id']] = $row;
+ mysqli_free_result($res);
+
+ if (isset($running_threads[$pthread_id]))
+ printf("[009] Persistent connection has not been killed\n");
+
+ echo "Before second pconnect:";
+ var_dump(mysqli_get_links_stats());
+
+ // this fails and we have 0 (<= $num_plinks) 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));
+
+ echo "After second pconnect:";
+ var_dump(mysqli_get_links_stats());
+
+ ob_start();
+ phpinfo();
+ $phpinfo = strip_tags(ob_get_contents());
+ ob_end_clean();
+ $phpinfo = substr($phpinfo, stripos($phpinfo, 'MysqlI Support => enabled'), 500);
+ if (!preg_match('@Active Persistent Links\s+=>\s+(\d+)@ismU', $phpinfo, $matches))
+ printf("[010] Cannot get # of active persistent links from phpinfo()\n");
+
+ var_dump(mysqli_get_links_stats());
+
+ $num_plinks_kill = $matches[1];
+ $sstats = mysqli_get_links_stats();
+ if ($sstats['active_plinks'] != $num_plinks_kill) {
+ printf("[010.2] Num of active plinks differ %s %s\n", $sstats['active_plinks'], $num_plinks_kill);
+ }
+ if ($num_plinks_kill > $num_plinks)
+ printf("[011] Expecting Active Persistent Links < %d, got %d\n", $num_plinks, $num_plinks_kill);
+
+ if (!$plink = my_mysqli_connect('p:' . $host, 'pcontest', 'newpass', $db, $port, $socket))
+ printf("[012] Cannot connect using the new password, [%d] %s\n",
+ mysqli_connect_errno(), mysqli_connect_error());
+
+ if (!$res = mysqli_query($plink, 'SELECT id, label FROM test WHERE id = 1'))
+ printf("[013] Cannot run query on persistent connection of second DB user, [%d] %s\n",
+ mysqli_errno($plink), mysqli_error($plink));
+
+ if (!$row = mysqli_fetch_assoc($res))
+ printf("[014] Cannot run fetch result, [%d] %s\n",
+ mysqli_errno($plink), mysqli_error($plink));
+ mysqli_free_result($res);
+ var_dump($row);
+
+ 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());
+ var_dump(mysqli_get_links_stats());
+ }
+
+ ob_start();
+ phpinfo();
+ $phpinfo = strip_tags(ob_get_contents());
+ ob_end_clean();
+ $phpinfo = substr($phpinfo, stripos($phpinfo, 'MysqlI Support => enabled'), 500);
+ if (!preg_match('@Active Persistent Links\s+=>\s+(\d+)@ismU', $phpinfo, $matches))
+ printf("[016] Cannot get # of active persistent links from phpinfo()\n");
+
+ $num_plinks = $matches[1];
+ if ($num_plinks > (int)ini_get('mysqli.max_persistent'))
+ printf("[017] mysqli.max_persistent=%d allows %d open connections!\n", ini_get('mysqli.max_persistent'),$num_plinks);
+
+ mysqli_query($link, 'REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest');
+ mysqli_query($link, 'DROP USER pcontest');
+ mysqli_close($link);
+ print "done!";
?>
--CLEAN--
<?php
mysqli.max_links=2
--FILE--
<?php
- require_once("connect.inc");
-
- $host = 'p:' . $host;
- if (!$link1 = 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, [%d] %s\n",
- $host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error());
- }
- if (!mysqli_query($link1, 'SET @pcondisabled = "Connection 1"'))
- printf("[002] Cannot set user variable to check if we got the same persistent connection, [%d] %s\n",
- mysqli_errno($link1), mysqli_error($link1));
-
- if (!$link2 = 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, [%d] %s\n",
- $host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error());
- }
-
- if (!$res = mysqli_query($link1, 'SELECT @pcondisabled AS _test'))
- printf("[004] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2));
-
- $row = mysqli_fetch_assoc($res);
- printf("Connection 1 - SELECT @pcondisabled -> '%s'\n", $row['_test']);
- mysqli_free_result($res);
-
- if (!$res = mysqli_query($link2, 'SELECT @pcondisabled AS _test'))
- printf("[005] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2));
-
- $row = mysqli_fetch_assoc($res);
- printf("Connection 2 (no reuse) - SELECT @pcondisabled -> '%s'\n", $row['_test']);
- $thread_id = mysqli_thread_id($link2);
- printf("Connection 2 (no reuse) - Thread ID -> '%s'\n", $thread_id);
- mysqli_free_result($res);
-
- if (!mysqli_query($link2, 'SET @pcondisabled = "Connection 2"'))
- printf("[006] Cannot set user variable to check if we got the same persistent connection, [%d] %s\n",
- mysqli_errno($link2), mysqli_error($link2));
-
- if (!$res = mysqli_query($link2, 'SELECT @pcondisabled AS _test'))
- printf("[007] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2));
-
- $row = mysqli_fetch_assoc($res);
- printf("Connection 2 - SELECT @pcondisabled -> '%s'\n", $row['_test']);
- mysqli_free_result($res);
-
- mysqli_close($link2);
-
- /* reuse of existing persistent connection expected! */
- if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- printf("[008] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
- $host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error());
- }
-
- if (!$res = mysqli_query($link2, 'SELECT @pcondisabled AS _test'))
- printf("[009] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2));
-
- $row = mysqli_fetch_assoc($res);
- printf("Connection 2 (reuse) - SELECT @pcondisabled -> '%s'\n", $row['_test']);
- $thread_id_reuse = mysqli_thread_id($link2);
- printf("Connection 2 (reuse) - Thread ID -> '%s'\n", $thread_id_reuse);
- mysqli_free_result($res);
-
- if ($thread_id != $thread_id_reuse)
- printf("[010] Seems as if we have got a new connection, connections should have been cached and reused!\n");
-
- mysqli_close($link1);
- mysqli_close($link2);
- print "done!";
+ require_once("connect.inc");
+
+ $host = 'p:' . $host;
+ if (!$link1 = 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, [%d] %s\n",
+ $host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error());
+ }
+ if (!mysqli_query($link1, 'SET @pcondisabled = "Connection 1"'))
+ printf("[002] Cannot set user variable to check if we got the same persistent connection, [%d] %s\n",
+ mysqli_errno($link1), mysqli_error($link1));
+
+ if (!$link2 = 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, [%d] %s\n",
+ $host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error());
+ }
+
+ if (!$res = mysqli_query($link1, 'SELECT @pcondisabled AS _test'))
+ printf("[004] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2));
+
+ $row = mysqli_fetch_assoc($res);
+ printf("Connection 1 - SELECT @pcondisabled -> '%s'\n", $row['_test']);
+ mysqli_free_result($res);
+
+ if (!$res = mysqli_query($link2, 'SELECT @pcondisabled AS _test'))
+ printf("[005] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2));
+
+ $row = mysqli_fetch_assoc($res);
+ printf("Connection 2 (no reuse) - SELECT @pcondisabled -> '%s'\n", $row['_test']);
+ $thread_id = mysqli_thread_id($link2);
+ printf("Connection 2 (no reuse) - Thread ID -> '%s'\n", $thread_id);
+ mysqli_free_result($res);
+
+ if (!mysqli_query($link2, 'SET @pcondisabled = "Connection 2"'))
+ printf("[006] Cannot set user variable to check if we got the same persistent connection, [%d] %s\n",
+ mysqli_errno($link2), mysqli_error($link2));
+
+ if (!$res = mysqli_query($link2, 'SELECT @pcondisabled AS _test'))
+ printf("[007] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2));
+
+ $row = mysqli_fetch_assoc($res);
+ printf("Connection 2 - SELECT @pcondisabled -> '%s'\n", $row['_test']);
+ mysqli_free_result($res);
+
+ mysqli_close($link2);
+
+ /* reuse of existing persistent connection expected! */
+ if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ printf("[008] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
+ $host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error());
+ }
+
+ if (!$res = mysqli_query($link2, 'SELECT @pcondisabled AS _test'))
+ printf("[009] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2));
+
+ $row = mysqli_fetch_assoc($res);
+ printf("Connection 2 (reuse) - SELECT @pcondisabled -> '%s'\n", $row['_test']);
+ $thread_id_reuse = mysqli_thread_id($link2);
+ printf("Connection 2 (reuse) - Thread ID -> '%s'\n", $thread_id_reuse);
+ mysqli_free_result($res);
+
+ if ($thread_id != $thread_id_reuse)
+ printf("[010] Seems as if we have got a new connection, connections should have been cached and reused!\n");
+
+ mysqli_close($link1);
+ mysqli_close($link2);
+ print "done!";
?>
--EXPECTF--
Connection 1 - SELECT @pcondisabled -> 'Connection 1'
mysqli.max_links=-1
--FILE--
<?php
- require_once("connect.inc");
+ require_once("connect.inc");
- $host = 'p:' . $host;
- 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);
+ $host = 'p:' . $host;
+ 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);
- if (true !== ($tmp = my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)))
- printf("[003] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
+ if (true !== ($tmp = my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)))
+ printf("[003] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
- /* it is undefined which pooled connection we get - thread ids may differ */
+ /* it is undefined which pooled connection we get - thread ids may differ */
- if (!($res = mysqli_query($link, "SELECT 'ok' AS it_works")) ||
- !($row = mysqli_fetch_assoc($res)))
- printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!($res = mysqli_query($link, "SELECT 'ok' AS it_works")) ||
+ !($row = mysqli_fetch_assoc($res)))
+ printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- var_dump($row);
- mysqli_free_result($res);
+ var_dump($row);
+ mysqli_free_result($res);
- mysqli_close($link);
+ mysqli_close($link);
- if (!$link = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
- printf("[007] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket);
+ if (!$link = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
+ printf("[007] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
- if (true !== ($tmp = $link->real_connect($host, $user, $passwd, $db, $port, $socket)))
- printf("[009] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
+ if (true !== ($tmp = $link->real_connect($host, $user, $passwd, $db, $port, $socket)))
+ printf("[009] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
- /* it is undefined which pooled connection we get - thread ids may differ */
+ /* it is undefined which pooled connection we get - thread ids may differ */
- if (!($res = $link->query("SELECT 'works also with oo' AS syntax")) ||
- !($row = $res->fetch_assoc()))
- printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!($res = $link->query("SELECT 'works also with oo' AS syntax")) ||
+ !($row = $res->fetch_assoc()))
+ printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- var_dump($row);
- mysqli_free_result($res);
+ var_dump($row);
+ mysqli_free_result($res);
- mysqli_close($link);
+ mysqli_close($link);
- if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
- printf("[013] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
+ if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
+ printf("[013] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- printf("[014] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket);
+ if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[014] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
- if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
- printf("[015] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
+ if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
+ printf("[015] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
- print "done!";
+ print "done!";
?>
--EXPECT--
array(1) {
require_once('skipifconnectfailure.inc');
if (!$IS_MYSQLND)
- die("skip mysqlnd only feature, compile PHP using --with-mysqli=mysqlnd");
+ die("skip mysqlnd only feature, compile PHP using --with-mysqli=mysqlnd");
?>
--FILE--
<?php
require_once('skipifconnectfailure.inc');
if (!$IS_MYSQLND)
- die("skip mysqlnd only feature, compile PHP using --with-mysqli=mysqlnd");
+ die("skip mysqlnd only feature, compile PHP using --with-mysqli=mysqlnd");
?>
--FILE--
<?php
require_once('skipifconnectfailure.inc');
if (!$IS_MYSQLND)
- die("skip mysqlnd only feature, compile PHP using --with-mysqli=mysqlnd");
+ die("skip mysqlnd only feature, compile PHP using --with-mysqli=mysqlnd");
?>
--FILE--
<?php
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "DROP TABLE IF EXISTS bogus"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_query($link, "DROP PROCEDURE IF EXISTS p");
require_once('skipifconnectfailure.inc');
if (!$IS_MYSQLND)
- die("skip mysqlnd only feature, compile PHP using --with-mysqli=mysqlnd");
+ die("skip mysqlnd only feature, compile PHP using --with-mysqli=mysqlnd");
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die("skip cannot connect");
+ die("skip cannot connect");
if (mysqli_get_server_version($link) < 50012)
- die("skip Test needs SQL function SLEEP() available as of MySQL 5.0.12");
+ die("skip Test needs SQL function SLEEP() available as of MySQL 5.0.12");
?>
--FILE--
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "DROP TABLE IF EXISTS test2"))
- printf("[c003] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c003] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
@mysqli_query($link, "DROP FUNCTION IF EXISTS f");
@mysqli_query($link, 'DROP PROCEDURE IF EXISTS p');
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
--- Testing default ---
require_once('skipifconnectfailure.inc');
require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
}
if (mysqli_get_server_version($link) <= 50000) {
- die(sprintf('skip Needs MySQL 5.0+, found version %d.', mysqli_get_server_version($link)));
+ die(sprintf('skip Needs MySQL 5.0+, found version %d.', mysqli_get_server_version($link)));
}
?>
--FILE--
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
@mysqli_query($link, "DROP PROCEDURE IS EXISTS p");
require_once('connect.inc');
require_once('table.inc');
if (!$res = mysqli_query($link, "SHOW CHARACTER SET LIKE 'utf8'"))
- die("skip UTF8 chatset seems not available");
+ die("skip UTF8 chatset seems not available");
mysqli_free_result($res);
mysqli_close($link);
?>
mysqli.allow_local_infile=1
--FILE--
<?php
- include("connect.inc");
-
- $tmp = NULL;
- $link = NULL;
-
- if (NULL !== ($tmp = @mysqli_real_connect($link)))
- printf("[001a] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
-
- if (NULL !== ($tmp = @mysqli_real_connect($link, $link)))
- printf("[001b] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
-
- if (NULL !== ($tmp = @mysqli_real_connect($link, $link, $link)))
- printf("[001c] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
-
- if (NULL !== ($tmp = @mysqli_real_connect($link, $link, $link, $link)))
- printf("[001d] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
-
- if (NULL !== ($tmp = @mysqli_real_connect($link, $link, $link, $link, $link)))
- printf("[001e] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
-
- if (NULL !== ($tmp = @mysqli_real_connect($link, $link, $link, $link, $link, $link)))
- printf("[001f] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
-
- if (NULL !== ($tmp = @mysqli_real_connect($link, $link, $link, $link, $link, $link, $link)))
- printf("[001g] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
-
- // ( mysqli link [, string hostname [, string username [, string passwd [, string dbname [, int port [, string socket [, int flags]]]]]]]
- if (NULL !== ($tmp = @mysqli_real_connect($link, $link, $link, $link, $link, $link, $link, $link)))
- printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
-
- if (!$link = mysqli_init())
- printf("[002] mysqli_init() failed\n");
-
- if (!mysqli_real_connect($link, $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);
-
- mysqli_close($link);
- if (!$link = mysqli_init())
- printf("[004] mysqli_init() failed\n");
-
- if (false !== ($tmp = mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)))
- printf("[005] Expecting boolean/false got %s/%s. Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", gettype($tmp), $tmp, $host, $user . 'unknown_really', $db, $port, $socket);
-
- // Run the following tests without an anoynmous MySQL user and use a password for the test user!
- ini_set('mysqli.default_socket', $socket);
- if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port)) {
- printf("[006] Usage of mysqli.default_socket failed\n");
- } else {
- mysqli_close($link);
- if (!$link = mysqli_init())
- printf("[007] mysqli_init() failed\n");
- }
-
- ini_set('mysqli.default_port', $port);
- if (!mysqli_real_connect($link, $host, $user, $passwd, $db)) {
- printf("[008] Usage of mysqli.default_port failed\n");
- } else {
- mysqli_close($link);
- if (!$link = mysqli_init())
- printf("[009] mysqli_init() failed\n");
- }
-
- ini_set('mysqli.default_pw', $passwd);
- if (!mysqli_real_connect($link, $host, $user)) {
- printf("[010] Usage of mysqli.default_pw failed\n") ;
- } else {
- mysqli_close($link);
- if (!$link = mysqli_init())
- printf("[011] mysqli_init() failed\n");
- }
-
- ini_set('mysqli.default_user', $user);
- if (!mysqli_real_connect($link, $host)) {
- printf("[012] Usage of mysqli.default_user failed\n") ;
- } else {
- mysqli_close($link);
- if (!$link = mysqli_init())
- printf("[011] mysqli_init() failed\n");
- }
-
- ini_set('mysqli.default_host', $host);
- if (!mysqli_real_connect($link)) {
- printf("[014] Usage of mysqli.default_host failed\n") ;
- } else {
- mysqli_close($link);
- if (!$link = mysqli_init())
- printf("[015] mysqli_init() failed\n");
- }
-
- // CLIENT_MULTI_STATEMENTS - should be disabled silently
- if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, 65536))
- printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
- if ($res = mysqli_query($link, "SELECT 1 AS a; SELECT 2 AS b")) {
- printf("[017] Should have failed. CLIENT_MULTI_STATEMENT should have been disabled.\n");
- var_dump($res->num_rows);
- mysqli_next_result($link);
- $res = mysqli_store_result($link);
- var_dump($res->num_rows);
- }
-
-
- mysqli_close($link);
- if (!$link = mysqli_init())
- printf("[018] mysqli_init() failed\n");
-
- if (ini_get('open_basedir')) {
- // CLIENT_LOCAL_FILES should be blocked - but how to test it ?!
-
- if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, 128))
- printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
- $filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'mysqli_real_connect_phpt';
- if (!$fp = fopen($filename, 'w'))
- printf("[020] Cannot open temporary file %s\n", $filename);
-
- fwrite($fp, '100;z');
- fclose($fp);
-
- // how do we test if gets forbidden because of a missing right or the flag, this test is partly bogus ?
- if (mysqli_query($link, "LOAD DATA LOCAL INFILE '$filename' INTO TABLE test FIELDS TERMINATED BY ';'"))
- printf("[021] LOAD DATA INFILE should have been forbidden!\n");
-
- unlink($filename);
- }
-
- 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:');
- $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);
- }
-
- if (false !== ($tmp = mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)))
- printf("[026] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
-
- print "done!";
+ include("connect.inc");
+
+ $tmp = NULL;
+ $link = NULL;
+
+ if (NULL !== ($tmp = @mysqli_real_connect($link)))
+ printf("[001a] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+ if (NULL !== ($tmp = @mysqli_real_connect($link, $link)))
+ printf("[001b] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+ if (NULL !== ($tmp = @mysqli_real_connect($link, $link, $link)))
+ printf("[001c] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+ if (NULL !== ($tmp = @mysqli_real_connect($link, $link, $link, $link)))
+ printf("[001d] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+ if (NULL !== ($tmp = @mysqli_real_connect($link, $link, $link, $link, $link)))
+ printf("[001e] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+ if (NULL !== ($tmp = @mysqli_real_connect($link, $link, $link, $link, $link, $link)))
+ printf("[001f] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+ if (NULL !== ($tmp = @mysqli_real_connect($link, $link, $link, $link, $link, $link, $link)))
+ printf("[001g] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+ // ( mysqli link [, string hostname [, string username [, string passwd [, string dbname [, int port [, string socket [, int flags]]]]]]]
+ if (NULL !== ($tmp = @mysqli_real_connect($link, $link, $link, $link, $link, $link, $link, $link)))
+ printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+ if (!$link = mysqli_init())
+ printf("[002] mysqli_init() failed\n");
+
+ if (!mysqli_real_connect($link, $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);
+
+ mysqli_close($link);
+ if (!$link = mysqli_init())
+ printf("[004] mysqli_init() failed\n");
+
+ if (false !== ($tmp = mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)))
+ printf("[005] Expecting boolean/false got %s/%s. Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", gettype($tmp), $tmp, $host, $user . 'unknown_really', $db, $port, $socket);
+
+ // Run the following tests without an anoynmous MySQL user and use a password for the test user!
+ ini_set('mysqli.default_socket', $socket);
+ if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port)) {
+ printf("[006] Usage of mysqli.default_socket failed\n");
+ } else {
+ mysqli_close($link);
+ if (!$link = mysqli_init())
+ printf("[007] mysqli_init() failed\n");
+ }
+
+ ini_set('mysqli.default_port', $port);
+ if (!mysqli_real_connect($link, $host, $user, $passwd, $db)) {
+ printf("[008] Usage of mysqli.default_port failed\n");
+ } else {
+ mysqli_close($link);
+ if (!$link = mysqli_init())
+ printf("[009] mysqli_init() failed\n");
+ }
+
+ ini_set('mysqli.default_pw', $passwd);
+ if (!mysqli_real_connect($link, $host, $user)) {
+ printf("[010] Usage of mysqli.default_pw failed\n") ;
+ } else {
+ mysqli_close($link);
+ if (!$link = mysqli_init())
+ printf("[011] mysqli_init() failed\n");
+ }
+
+ ini_set('mysqli.default_user', $user);
+ if (!mysqli_real_connect($link, $host)) {
+ printf("[012] Usage of mysqli.default_user failed\n") ;
+ } else {
+ mysqli_close($link);
+ if (!$link = mysqli_init())
+ printf("[011] mysqli_init() failed\n");
+ }
+
+ ini_set('mysqli.default_host', $host);
+ if (!mysqli_real_connect($link)) {
+ printf("[014] Usage of mysqli.default_host failed\n") ;
+ } else {
+ mysqli_close($link);
+ if (!$link = mysqli_init())
+ printf("[015] mysqli_init() failed\n");
+ }
+
+ // CLIENT_MULTI_STATEMENTS - should be disabled silently
+ if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, 65536))
+ printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if ($res = mysqli_query($link, "SELECT 1 AS a; SELECT 2 AS b")) {
+ printf("[017] Should have failed. CLIENT_MULTI_STATEMENT should have been disabled.\n");
+ var_dump($res->num_rows);
+ mysqli_next_result($link);
+ $res = mysqli_store_result($link);
+ var_dump($res->num_rows);
+ }
+
+
+ mysqli_close($link);
+ if (!$link = mysqli_init())
+ printf("[018] mysqli_init() failed\n");
+
+ if (ini_get('open_basedir')) {
+ // CLIENT_LOCAL_FILES should be blocked - but how to test it ?!
+
+ if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, 128))
+ printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ $filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'mysqli_real_connect_phpt';
+ if (!$fp = fopen($filename, 'w'))
+ printf("[020] Cannot open temporary file %s\n", $filename);
+
+ fwrite($fp, '100;z');
+ fclose($fp);
+
+ // how do we test if gets forbidden because of a missing right or the flag, this test is partly bogus ?
+ if (mysqli_query($link, "LOAD DATA LOCAL INFILE '$filename' INTO TABLE test FIELDS TERMINATED BY ';'"))
+ printf("[021] LOAD DATA INFILE should have been forbidden!\n");
+
+ unlink($filename);
+ }
+
+ 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:');
+ $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);
+ }
+
+ if (false !== ($tmp = mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)))
+ printf("[026] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
+
+ print "done!";
?>
--CLEAN--
<?php
require_once('skipifconnectfailure.inc');
require_once('connect.inc');
if (!$IS_MYSQLND)
- die("skip mysqlnd only test");
+ die("skip mysqlnd only test");
?>
--INI--
mysqli.allow_local_infile=1
mysqli.max_persistent=10
--FILE--
<?php
- require_once("connect.inc");
- $host = 'p:' . $host;
-
- if (!$link = mysqli_init())
- printf("[002] mysqli_init() failed\n");
-
- if (!mysqli_real_connect($link, $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);
-
- mysqli_close($link);
- if (!$link = mysqli_init())
- printf("[004] mysqli_init() failed\n");
-
- if (false !== ($tmp = mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)))
- printf("[005] Expecting boolean/false got %s/%s. Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", gettype($tmp), $tmp, $host, $user . 'unknown_really', $db, $port, $socket);
-
- // Run the following tests without an anoynmous MySQL user and use a password for the test user!
- ini_set('mysqli.default_socket', $socket);
- if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port)) {
- printf("[006] Usage of mysqli.default_socket failed\n");
- } else {
- mysqli_close($link);
- if (!$link = mysqli_init())
- printf("[007] mysqli_init() failed\n");
- }
-
- ini_set('mysqli.default_port', $port);
- if (!mysqli_real_connect($link, $host, $user, $passwd, $db)) {
- printf("[008] Usage of mysqli.default_port failed\n");
- } else {
- mysqli_close($link);
- if (!$link = mysqli_init())
- printf("[009] mysqli_init() failed\n");
- }
-
- ini_set('mysqli.default_pw', $passwd);
- if (!mysqli_real_connect($link, $host, $user)) {
- printf("[010] Usage of mysqli.default_pw failed\n") ;
- } else {
- mysqli_close($link);
- if (!$link = mysqli_init())
- printf("[011] mysqli_init() failed\n");
- }
-
- ini_set('mysqli.default_user', $user);
- if (!mysqli_real_connect($link, $host)) {
- printf("[012] Usage of mysqli.default_user failed\n") ;
- } else {
- mysqli_close($link);
- if (!$link = mysqli_init())
- printf("[011] mysqli_init() failed\n");
- }
-
- ini_set('mysqli.default_host', $host);
- if (!mysqli_real_connect($link)) {
- printf("[014] Usage of mysqli.default_host failed\n") ;
- } else {
- mysqli_close($link);
- if (!$link = mysqli_init())
- printf("[015] mysqli_init() failed\n");
- }
-
- // CLIENT_MULTI_STATEMENTS - should be disabled silently
- if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, 65536))
- printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
- if ($res = mysqli_query($link, "SELECT 1 AS a; SELECT 2 AS b")) {
- printf("[017] Should have failed. CLIENT_MULTI_STATEMENT should have been disabled.\n");
- var_dump($res->num_rows);
- mysqli_next_result($link);
- $res = mysqli_store_result($link);
- var_dump($res->num_rows);
- }
-
-
- mysqli_close($link);
- if (!$link = mysqli_init())
- printf("[018] mysqli_init() failed\n");
-
- if (ini_get('open_basedir')) {
- // CLIENT_LOCAL_FILES should be blocked - but how to test it ?!
-
- if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, 128))
- printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
- $filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'mysqli_real_connect_phpt';
- if (!$fp = fopen($filename, 'w'))
- printf("[020] Cannot open temporary file %s\n", $filename);
-
- fwrite($fp, '100;z');
- fclose($fp);
-
- // how do we test if gets forbidden because of a missing right or the flag, this test is partly bogus ?
- if (mysqli_query($link, "LOAD DATA LOCAL INFILE '$filename' INTO TABLE test FIELDS TERMINATED BY ';'"))
- printf("[021] LOAD DATA INFILE should have been forbidden!\n");
-
- unlink($filename);
- }
-
- 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);
- }
-
- 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)))
- printf("[026] Expecting not NULL, got %s/%s\n", gettype($tmp), $tmp);
-
- print "done!";
+ require_once("connect.inc");
+ $host = 'p:' . $host;
+
+ if (!$link = mysqli_init())
+ printf("[002] mysqli_init() failed\n");
+
+ if (!mysqli_real_connect($link, $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);
+
+ mysqli_close($link);
+ if (!$link = mysqli_init())
+ printf("[004] mysqli_init() failed\n");
+
+ if (false !== ($tmp = mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)))
+ printf("[005] Expecting boolean/false got %s/%s. Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", gettype($tmp), $tmp, $host, $user . 'unknown_really', $db, $port, $socket);
+
+ // Run the following tests without an anoynmous MySQL user and use a password for the test user!
+ ini_set('mysqli.default_socket', $socket);
+ if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port)) {
+ printf("[006] Usage of mysqli.default_socket failed\n");
+ } else {
+ mysqli_close($link);
+ if (!$link = mysqli_init())
+ printf("[007] mysqli_init() failed\n");
+ }
+
+ ini_set('mysqli.default_port', $port);
+ if (!mysqli_real_connect($link, $host, $user, $passwd, $db)) {
+ printf("[008] Usage of mysqli.default_port failed\n");
+ } else {
+ mysqli_close($link);
+ if (!$link = mysqli_init())
+ printf("[009] mysqli_init() failed\n");
+ }
+
+ ini_set('mysqli.default_pw', $passwd);
+ if (!mysqli_real_connect($link, $host, $user)) {
+ printf("[010] Usage of mysqli.default_pw failed\n") ;
+ } else {
+ mysqli_close($link);
+ if (!$link = mysqli_init())
+ printf("[011] mysqli_init() failed\n");
+ }
+
+ ini_set('mysqli.default_user', $user);
+ if (!mysqli_real_connect($link, $host)) {
+ printf("[012] Usage of mysqli.default_user failed\n") ;
+ } else {
+ mysqli_close($link);
+ if (!$link = mysqli_init())
+ printf("[011] mysqli_init() failed\n");
+ }
+
+ ini_set('mysqli.default_host', $host);
+ if (!mysqli_real_connect($link)) {
+ printf("[014] Usage of mysqli.default_host failed\n") ;
+ } else {
+ mysqli_close($link);
+ if (!$link = mysqli_init())
+ printf("[015] mysqli_init() failed\n");
+ }
+
+ // CLIENT_MULTI_STATEMENTS - should be disabled silently
+ if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, 65536))
+ printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if ($res = mysqli_query($link, "SELECT 1 AS a; SELECT 2 AS b")) {
+ printf("[017] Should have failed. CLIENT_MULTI_STATEMENT should have been disabled.\n");
+ var_dump($res->num_rows);
+ mysqli_next_result($link);
+ $res = mysqli_store_result($link);
+ var_dump($res->num_rows);
+ }
+
+
+ mysqli_close($link);
+ if (!$link = mysqli_init())
+ printf("[018] mysqli_init() failed\n");
+
+ if (ini_get('open_basedir')) {
+ // CLIENT_LOCAL_FILES should be blocked - but how to test it ?!
+
+ if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, 128))
+ printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ $filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'mysqli_real_connect_phpt';
+ if (!$fp = fopen($filename, 'w'))
+ printf("[020] Cannot open temporary file %s\n", $filename);
+
+ fwrite($fp, '100;z');
+ fclose($fp);
+
+ // how do we test if gets forbidden because of a missing right or the flag, this test is partly bogus ?
+ if (mysqli_query($link, "LOAD DATA LOCAL INFILE '$filename' INTO TABLE test FIELDS TERMINATED BY ';'"))
+ printf("[021] LOAD DATA INFILE should have been forbidden!\n");
+
+ unlink($filename);
+ }
+
+ 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);
+ }
+
+ 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)))
+ printf("[026] Expecting not NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+ print "done!";
?>
--CLEAN--
<?php
require_once('connect.inc');
if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- die(sprintf("skip Cannot connect to MySQL, [%d] %s\n",
- mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf("skip Cannot connect to MySQL, [%d] %s\n",
+ mysqli_connect_errno(), mysqli_connect_error()));
}
if (!mysqli_set_charset($link, 'big5'))
- die(sprintf("skip Cannot set charset 'big5'"));
+ die(sprintf("skip Cannot set charset 'big5'"));
mysqli_close($link);
?>
--FILE--
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
bool(true)
require_once('connect.inc');
if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- die(sprintf("skip Cannot connect to MySQL, [%d] %s\n",
- mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf("skip Cannot connect to MySQL, [%d] %s\n",
+ mysqli_connect_errno(), mysqli_connect_error()));
}
if (!mysqli_set_charset($link, 'eucjpms'))
- die(sprintf("skip Cannot set charset 'eucjpms'"));
+ die(sprintf("skip Cannot set charset 'eucjpms'"));
mysqli_close($link);
?>
--FILE--
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
bool(true)
require_once('connect.inc');
if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- die(sprintf("skip Cannot connect to MySQL, [%d] %s\n",
- mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf("skip Cannot connect to MySQL, [%d] %s\n",
+ mysqli_connect_errno(), mysqli_connect_error()));
}
if (!mysqli_set_charset($link, 'euckr'))
- die(sprintf("skip Cannot set charset 'euckr'"));
+ die(sprintf("skip Cannot set charset 'euckr'"));
mysqli_close($link);
?>
--FILE--
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
bool(true)
require_once('connect.inc');
if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- die(sprintf("skip Cannot connect to MySQL, [%d] %s\n",
- mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf("skip Cannot connect to MySQL, [%d] %s\n",
+ mysqli_connect_errno(), mysqli_connect_error()));
}
if (!mysqli_set_charset($link, 'gb2312'))
- die(sprintf("skip Cannot set charset 'gb2312'"));
+ die(sprintf("skip Cannot set charset 'gb2312'"));
mysqli_close($link);
?>
--FILE--
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
bool(true)
require_once('connect.inc');
if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- die(sprintf("skip Cannot connect to MySQL, [%d] %s\n",
- mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf("skip Cannot connect to MySQL, [%d] %s\n",
+ mysqli_connect_errno(), mysqli_connect_error()));
}
if (!mysqli_set_charset($link, 'gbk'))
- die(sprintf("skip Cannot set charset 'gbk'"));
+ die(sprintf("skip Cannot set charset 'gbk'"));
mysqli_close($link);
?>
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
bool(true)
require_once('connect.inc');
if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- die(sprintf("skip Cannot connect to MySQL, [%d] %s\n",
- mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf("skip Cannot connect to MySQL, [%d] %s\n",
+ mysqli_connect_errno(), mysqli_connect_error()));
}
if (!mysqli_set_charset($link, 'sjis'))
- die(sprintf("skip Cannot set charset 'sjis'"));
+ die(sprintf("skip Cannot set charset 'sjis'"));
mysqli_close($link);
?>
--FILE--
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_real_escape_string(): Couldn't fetch mysqli in %s on line %d
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
@mysqli_query($link, "DROP PROCEDURE IF EXISTS p");
@mysqli_query($link, "DROP FUNCTION IF EXISTS f");
require_once('skipifconnectfailure.inc');
if (!$IS_MYSQLND)
- die("skip mysqlnd only feature, compile PHP using --with-mysqli=mysqlnd");
+ die("skip mysqlnd only feature, compile PHP using --with-mysqli=mysqlnd");
?>
--FILE--
<?php
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
if (stristr(mysqli_get_client_info(), 'mysqlnd'))
- die("skip: test for libmysql");
+ die("skip: test for libmysql");
?>
--INI--
mysqli.reconnect=1
--FILE--
<?php
- require_once("connect.inc");
- require_once("table.inc");
+ require_once("connect.inc");
+ require_once("table.inc");
- if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- printf("[001] Cannot create second database connection, [%d] %s\n",
- mysqli_connect_errno(), mysqli_connect_error());
+ if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[001] Cannot create second database connection, [%d] %s\n",
+ mysqli_connect_errno(), mysqli_connect_error());
- $thread_id_timeout = mysqli_thread_id($link);
- $thread_id_control = mysqli_thread_id($link2);
+ $thread_id_timeout = mysqli_thread_id($link);
+ $thread_id_control = mysqli_thread_id($link2);
- if (!$res = mysqli_query($link2, "SHOW FULL PROCESSLIST"))
- printf("[002] Cannot get full processlist, [%d] %s\n",
- mysqli_errno($link2), mysqli_error($link));
-
- $running_threads = array();
- while ($row = mysqli_fetch_assoc($res))
- $running_threads[$row['Id']] = $row;
- mysqli_free_result($res);
-
- if (!isset($running_threads[$thread_id_timeout]) ||
- !isset($running_threads[$thread_id_control]))
- printf("[003] Processlist is borked, [%d] %s\n",
- mysqli_errno($link2), mysqli_error($link));
-
- if (!mysqli_query($link, "SET SESSION wait_timeout = 2"))
- printf("[004] Cannot set wait_timeout, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
- if (!$res = mysqli_query($link, "SHOW VARIABLES LIKE 'wait_timeout'"))
- printf("[005] Cannot check if wait_timeout has been set, [%d] %s\n",
- mysqli_errno($link), mysqli_error($link));
-
- if (!$row = mysqli_fetch_assoc($res))
- printf("[006] Cannot get wait_timeout, [%d] %s\n",
- mysqli_errno($link), mysqli_error($link));
- mysqli_free_result($res);
-
- if ($row['Value'] != 2)
- printf("[007] Failed setting the wait_timeout, test will not work, [%d] %s\n",
- mysqli_errno($link), mysqli_error($link));
-
- // after 2+ seconds the server should kill the connection
- sleep(3);
-
- if (!$res = mysqli_query($link2, "SHOW FULL PROCESSLIST"))
- printf("[008] Cannot get full processlist, [%d] %s\n",
- mysqli_errno($link2), mysqli_error($link));
-
- $running_threads = array();
- while ($row = mysqli_fetch_assoc($res))
- $running_threads[$row['Id']] = $row;
- mysqli_free_result($res);
-
- if (isset($running_threads[$thread_id_timeout]))
- printf("[009] Server should have killed the timeout connection, [%d] %s\n",
- mysqli_errno($link2), mysqli_error($link));
-
- if (true !== mysqli_ping($link))
- printf("[010] Reconnect should have happened");
-
- if (!$res = mysqli_query($link, "SELECT DATABASE() as _dbname"))
- printf("[011] Cannot get database name, [%d] %s\n",
- mysqli_errno($link), mysqli_error($link));
-
- if (!$row = mysqli_fetch_assoc($res))
- printf("[012] Cannot get database name, [%d] %s\n",
- mysqli_errno($link), mysqli_error($link));
-
- mysqli_free_result($res);
- if ($row['_dbname'] != $db)
- printf("[013] Connection should has been made to DB/Schema '%s', expecting '%s', [%d] %s\n",
- $row['_dbname'], $db, mysqli_errno($link), mysqli_error($link));
-
- // ... and now we try KILL
- $thread_id_timeout = mysqli_thread_id($link);
-
- if (!mysqli_query($link2, sprintf('KILL %d', $thread_id_timeout)))
- printf("[014] Cannot KILL timeout connection, [%d] %s\n", mysqli_errno($link2), mysqli_error($link2));
- // Give the server a second to really kill the other thread...
- sleep(1);
-
- if (!$res = mysqli_query($link2, "SHOW FULL PROCESSLIST"))
- printf("[015] Cannot get full processlist, [%d] %s\n",
- mysqli_errno($link2), mysqli_error($link));
-
- $running_threads = array();
- while ($row = mysqli_fetch_assoc($res))
- $running_threads[$row['Id']] = $row;
- mysqli_free_result($res);
-
- if (isset($running_threads[$thread_id_timeout]) ||
- !isset($running_threads[$thread_id_control]))
- printf("[016] Processlist is borked, [%d] %s\n",
- mysqli_errno($link2), mysqli_error($link));
-
- if (true !== ($tmp = mysqli_ping($link)))
- printf("[017] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
-
- if (!$res = mysqli_query($link, "SELECT DATABASE() as _dbname"))
- printf("[018] Cannot get database name, [%d] %s\n",
- mysqli_errno($link), mysqli_error($link));
-
- if (!$row = mysqli_fetch_assoc($res))
- printf("[019] Cannot get database name, [%d] %s\n",
- mysqli_errno($link), mysqli_error($link));
-
- mysqli_free_result($res);
- if ($row['_dbname'] != $db)
- printf("[020] Connection should has been made to DB/Schema '%s', expecting '%s', [%d] %s\n",
- $row['_dbname'], $db, mysqli_errno($link), mysqli_error($link));
-
- mysqli_close($link);
- mysqli_close($link2);
- print "done!";
+ if (!$res = mysqli_query($link2, "SHOW FULL PROCESSLIST"))
+ printf("[002] Cannot get full processlist, [%d] %s\n",
+ mysqli_errno($link2), mysqli_error($link));
+
+ $running_threads = array();
+ while ($row = mysqli_fetch_assoc($res))
+ $running_threads[$row['Id']] = $row;
+ mysqli_free_result($res);
+
+ if (!isset($running_threads[$thread_id_timeout]) ||
+ !isset($running_threads[$thread_id_control]))
+ printf("[003] Processlist is borked, [%d] %s\n",
+ mysqli_errno($link2), mysqli_error($link));
+
+ if (!mysqli_query($link, "SET SESSION wait_timeout = 2"))
+ printf("[004] Cannot set wait_timeout, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (!$res = mysqli_query($link, "SHOW VARIABLES LIKE 'wait_timeout'"))
+ printf("[005] Cannot check if wait_timeout has been set, [%d] %s\n",
+ mysqli_errno($link), mysqli_error($link));
+
+ if (!$row = mysqli_fetch_assoc($res))
+ printf("[006] Cannot get wait_timeout, [%d] %s\n",
+ mysqli_errno($link), mysqli_error($link));
+ mysqli_free_result($res);
+
+ if ($row['Value'] != 2)
+ printf("[007] Failed setting the wait_timeout, test will not work, [%d] %s\n",
+ mysqli_errno($link), mysqli_error($link));
+
+ // after 2+ seconds the server should kill the connection
+ sleep(3);
+
+ if (!$res = mysqli_query($link2, "SHOW FULL PROCESSLIST"))
+ printf("[008] Cannot get full processlist, [%d] %s\n",
+ mysqli_errno($link2), mysqli_error($link));
+
+ $running_threads = array();
+ while ($row = mysqli_fetch_assoc($res))
+ $running_threads[$row['Id']] = $row;
+ mysqli_free_result($res);
+
+ if (isset($running_threads[$thread_id_timeout]))
+ printf("[009] Server should have killed the timeout connection, [%d] %s\n",
+ mysqli_errno($link2), mysqli_error($link));
+
+ if (true !== mysqli_ping($link))
+ printf("[010] Reconnect should have happened");
+
+ if (!$res = mysqli_query($link, "SELECT DATABASE() as _dbname"))
+ printf("[011] Cannot get database name, [%d] %s\n",
+ mysqli_errno($link), mysqli_error($link));
+
+ if (!$row = mysqli_fetch_assoc($res))
+ printf("[012] Cannot get database name, [%d] %s\n",
+ mysqli_errno($link), mysqli_error($link));
+
+ mysqli_free_result($res);
+ if ($row['_dbname'] != $db)
+ printf("[013] Connection should has been made to DB/Schema '%s', expecting '%s', [%d] %s\n",
+ $row['_dbname'], $db, mysqli_errno($link), mysqli_error($link));
+
+ // ... and now we try KILL
+ $thread_id_timeout = mysqli_thread_id($link);
+
+ if (!mysqli_query($link2, sprintf('KILL %d', $thread_id_timeout)))
+ printf("[014] Cannot KILL timeout connection, [%d] %s\n", mysqli_errno($link2), mysqli_error($link2));
+ // Give the server a second to really kill the other thread...
+ sleep(1);
+
+ if (!$res = mysqli_query($link2, "SHOW FULL PROCESSLIST"))
+ printf("[015] Cannot get full processlist, [%d] %s\n",
+ mysqli_errno($link2), mysqli_error($link));
+
+ $running_threads = array();
+ while ($row = mysqli_fetch_assoc($res))
+ $running_threads[$row['Id']] = $row;
+ mysqli_free_result($res);
+
+ if (isset($running_threads[$thread_id_timeout]) ||
+ !isset($running_threads[$thread_id_control]))
+ printf("[016] Processlist is borked, [%d] %s\n",
+ mysqli_errno($link2), mysqli_error($link));
+
+ if (true !== ($tmp = mysqli_ping($link)))
+ printf("[017] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
+
+ if (!$res = mysqli_query($link, "SELECT DATABASE() as _dbname"))
+ printf("[018] Cannot get database name, [%d] %s\n",
+ mysqli_errno($link), mysqli_error($link));
+
+ if (!$row = mysqli_fetch_assoc($res))
+ printf("[019] Cannot get database name, [%d] %s\n",
+ mysqli_errno($link), mysqli_error($link));
+
+ mysqli_free_result($res);
+ if ($row['_dbname'] != $db)
+ printf("[020] Connection should has been made to DB/Schema '%s', expecting '%s', [%d] %s\n",
+ $row['_dbname'], $db, mysqli_errno($link), mysqli_error($link));
+
+ mysqli_close($link);
+ mysqli_close($link2);
+ print "done!";
?>
--EXPECT--
done!
require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
if (!have_innodb($link))
- die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
+ die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_release_savepoint(): Savepoint name cannot be empty in %s on line %d
require_once('skipifconnectfailure.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die(sprintf("SKIP Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket));
+ die(sprintf("SKIP Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket));
if (mysqli_get_server_version($link) < 50600)
- die("SKIP For MySQL >= 5.6.0");
+ die("SKIP For MySQL >= 5.6.0");
?>
--FILE--
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_change_user(): (%d/%d): Access denied for user '%s'@'%s' (using password: %s) in %s on line %d
require_once('skipifconnectfailure.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die(sprintf("SKIP Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket));
+ die(sprintf("SKIP Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket));
if (mysqli_get_server_version($link) >= 50600)
- die("SKIP For MySQL < 5.6.0");
+ die("SKIP For MySQL < 5.6.0");
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_multi_query(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'BAR; FOO' at line 1 in %s on line %d
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_result::__construct(): Invalid value for resultmode in %s on line %d
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
array(7) refcount(2){
require_once('connect.inc');
if (!$IS_MYSQLND)
- die("skip Test for mysqlnd only");
+ die("skip Test for mysqlnd only");
require_once('skipifemb.inc'); ?>
--FILE--
<?php
mysqli_rollback()
--SKIPIF--
<?php
- require_once('skipif.inc');
- require_once('skipifemb.inc');
- require_once('skipifconnectfailure.inc');
+ require_once('skipif.inc');
+ require_once('skipifemb.inc');
+ require_once('skipifconnectfailure.inc');
- require_once('connect.inc');
- if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
+ require_once('connect.inc');
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
- if (!have_innodb($link))
- die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
+ if (!have_innodb($link))
+ die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_rollback(): Couldn't fetch mysqli in %s on line %d
require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
if (!have_innodb($link))
- die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
+ die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_savepoint(): Savepoint name cannot be empty in %s on line %d
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_send_query')) {
- die("skip mysqli_send_query() not available");
+ die("skip mysqli_send_query() not available");
}
require_once('connect.inc');
if (!$TEST_EXPERIMENTAL)
- die("skip - experimental (= unsupported) feature");
+ die("skip - experimental (= unsupported) feature");
?>
--FILE--
<?php
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_set_charset'))
- die("skip Function not available");
+ die("skip Function not available");
require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
if (!($res = mysqli_query($link, 'SELECT version() AS server_version')) ||
- !($tmp = mysqli_fetch_assoc($res))) {
- mysqli_close($link);
- die(sprintf("skip Cannot check server version, [%d] %s\n",
- mysqli_errno($link), mysqli_error($link)));
+ !($tmp = mysqli_fetch_assoc($res))) {
+ mysqli_close($link);
+ die(sprintf("skip Cannot check server version, [%d] %s\n",
+ mysqli_errno($link), mysqli_error($link)));
}
mysqli_free_result($res);
$version = explode('.', $tmp['server_version']);
if (empty($version)) {
- mysqli_close($link);
- die(sprintf("skip Cannot check server version, based on '%s'",
- $tmp['server_version']));
+ mysqli_close($link);
+ die(sprintf("skip Cannot check server version, based on '%s'",
+ $tmp['server_version']));
}
if ($version[0] <= 4 && $version[1] < 1) {
- mysqli_close($link);
- die(sprintf("skip Requires MySQL Server 4.1+\n"));
+ mysqli_close($link);
+ die(sprintf("skip Requires MySQL Server 4.1+\n"));
}
if ((($res = mysqli_query($link, 'SHOW CHARACTER SET LIKE "latin1"', MYSQLI_STORE_RESULT)) &&
- (mysqli_num_rows($res) == 1)) ||
- (($res = mysqli_query($link, 'SHOW CHARACTER SET LIKE "latin2"', MYSQLI_STORE_RESULT)) &&
- (mysqli_num_rows($res) == 1))
- ) {
- // ok, required latin1 or latin2 are available
- mysqli_close($link);
+ (mysqli_num_rows($res) == 1)) ||
+ (($res = mysqli_query($link, 'SHOW CHARACTER SET LIKE "latin2"', MYSQLI_STORE_RESULT)) &&
+ (mysqli_num_rows($res) == 1))
+ ) {
+ // ok, required latin1 or latin2 are available
+ mysqli_close($link);
} else {
- die(sprintf("skip Requires character set latin1 or latin2\n"));
- mysqli_close($link);
+ die(sprintf("skip Requires character set latin1 or latin2\n"));
+ mysqli_close($link);
}
?>
--FILE--
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_set_charset(): Couldn't fetch mysqli in %s on line %d
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
NULL
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_ssl_set'))
- die("skip function not available");
+ die("skip function not available");
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
[009] [%d] (error message varies with the MySQL Server version, check the error code)
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_bind_param(): Number of elements in type definition string doesn't match number of bind variables in %s on line %d
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
Regular, procedural, using variables
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Test 1:
memory_limit=256M
--FILE--
<?php
- /*
- The way we test the INSERT and data types overlaps with
- the mysqli_stmt_bind_result test in large parts. There is only
- one difference. This test uses mysqli_query()/mysqli_fetch_assoc() to
- fetch the inserted values. This way we test
- mysqli_query()/mysqli_fetch_assoc() for all possible data types
- in this file and we test mysqli_stmt_bind_result() in the other
- test -- therefore the "duplicate" makes some sense to me.
- */
- require_once("connect.inc");
+ /*
+ The way we test the INSERT and data types overlaps with
+ the mysqli_stmt_bind_result test in large parts. There is only
+ one difference. This test uses mysqli_query()/mysqli_fetch_assoc() to
+ fetch the inserted values. This way we test
+ mysqli_query()/mysqli_fetch_assoc() for all possible data types
+ in this file and we test mysqli_stmt_bind_result() in the other
+ test -- therefore the "duplicate" makes some sense to me.
+ */
+ require_once("connect.inc");
- 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);
- exit(1);
- }
+ 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);
+ exit(1);
+ }
- $cols = 2500;
+ $cols = 2500;
- list($old_max_allowed_packet) = $link->query("SELECT @@max_allowed_packet")->fetch_row();
- if (!$link->query("SET GLOBAL max_allowed_packet=(2<<29)")) {
- if (1227 == mysqli_errno($link)) {
- /* [1227] Access denied; you need the SUPER privilege for this operation */
- $cols = 10;
- } else {
- $cols = 10;
- printf("[002] Failed to set max_allowed_packet the test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- }
- }
- mysqli_close($link);
+ list($old_max_allowed_packet) = $link->query("SELECT @@max_allowed_packet")->fetch_row();
+ if (!$link->query("SET GLOBAL max_allowed_packet=(2<<29)")) {
+ if (1227 == mysqli_errno($link)) {
+ /* [1227] Access denied; you need the SUPER privilege for this operation */
+ $cols = 10;
+ } else {
+ $cols = 10;
+ printf("[002] Failed to set max_allowed_packet the test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ }
+ }
+ mysqli_close($link);
- if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- printf("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);
- }
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ printf("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);
+ }
- if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) {
- printf("Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- exit(1);
- }
+ if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) {
+ printf("Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ exit(1);
+ }
- $str = array();
- for ($i = 1; $i <= $cols; $i++) {
- $str[] ="a$i BLOB";
- }
- $link->query("CREATE TABLE test(" . implode(" , ", $str) . ") ENGINE=MyISAM");
- if (mysqli_errno($link)) {
- printf("Failed to create the test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- die("");
- }
- $stmt = $link->prepare("INSERT INTO test VALUES(".str_repeat("?, ", $cols-1) . "?)");
- var_dump($stmt->id);
- $s = str_repeat("a", 2 << 12);
- $eval_str="\$stmt->bind_param(\"".str_repeat("s",$cols)."\", ";
- for ($i = 1; $i < $cols; $i++) {
- $eval_str.="\$s,";
- }
- $eval_str.="\$s";
- $eval_str.=");";
- eval($eval_str);
- printf("executing\n");
- if (!$stmt->execute()) {
- printf("failed");
- printf("Failed to execute: [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- } else {
- var_dump(true);
- }
+ $str = array();
+ for ($i = 1; $i <= $cols; $i++) {
+ $str[] ="a$i BLOB";
+ }
+ $link->query("CREATE TABLE test(" . implode(" , ", $str) . ") ENGINE=MyISAM");
+ if (mysqli_errno($link)) {
+ printf("Failed to create the test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ die("");
+ }
+ $stmt = $link->prepare("INSERT INTO test VALUES(".str_repeat("?, ", $cols-1) . "?)");
+ var_dump($stmt->id);
+ $s = str_repeat("a", 2 << 12);
+ $eval_str="\$stmt->bind_param(\"".str_repeat("s",$cols)."\", ";
+ for ($i = 1; $i < $cols; $i++) {
+ $eval_str.="\$s,";
+ }
+ $eval_str.="\$s";
+ $eval_str.=");";
+ eval($eval_str);
+ printf("executing\n");
+ if (!$stmt->execute()) {
+ printf("failed");
+ printf("Failed to execute: [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ } else {
+ var_dump(true);
+ }
- mysqli_stmt_close($stmt);
+ mysqli_stmt_close($stmt);
- if (!$link->query("SET GLOBAL max_allowed_packet=$old_max_allowed_packet")) {
- if (1227 != mysqli_errno($link))
- printf("Failed to set max_allowed_packet the test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- }
+ if (!$link->query("SET GLOBAL max_allowed_packet=$old_max_allowed_packet")) {
+ if (1227 != mysqli_errno($link))
+ printf("Failed to set max_allowed_packet the test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ }
- mysqli_close($link);
+ mysqli_close($link);
- print "done!";
+ print "done!";
?>
--CLEAN--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_bind_result() expects at least 2 parameters, 1 given in %s on line %d
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
memory_limit=83886080
--FILE--
<?php
- require_once("connect.inc");
-
- function create_table($link, $column, $min, $max, $engine, $offset) {
-
- if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) {
- printf("[%03d] Cannot drop table test, [%d] %s\n",
- $offset,
- mysqli_errno($link), mysqli_error($link));
- return array();
- }
-
- $sql = sprintf("CREATE TABLE test(id INT AUTO_INCREMENT PRIMARY KEY, col1 %s) ENGINE=%s",
- $column, $engine);
- if (!mysqli_query($link, $sql)) {
- printf("[%03d] Cannot create table test, [%d] %s\n",
- $offset + 1,
- mysqli_errno($link), mysqli_error($link));
- return array();
- }
-
- $values = array();
- for ($i = 1; $i <= 100; $i++) {
- $col1 = mt_rand($min, $max);
- $values[$i] = $col1;
- $sql = sprintf("INSERT INTO test(id, col1) VALUES (%d, %f)",
- $i, $col1);
- if (!mysqli_query($link, $sql)) {
- printf("[%03d] Cannot insert data, [%d] %s\n",
- $offset + 2,
- mysqli_errno($link), mysqli_error($link));
- return array();
- }
- }
-
- return $values;
- }
-
- function test_format($link, $format, $from, $order_by, $expected, $offset) {
-
- if (!$stmt = mysqli_stmt_init($link)) {
- printf("[%03d] Cannot create PS, [%d] %s\n",
- $offset,
- mysqli_errno($link), mysqli_error($link));
- return false;
- }
-
- if ($order_by)
- $sql = sprintf('SELECT %s AS _format FROM %s ORDER BY %s', $format, $from, $order_by);
- else
- $sql = sprintf('SELECT %s AS _format FROM %s', $format, $from);
-
- if (!mysqli_stmt_prepare($stmt, $sql)) {
- printf("[%03d] Cannot prepare PS, [%d] %s\n",
- $offset + 1,
- mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- return false;
- }
-
- if (!mysqli_stmt_execute($stmt)) {
- printf("[%03d] Cannot execute PS, [%d] %s\n",
- $offset + 2,
- mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- return false;
- }
-
- if (!mysqli_stmt_store_result($stmt)) {
- printf("[%03d] Cannot store result set, [%d] %s\n",
- $offset + 3,
- mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- return false;
- }
-
- if (!is_array($expected)) {
-
- $result = null;
- if (!mysqli_stmt_bind_result($stmt, $result)) {
- printf("[%03d] Cannot bind result, [%d] %s\n",
- $offset + 4,
- mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- return false;
- }
-
- if (!mysqli_stmt_fetch($stmt)) {
- printf("[%03d] Cannot fetch result,, [%d] %s\n",
- $offset + 5,
- mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- return false;
- }
-
- if ($result !== $expected) {
- printf("[%03d] Expecting %s/%s got %s/%s with %s - %s.\n",
- $offset + 6,
- gettype($expected), $expected,
- gettype($result), $result,
- $format, $sql);
- }
-
- } else {
-
- $order_by_col = $result = null;
- if (!mysqli_stmt_bind_result($stmt, $order_by_col, $result)) {
- printf("[%03d] Cannot bind result, [%d] %s\n",
- $offset + 7,
- mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- return false;
- }
-
- foreach ($expected as $k => $v) {
- if (!mysqli_stmt_fetch($stmt)) {
- break;
- }
- if ($result !== $v) {
- printf("[%03d] Row %d - expecting %s/%s got %s/%s [%s] with %s - %s.\n",
- $offset + 8,
- $k,
- gettype($v), $v,
- gettype($result), $result,
- $order_by_col,
- $format, $sql);
- }
- }
-
- }
-
- mysqli_stmt_free_result($stmt);
- mysqli_stmt_close($stmt);
-
- return true;
- }
-
- if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- printf("[001] Cannot connect - [%d] %s\n",
- mysqli_connect_errno(),
- mysqli_connect_error());
-
- /* select from dual - pseudo table */
- test_format($link, 'FORMAT(1.01, 0)', 'DUAL', null, '1', 10);
- test_format($link, 'FORMAT(1.23, 1)', 'DUAL', null, '1.2', 20);
- test_format($link, 'FORMAT(1.23, 2)', 'DUAL', null, '1.23', 30);
- test_format($link, 'FORMAT(1234.567, 3)', 'DUAL', null, '1,234.567', 40);
- /* no typo! */
- test_format($link, 'FORMAT(1234.567, 4)', 'DUAL', null, '1,234.5670', 50);
-
- mysqli_close($link);
- require_once('table.inc');
-
- /* select from existing table */
- test_format($link, 'FORMAT(id, 0)', 'test', null, '1', 60);
- test_format($link, 'FORMAT(id + 0.1, 1)', 'test', null, '1.1', 70);
- test_format($link, 'FORMAT(id + 0.01, 2)', 'test', null, '1.01', 80);
-
- /* create new table and select from it */
- $expected = create_table($link, 'FLOAT', -10000, 10000, $engine, 90);
- foreach ($expected as $k => $v)
- $expected[$k] = number_format(round($v), 0, '.', ',');
- test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 100);
-
- $expected = create_table($link, 'FLOAT UNSIGNED', 0, 10000, $engine, 110);
- foreach ($expected as $k => $v)
- $expected[$k] = number_format(round($v), 0, '.', ',');
- test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 120);
-
- $expected = create_table($link, 'TINYINT', -128, 127, $engine, 130);
- foreach ($expected as $k => $v)
- $expected[$k] = number_format(round($v), 0, '.', ',');
- test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 140);
-
- $expected = create_table($link, 'SMALLINT UNSIGNED', 0, 65535, $engine, 150);
- foreach ($expected as $k => $v)
- $expected[$k] = number_format(round($v), 0, '.', ',');
- test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 160);
-
- $expected = create_table($link, 'MEDIUMINT', 0, 8388607, $engine, 170);
- foreach ($expected as $k => $v)
- $expected[$k] = number_format(round($v), 0, '.', ',');
- test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 180);
-
- $expected = create_table($link, 'INT UNSIGNED', 0, 1000, $engine, 190);
- foreach ($expected as $k => $v)
- $expected[$k] = number_format(round($v), 0, '.', ',');
- test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 200);
-
- $expected = create_table($link, 'BIGINT', -1000, 1000, $engine, 210);
- foreach ($expected as $k => $v)
- $expected[$k] = number_format(round($v), 0, '.', ',');
- test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 220);
-
- $expected = create_table($link, 'DECIMAL(5,0)', -1000, 1000, $engine, 230);
- foreach ($expected as $k => $v)
- $expected[$k] = number_format(round($v), 0, '.', ',');
- test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 240);
-
- // http://bugs.php.net/bug.php?id=42378
- if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) {
- printf("[300] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- }
-
- if (mysqli_query($link, "CREATE TABLE `test` (
+ require_once("connect.inc");
+
+ function create_table($link, $column, $min, $max, $engine, $offset) {
+
+ if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) {
+ printf("[%03d] Cannot drop table test, [%d] %s\n",
+ $offset,
+ mysqli_errno($link), mysqli_error($link));
+ return array();
+ }
+
+ $sql = sprintf("CREATE TABLE test(id INT AUTO_INCREMENT PRIMARY KEY, col1 %s) ENGINE=%s",
+ $column, $engine);
+ if (!mysqli_query($link, $sql)) {
+ printf("[%03d] Cannot create table test, [%d] %s\n",
+ $offset + 1,
+ mysqli_errno($link), mysqli_error($link));
+ return array();
+ }
+
+ $values = array();
+ for ($i = 1; $i <= 100; $i++) {
+ $col1 = mt_rand($min, $max);
+ $values[$i] = $col1;
+ $sql = sprintf("INSERT INTO test(id, col1) VALUES (%d, %f)",
+ $i, $col1);
+ if (!mysqli_query($link, $sql)) {
+ printf("[%03d] Cannot insert data, [%d] %s\n",
+ $offset + 2,
+ mysqli_errno($link), mysqli_error($link));
+ return array();
+ }
+ }
+
+ return $values;
+ }
+
+ function test_format($link, $format, $from, $order_by, $expected, $offset) {
+
+ if (!$stmt = mysqli_stmt_init($link)) {
+ printf("[%03d] Cannot create PS, [%d] %s\n",
+ $offset,
+ mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+
+ if ($order_by)
+ $sql = sprintf('SELECT %s AS _format FROM %s ORDER BY %s', $format, $from, $order_by);
+ else
+ $sql = sprintf('SELECT %s AS _format FROM %s', $format, $from);
+
+ if (!mysqli_stmt_prepare($stmt, $sql)) {
+ printf("[%03d] Cannot prepare PS, [%d] %s\n",
+ $offset + 1,
+ mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ return false;
+ }
+
+ if (!mysqli_stmt_execute($stmt)) {
+ printf("[%03d] Cannot execute PS, [%d] %s\n",
+ $offset + 2,
+ mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ return false;
+ }
+
+ if (!mysqli_stmt_store_result($stmt)) {
+ printf("[%03d] Cannot store result set, [%d] %s\n",
+ $offset + 3,
+ mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ return false;
+ }
+
+ if (!is_array($expected)) {
+
+ $result = null;
+ if (!mysqli_stmt_bind_result($stmt, $result)) {
+ printf("[%03d] Cannot bind result, [%d] %s\n",
+ $offset + 4,
+ mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ return false;
+ }
+
+ if (!mysqli_stmt_fetch($stmt)) {
+ printf("[%03d] Cannot fetch result,, [%d] %s\n",
+ $offset + 5,
+ mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ return false;
+ }
+
+ if ($result !== $expected) {
+ printf("[%03d] Expecting %s/%s got %s/%s with %s - %s.\n",
+ $offset + 6,
+ gettype($expected), $expected,
+ gettype($result), $result,
+ $format, $sql);
+ }
+
+ } else {
+
+ $order_by_col = $result = null;
+ if (!mysqli_stmt_bind_result($stmt, $order_by_col, $result)) {
+ printf("[%03d] Cannot bind result, [%d] %s\n",
+ $offset + 7,
+ mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ return false;
+ }
+
+ foreach ($expected as $k => $v) {
+ if (!mysqli_stmt_fetch($stmt)) {
+ break;
+ }
+ if ($result !== $v) {
+ printf("[%03d] Row %d - expecting %s/%s got %s/%s [%s] with %s - %s.\n",
+ $offset + 8,
+ $k,
+ gettype($v), $v,
+ gettype($result), $result,
+ $order_by_col,
+ $format, $sql);
+ }
+ }
+
+ }
+
+ mysqli_stmt_free_result($stmt);
+ mysqli_stmt_close($stmt);
+
+ return true;
+ }
+
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[001] Cannot connect - [%d] %s\n",
+ mysqli_connect_errno(),
+ mysqli_connect_error());
+
+ /* select from dual - pseudo table */
+ test_format($link, 'FORMAT(1.01, 0)', 'DUAL', null, '1', 10);
+ test_format($link, 'FORMAT(1.23, 1)', 'DUAL', null, '1.2', 20);
+ test_format($link, 'FORMAT(1.23, 2)', 'DUAL', null, '1.23', 30);
+ test_format($link, 'FORMAT(1234.567, 3)', 'DUAL', null, '1,234.567', 40);
+ /* no typo! */
+ test_format($link, 'FORMAT(1234.567, 4)', 'DUAL', null, '1,234.5670', 50);
+
+ mysqli_close($link);
+ require_once('table.inc');
+
+ /* select from existing table */
+ test_format($link, 'FORMAT(id, 0)', 'test', null, '1', 60);
+ test_format($link, 'FORMAT(id + 0.1, 1)', 'test', null, '1.1', 70);
+ test_format($link, 'FORMAT(id + 0.01, 2)', 'test', null, '1.01', 80);
+
+ /* create new table and select from it */
+ $expected = create_table($link, 'FLOAT', -10000, 10000, $engine, 90);
+ foreach ($expected as $k => $v)
+ $expected[$k] = number_format(round($v), 0, '.', ',');
+ test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 100);
+
+ $expected = create_table($link, 'FLOAT UNSIGNED', 0, 10000, $engine, 110);
+ foreach ($expected as $k => $v)
+ $expected[$k] = number_format(round($v), 0, '.', ',');
+ test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 120);
+
+ $expected = create_table($link, 'TINYINT', -128, 127, $engine, 130);
+ foreach ($expected as $k => $v)
+ $expected[$k] = number_format(round($v), 0, '.', ',');
+ test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 140);
+
+ $expected = create_table($link, 'SMALLINT UNSIGNED', 0, 65535, $engine, 150);
+ foreach ($expected as $k => $v)
+ $expected[$k] = number_format(round($v), 0, '.', ',');
+ test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 160);
+
+ $expected = create_table($link, 'MEDIUMINT', 0, 8388607, $engine, 170);
+ foreach ($expected as $k => $v)
+ $expected[$k] = number_format(round($v), 0, '.', ',');
+ test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 180);
+
+ $expected = create_table($link, 'INT UNSIGNED', 0, 1000, $engine, 190);
+ foreach ($expected as $k => $v)
+ $expected[$k] = number_format(round($v), 0, '.', ',');
+ test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 200);
+
+ $expected = create_table($link, 'BIGINT', -1000, 1000, $engine, 210);
+ foreach ($expected as $k => $v)
+ $expected[$k] = number_format(round($v), 0, '.', ',');
+ test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 220);
+
+ $expected = create_table($link, 'DECIMAL(5,0)', -1000, 1000, $engine, 230);
+ foreach ($expected as $k => $v)
+ $expected[$k] = number_format(round($v), 0, '.', ',');
+ test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 240);
+
+ // http://bugs.php.net/bug.php?id=42378
+ if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) {
+ printf("[300] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ }
+
+ if (mysqli_query($link, "CREATE TABLE `test` (
`targetport` int(11) NOT NULL default '0',
`sources` double(17,4) default NULL,
`current_sources` double(17,4) default NULL,
PRIMARY KEY (`targetport`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1")) {
- do {
- $values = array();
- for ($i = 0; $i < 200; $i++) {
- $current_targets = mt_rand(-100000, 100000) / 10;
- do {
- $trend = (mt_rand(0, 3) > 1) ? (mt_rand(-10000, 10000) / 100) : 'NULL';
- } while (isset($values[$trend]));
-
- $sql = sprintf('INSERT INTO test(targetport, current_targets, maxreports, trend) VALUES (%d, %f, %s, %s)',
- $i,
- $current_targets,
- (mt_rand(0, 1) > 0) ? mt_rand(0, 1000) : 'NULL',
- $trend);
- if (!mysqli_query($link, $sql)) {
- printf("[301] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- break 2;
- }
- if ($current_targets > 0 && $trend !== 'NULL')
- $values[$trend] = $i;
- }
- krsort($values);
-
- if (!$stmt = mysqli_stmt_init($link)) {
- printf("[302] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- break;
- }
-
- if (!mysqli_stmt_prepare($stmt, 'SELECT trend, targetport, FORMAT(trend, 2) FROM test WHERE current_targets > 0 AND trend IS NOT NULL ORDER BY trend DESC LIMIT 100')) {
- printf("[303] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link));
- break;
- }
-
- if (!mysqli_stmt_execute($stmt)) {
- printf("[304] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link));
- break;
- }
-
- if (!mysqli_stmt_store_result($stmt)) {
- printf("[305] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link));
- break;
- }
-
- $trend = $targetport = $format = null;
- if (!mysqli_stmt_bind_result($stmt, $trend, $targetport, $format)) {
-
- printf("[305] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link));
- break;
- }
-
- foreach ($values as $exp_trend => $exp_targetport) {
- if (!mysqli_stmt_fetch($stmt)) {
- break;
- }
- if ($targetport != $exp_targetport) {
- printf("[306] Values fetched from MySQL seem to be wrong, check manually\n");
- printf("%s/%s - %s/%s - '%s'\n", $trend, $exp_trend, $targetport, $exp_targetport, $format);
- }
- }
- mysqli_stmt_free_result($stmt);
- mysqli_stmt_close($stmt);
-
- // same but OO interface
- if (!$stmt = mysqli_stmt_init($link)) {
- printf("[307] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- break;
- }
-
- if (!$stmt->prepare('SELECT trend, targetport, FORMAT(trend, 2) FROM test WHERE current_targets > 0 AND trend IS NOT NULL ORDER BY trend DESC LIMIT 100')) {
- printf("[308] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link));
- break;
- }
-
- if (!$stmt->execute()) {
- printf("[309] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link));
- break;
- }
-
- if (!$stmt->store_result()) {
- printf("[310] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link));
- break;
- }
-
- $trend = $targetport = $format = null;
- if (!$stmt->bind_result($trend, $targetport, $format)) {
-
- printf("[311] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link));
- break;
- }
-
- foreach ($values as $exp_trend => $exp_targetport) {
- if (!$stmt->fetch()) {
- break;
- }
- if ($targetport != $exp_targetport) {
- printf("[312] Values fetched from MySQL seem to be wrong, check manually\n");
- printf("%s/%s - %s/%s - '%s'\n", $trend, $exp_trend, $targetport, $exp_targetport, $format);
- }
- }
- $stmt->free_result();
- $stmt->close();
-
- } while (false);
-
- } else {
- var_dump(mysqli_error($link));
- }
-
-
- mysqli_close($link);
- print "done!";
+ do {
+ $values = array();
+ for ($i = 0; $i < 200; $i++) {
+ $current_targets = mt_rand(-100000, 100000) / 10;
+ do {
+ $trend = (mt_rand(0, 3) > 1) ? (mt_rand(-10000, 10000) / 100) : 'NULL';
+ } while (isset($values[$trend]));
+
+ $sql = sprintf('INSERT INTO test(targetport, current_targets, maxreports, trend) VALUES (%d, %f, %s, %s)',
+ $i,
+ $current_targets,
+ (mt_rand(0, 1) > 0) ? mt_rand(0, 1000) : 'NULL',
+ $trend);
+ if (!mysqli_query($link, $sql)) {
+ printf("[301] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ break 2;
+ }
+ if ($current_targets > 0 && $trend !== 'NULL')
+ $values[$trend] = $i;
+ }
+ krsort($values);
+
+ if (!$stmt = mysqli_stmt_init($link)) {
+ printf("[302] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ break;
+ }
+
+ if (!mysqli_stmt_prepare($stmt, 'SELECT trend, targetport, FORMAT(trend, 2) FROM test WHERE current_targets > 0 AND trend IS NOT NULL ORDER BY trend DESC LIMIT 100')) {
+ printf("[303] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link));
+ break;
+ }
+
+ if (!mysqli_stmt_execute($stmt)) {
+ printf("[304] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link));
+ break;
+ }
+
+ if (!mysqli_stmt_store_result($stmt)) {
+ printf("[305] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link));
+ break;
+ }
+
+ $trend = $targetport = $format = null;
+ if (!mysqli_stmt_bind_result($stmt, $trend, $targetport, $format)) {
+
+ printf("[305] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link));
+ break;
+ }
+
+ foreach ($values as $exp_trend => $exp_targetport) {
+ if (!mysqli_stmt_fetch($stmt)) {
+ break;
+ }
+ if ($targetport != $exp_targetport) {
+ printf("[306] Values fetched from MySQL seem to be wrong, check manually\n");
+ printf("%s/%s - %s/%s - '%s'\n", $trend, $exp_trend, $targetport, $exp_targetport, $format);
+ }
+ }
+ mysqli_stmt_free_result($stmt);
+ mysqli_stmt_close($stmt);
+
+ // same but OO interface
+ if (!$stmt = mysqli_stmt_init($link)) {
+ printf("[307] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ break;
+ }
+
+ if (!$stmt->prepare('SELECT trend, targetport, FORMAT(trend, 2) FROM test WHERE current_targets > 0 AND trend IS NOT NULL ORDER BY trend DESC LIMIT 100')) {
+ printf("[308] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link));
+ break;
+ }
+
+ if (!$stmt->execute()) {
+ printf("[309] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link));
+ break;
+ }
+
+ if (!$stmt->store_result()) {
+ printf("[310] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link));
+ break;
+ }
+
+ $trend = $targetport = $format = null;
+ if (!$stmt->bind_result($trend, $targetport, $format)) {
+
+ printf("[311] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link));
+ break;
+ }
+
+ foreach ($values as $exp_trend => $exp_targetport) {
+ if (!$stmt->fetch()) {
+ break;
+ }
+ if ($targetport != $exp_targetport) {
+ printf("[312] Values fetched from MySQL seem to be wrong, check manually\n");
+ printf("%s/%s - %s/%s - '%s'\n", $trend, $exp_trend, $targetport, $exp_targetport, $format);
+ }
+ }
+ $stmt->free_result();
+ $stmt->close();
+
+ } while (false);
+
+ } else {
+ var_dump(mysqli_error($link));
+ }
+
+
+ mysqli_close($link);
+ print "done!";
?>
--CLEAN--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
plain vanilla...
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_close(): invalid object or resource mysqli_stmt
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_data_seek(): invalid object or resource mysqli_stmt
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS type_change"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_errno(): Couldn't fetch mysqli_stmt in %s on line %d
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_error(): Couldn't fetch mysqli_stmt in %s on line %d
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
}
if (mysqli_get_server_version($link) <= 40100) {
- die(sprintf('skip Needs MySQL 4.1+, found version %d.', mysqli_get_server_version($link)));
+ die(sprintf('skip Needs MySQL 4.1+, found version %d.', mysqli_get_server_version($link)));
}
?>
--FILE--
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_execute(): invalid object or resource mysqli_stmt
require_once('skipifconnectfailure.inc');
require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
}
if (mysqli_get_server_version($link) <= 50000) {
- die(sprintf('skip Needs MySQL 5.0+, found version %d.', mysqli_get_server_version($link)));
+ die(sprintf('skip Needs MySQL 5.0+, found version %d.', mysqli_get_server_version($link)));
}
?>
--FILE--
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
- printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
@mysqli_query($link, 'DROP PROCEDURE IF EXISTS p');
require_once('skipifconnectfailure.inc');
require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
}
if (mysqli_get_server_version($link) < 50503) {
- die(sprintf('skip Needs MySQL 5.5.3+, found version %d.', mysqli_get_server_version($link)));
+ die(sprintf('skip Needs MySQL 5.5.3+, found version %d.', mysqli_get_server_version($link)));
}
?>
--FILE--
require_once('skipifconnectfailure.inc');
require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
}
if (mysqli_get_server_version($link) < 50503) {
- die(sprintf('skip Needs MySQL 5.5.3+, found version %d.', mysqli_get_server_version($link)));
+ die(sprintf('skip Needs MySQL 5.5.3+, found version %d.', mysqli_get_server_version($link)));
}
/*
if ($IS_MYSQLND) {
- die(sprintf("skip WHY ?!"));
+ die(sprintf("skip WHY ?!"));
}
*/
?>
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_fetch(): invalid object or resource mysqli_stmt
Fetching BIT column values using the PS API
--SKIPIF--
<?php
- require_once('skipif.inc');
- require_once('skipifemb.inc');
- require_once('skipifconnectfailure.inc');
- require_once('connect.inc');
- require_once('table.inc');
- if (mysqli_get_server_version($link) < 50003)
- // b'001' syntax not supported before 5.0.3
- die("skip Syntax used for test not supported with MySQL Server before 5.0.3");
- if (!$IS_MYSQLND && (mysqli_get_client_version() < 50003))
- // better don't trust libmysql before 5.0.3
- die("skip Syntax used for test not supported with MySQL Server before 5.0.3");
+ require_once('skipif.inc');
+ require_once('skipifemb.inc');
+ require_once('skipifconnectfailure.inc');
+ require_once('connect.inc');
+ require_once('table.inc');
+ if (mysqli_get_server_version($link) < 50003)
+ // b'001' syntax not supported before 5.0.3
+ die("skip Syntax used for test not supported with MySQL Server before 5.0.3");
+ if (!$IS_MYSQLND && (mysqli_get_client_version() < 50003))
+ // better don't trust libmysql before 5.0.3
+ die("skip Syntax used for test not supported with MySQL Server before 5.0.3");
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
OK: 1
mysqli_stmt_fetch - geometry / spatial types
--SKIPIF--
<?php
- require_once('skipif.inc');
- require_once('skipifemb.inc');
- require_once('skipifconnectfailure.inc');
+ require_once('skipif.inc');
+ require_once('skipifemb.inc');
+ require_once('skipifconnectfailure.inc');
- if (!defined("MYSQLI_TYPE_GEOMETRY"))
- die("skip MYSQLI_TYPE_GEOMETRY not defined");
+ if (!defined("MYSQLI_TYPE_GEOMETRY"))
+ die("skip MYSQLI_TYPE_GEOMETRY not defined");
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_field_count(): invalid object or resource mysqli_stmt
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_free_result(): invalid object or resource mysqli_stmt
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_stmt_get_result'))
- die('skip mysqli_stmt_get_result not available');
+ die('skip mysqli_stmt_get_result not available');
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_fetch(): invalid object or resource mysqli_stmt
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_stmt_get_result'))
- die('skip mysqli_stmt_get_result not available');
+ die('skip mysqli_stmt_get_result not available');
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
array(2) {
Fetching BIT column values using the PS API
--SKIPIF--
<?php
- require_once('skipif.inc');
- require_once('skipifemb.inc');
- require_once('skipifconnectfailure.inc');
-
- if (!function_exists('mysqli_stmt_get_result'))
- die("skip mysqli_stmt_get_result() not available");
-
- require_once('connect.inc');
- require_once('table.inc');
- if (mysqli_get_server_version($link) < 50003)
- // b'001' syntax not supported before 5.0.3
- die("skip Syntax used for test not supported with MySQL Server before 5.0.3");
- if (!$IS_MYSQLND && (mysqli_get_client_version() < 50003))
- // better don't trust libmysql before 5.0.3
- die("skip Syntax used for test not supported with MySQL Server before 5.0.3");
+ require_once('skipif.inc');
+ require_once('skipifemb.inc');
+ require_once('skipifconnectfailure.inc');
+
+ if (!function_exists('mysqli_stmt_get_result'))
+ die("skip mysqli_stmt_get_result() not available");
+
+ require_once('connect.inc');
+ require_once('table.inc');
+ if (mysqli_get_server_version($link) < 50003)
+ // b'001' syntax not supported before 5.0.3
+ die("skip Syntax used for test not supported with MySQL Server before 5.0.3");
+ if (!$IS_MYSQLND && (mysqli_get_client_version() < 50003))
+ // better don't trust libmysql before 5.0.3
+ die("skip Syntax used for test not supported with MySQL Server before 5.0.3");
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
mysqli_stmt_get_result() - meta data, field_count()
--SKIPIF--
<?php
- require_once('skipif.inc');
- require_once('skipifemb.inc');
- require_once('skipifconnectfailure.inc');
+ require_once('skipif.inc');
+ require_once('skipifemb.inc');
+ require_once('skipifconnectfailure.inc');
- if (!function_exists('mysqli_stmt_get_result'))
- die('skip mysqli_stmt_get_result not available');
+ if (!function_exists('mysqli_stmt_get_result'))
+ die('skip mysqli_stmt_get_result not available');
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
2 2
mysqli_stmt_get_result - geometry / spatial types
--SKIPIF--
<?php
- require_once('skipif.inc');
- require_once('skipifemb.inc');
- require_once('skipifconnectfailure.inc');
+ require_once('skipif.inc');
+ require_once('skipifemb.inc');
+ require_once('skipifconnectfailure.inc');
- if (!function_exists('mysqli_stmt_get_result'))
- die("skip mysqli_stmt_get_result() not available");
+ if (!function_exists('mysqli_stmt_get_result'))
+ die("skip mysqli_stmt_get_result() not available");
- if (!defined("MYSQLI_TYPE_GEOMETRY"))
- die("skip MYSQLI_TYPE_GEOMETRY not defined");
+ if (!defined("MYSQLI_TYPE_GEOMETRY"))
+ die("skip MYSQLI_TYPE_GEOMETRY not defined");
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_stmt_get_result'))
- die('skip mysqli_stmt_get_result not available');
+ die('skip mysqli_stmt_get_result not available');
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
array(2) {
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_stmt_get_result'))
- die('skip mysqli_stmt_get_result not available');
+ die('skip mysqli_stmt_get_result not available');
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
object(stdClass)#%d (13) {
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_stmt_get_result'))
- die('skip mysqli_stmt_get_result not available');
+ die('skip mysqli_stmt_get_result not available');
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_stmt_get_result'))
- die('skip mysqli_stmt_get_result not available');
+ die('skip mysqli_stmt_get_result not available');
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_result::data_seek() expects parameter 1 to be int, float given in %s on line %d
mysqli_stmt_get_result - data types
--SKIPIF--
<?php
- require_once('skipif.inc');
- require_once('skipifemb.inc');
- require_once('skipifconnectfailure.inc');
+ require_once('skipif.inc');
+ require_once('skipifemb.inc');
+ require_once('skipifconnectfailure.inc');
- if (!function_exists('mysqli_stmt_get_result'))
- die("skip mysqli_stmt_get_result() not available");
+ if (!function_exists('mysqli_stmt_get_result'))
+ die("skip mysqli_stmt_get_result() not available");
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
require_once("connect.inc");
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket));
+ die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket));
}
if (!mysqli_query($link, "DROP TABLE IF EXISTS test") ||
- !mysqli_query($link, "CREATE TABLE test(id SMALLINT)"))
- die(sprintf("skip [%d] %s\n", $link->errno, $link->error));
+ !mysqli_query($link, "CREATE TABLE test(id SMALLINT)"))
+ die(sprintf("skip [%d] %s\n", $link->errno, $link->error));
if (!@mysqli_query($link, "SET sql_mode=''") || !@mysqli_query($link, "INSERT INTO test(id) VALUES (100001)"))
- die("skip Strict sql mode seems to be active. We won't get a warning to check for.");
+ die("skip Strict sql mode seems to be active. We won't get a warning to check for.");
mysqli_query($link, "DROP TABLE IF EXISTS test");
?>
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_get_warnings(): invalid object or resource mysqli_stmt
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_close(): invalid object or resource mysqli_stmt
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_insert_id(): Couldn't fetch mysqli_stmt in %s on line %d
?>
--CLEAN--
<?php
- require_once("connect.inc");
- if (!$link->query('DROP PROCEDURE IF EXISTS p123')) {
- printf("[001] [%d] %s\n", $link->error, $link->errno);
- }
+ require_once("connect.inc");
+ if (!$link->query('DROP PROCEDURE IF EXISTS p123')) {
+ printf("[001] [%d] %s\n", $link->error, $link->errno);
+ }
?>
--EXPECT--
string(4) "pre:"
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
run_tests.php don't fool me with your 'ungreedy' expression '.+?'!
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_param_count(): invalid object or resource mysqli_stmt
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_prepare(): Couldn't fetch mysqli_stmt in %s on line %d
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_reset(): invalid object or resource mysqli_stmt
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_result_metadata(): invalid object or resource mysqli_stmt
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_send_long_data(): Invalid parameter number in %s on line %d
require_once('skipifconnectfailure.inc');
if (stristr(mysqli_get_client_info(), 'mysqlnd'))
- die("skip: test for libmysql");
+ die("skip: test for libmysql");
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
require_once('skipifconnectfailure.inc');
if (!stristr(mysqli_get_client_info(), 'mysqlnd'))
- die("skip: warnings only available in mysqlnd");
+ die("skip: warnings only available in mysqlnd");
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_sqlstate(): invalid object or resource mysqli_stmt
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
done!
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_store_result(): Couldn't fetch mysqli in %s on line %d
mysqlnd.debug="d:t:O,{TMP}/mysqlnd.trace"
--FILE--
<?php
- require_once("connect.inc");
+ require_once("connect.inc");
- $tmp = NULL;
- $link = NULL;
+ $tmp = NULL;
+ $link = NULL;
- require('table.inc');
+ require('table.inc');
- if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id"))
- printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if (!$res = 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, MYSQLI_STORE_RESULT_COPY_DATA)))
- printf("[004] Expecting object, got %s/%s. [%d] %s\n",
- gettype($res), $res, mysqli_errno($link), mysqli_error($link));
+ if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA)))
+ printf("[004] Expecting object, got %s/%s. [%d] %s\n",
+ gettype($res), $res, mysqli_errno($link), mysqli_error($link));
- if (true !== ($tmp = mysqli_data_seek($res, 2)))
- printf("[005] Expecting boolean/true, got %s/%s. [%d] %s\n",
- gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link));
+ if (true !== ($tmp = mysqli_data_seek($res, 2)))
+ printf("[005] Expecting boolean/true, got %s/%s. [%d] %s\n",
+ gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link));
- mysqli_free_result($res);
+ mysqli_free_result($res);
- print "done!";
+ print "done!";
?>
--CLEAN--
<?php
mysqlnd.fetch_data_copy=0
--FILE--
<?php
- require_once("connect.inc");
-
- $tmp = NULL;
- $link = NULL;
-
- require('table.inc');
-
- if (!$res = 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, MYSQLI_STORE_RESULT_COPY_DATA)))
- printf("[004] Expecting object, got %s/%s. [%d] %s\n",
- gettype($res), $res, mysqli_errno($link), mysqli_error($link));
-
- if (true !== ($tmp = mysqli_data_seek($res, 2)))
- printf("[005] Expecting boolean/true, got %s/%s. [%d] %s\n",
- gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link));
-
- var_dump($res->fetch_assoc());
-
- if (true !== ($tmp = mysqli_data_seek($res, 0)))
- printf("[006] Expecting boolean/true, got %s/%s. [%d] %s\n",
- gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link));
-
- while ($row = $res->fetch_assoc()) {
- printf("id = %d, label = %s\n", $row['id'], $row['label']);
- }
-
- mysqli_free_result($res);
- mysqli_close($link);
-
- if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- printf("[007] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket);
- }
-
-
- if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id"))
- printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
- if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA)))
- printf("[009] Expecting object, got %s/%s. [%d] %s\n",
- gettype($res), $res, mysqli_errno($link), mysqli_error($link));
+ require_once("connect.inc");
+
+ $tmp = NULL;
+ $link = NULL;
+
+ require('table.inc');
+
+ if (!$res = 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, MYSQLI_STORE_RESULT_COPY_DATA)))
+ printf("[004] Expecting object, got %s/%s. [%d] %s\n",
+ gettype($res), $res, mysqli_errno($link), mysqli_error($link));
+
+ if (true !== ($tmp = mysqli_data_seek($res, 2)))
+ printf("[005] Expecting boolean/true, got %s/%s. [%d] %s\n",
+ gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link));
+
+ var_dump($res->fetch_assoc());
+
+ if (true !== ($tmp = mysqli_data_seek($res, 0)))
+ printf("[006] Expecting boolean/true, got %s/%s. [%d] %s\n",
+ gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link));
+
+ while ($row = $res->fetch_assoc()) {
+ printf("id = %d, label = %s\n", $row['id'], $row['label']);
+ }
+
+ mysqli_free_result($res);
+ mysqli_close($link);
+
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ printf("[007] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
+ }
+
+
+ if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id"))
+ printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA)))
+ printf("[009] Expecting object, got %s/%s. [%d] %s\n",
+ gettype($res), $res, mysqli_errno($link), mysqli_error($link));
- $no_result = 0;
- for ($i = 0; $i < 1000; $i++) {
- $idx = mt_rand(-100, 100);
- if (true === @mysqli_data_seek($res, $idx)) {
- $row = $res->fetch_assoc();
- if (!isset($row['id']) || !isset($row['label'])) {
- printf("[010] Brute force seek %d returned %d\n", $idx, var_export($row, true));
- }
- } else {
- $no_result++;
- }
- }
- printf("No result: %d\n", $no_result);
-
- /* implicit free, implicit store */
- /* meta and fetch lengths code */
- if (!$res = mysqli_query($link, "SELECT CONCAT(id, id) AS _c, label FROM test ORDER BY id DESC LIMIT 2"))
- printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
- printf("Default\n");
- var_dump(mysqli_fetch_lengths($res));
- $fields = $res->fetch_fields();
- while ($row = $res->fetch_assoc()) {
- var_dump(mysqli_fetch_lengths($res));
- }
- var_dump(mysqli_fetch_lengths($res));
-
- if (!$res = mysqli_real_query($link, "SELECT CONCAT(id, id) AS _c, label FROM test ORDER BY id DESC LIMIT 2"))
- printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
- if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA)))
- printf("[013] Expecting object, got %s/%s. [%d] %s\n",
- gettype($res), $res, mysqli_errno($link), mysqli_error($link));
-
- printf("Copy\n");
- var_dump(mysqli_fetch_lengths($res));
- $fields_copy = $res->fetch_fields();
- while ($row = $res->fetch_assoc()) {
- var_dump(mysqli_fetch_lengths($res));
- }
- var_dump(mysqli_fetch_lengths($res));
-
- /* There's no need for in-depth testing here. If you want in-depth switch mysqlnd
- globally to copy mode and run all the tests */
- foreach ($fields as $k => $field_info) {
- if ($fields_copy[$k] != $field_info) {
- printf("[014] Metadata seems to differ, dumping\n");
- var_dump($field_info);
- var_dump($fields_copy[$k]);
- }
- }
-
- /* fetch all */
-
- if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id DESC LIMIT 2"))
- printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
- if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA)))
- printf("[016] Expecting object, got %s/%s. [%d] %s\n",
- gettype($res), $res, mysqli_errno($link), mysqli_error($link));
-
- foreach (mysqli_fetch_all($res, MYSQLI_ASSOC) as $row) {
- printf("id = %d label = %s\n", $row['id'], $row['label']);
- }
-
- if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id DESC LIMIT 2"))
- printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
- if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA)))
- printf("[018] Expecting object, got %s/%s. [%d] %s\n",
- gettype($res), $res, mysqli_errno($link), mysqli_error($link));
-
- /* provoke out of sync */
- if (!mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id DESC LIMIT 2"))
- printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
- var_dump($res->fetch_assoc());
-
- if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2"))
- printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
- if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA)))
- printf("[021] Expecting object, got %s/%s. [%d] %s\n",
- gettype($res), $res, mysqli_errno($link), mysqli_error($link));
-
- /* user conn killed, res associated with conn, fetch from res */
- unset($link);
- var_dump($res->fetch_assoc());
-
-
- if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- printf("[022] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket);
- }
-
- if (!$res = mysqli_real_query($link, "INSERT INTO test(id, label) VALUES (100, 'z')"))
- printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
- mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA);
-
- if (mysqli_get_server_version($link) > 50000) {
- // let's try to play with stored procedures
- mysqli_real_query($link, 'DROP PROCEDURE IF EXISTS p');
- if (mysqli_real_query($link, 'CREATE PROCEDURE p(OUT ver_param VARCHAR(25)) READS SQL DATA BEGIN SELECT id FROM test WHERE id >= 100 ORDER BY id; SELECT id + 1, label FROM test WHERE id > 0 AND id < 3 ORDER BY id; SELECT VERSION() INTO ver_param;
+ $no_result = 0;
+ for ($i = 0; $i < 1000; $i++) {
+ $idx = mt_rand(-100, 100);
+ if (true === @mysqli_data_seek($res, $idx)) {
+ $row = $res->fetch_assoc();
+ if (!isset($row['id']) || !isset($row['label'])) {
+ printf("[010] Brute force seek %d returned %d\n", $idx, var_export($row, true));
+ }
+ } else {
+ $no_result++;
+ }
+ }
+ printf("No result: %d\n", $no_result);
+
+ /* implicit free, implicit store */
+ /* meta and fetch lengths code */
+ if (!$res = mysqli_query($link, "SELECT CONCAT(id, id) AS _c, label FROM test ORDER BY id DESC LIMIT 2"))
+ printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ printf("Default\n");
+ var_dump(mysqli_fetch_lengths($res));
+ $fields = $res->fetch_fields();
+ while ($row = $res->fetch_assoc()) {
+ var_dump(mysqli_fetch_lengths($res));
+ }
+ var_dump(mysqli_fetch_lengths($res));
+
+ if (!$res = mysqli_real_query($link, "SELECT CONCAT(id, id) AS _c, label FROM test ORDER BY id DESC LIMIT 2"))
+ printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA)))
+ printf("[013] Expecting object, got %s/%s. [%d] %s\n",
+ gettype($res), $res, mysqli_errno($link), mysqli_error($link));
+
+ printf("Copy\n");
+ var_dump(mysqli_fetch_lengths($res));
+ $fields_copy = $res->fetch_fields();
+ while ($row = $res->fetch_assoc()) {
+ var_dump(mysqli_fetch_lengths($res));
+ }
+ var_dump(mysqli_fetch_lengths($res));
+
+ /* There's no need for in-depth testing here. If you want in-depth switch mysqlnd
+ globally to copy mode and run all the tests */
+ foreach ($fields as $k => $field_info) {
+ if ($fields_copy[$k] != $field_info) {
+ printf("[014] Metadata seems to differ, dumping\n");
+ var_dump($field_info);
+ var_dump($fields_copy[$k]);
+ }
+ }
+
+ /* fetch all */
+
+ if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id DESC LIMIT 2"))
+ printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA)))
+ printf("[016] Expecting object, got %s/%s. [%d] %s\n",
+ gettype($res), $res, mysqli_errno($link), mysqli_error($link));
+
+ foreach (mysqli_fetch_all($res, MYSQLI_ASSOC) as $row) {
+ printf("id = %d label = %s\n", $row['id'], $row['label']);
+ }
+
+ if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id DESC LIMIT 2"))
+ printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA)))
+ printf("[018] Expecting object, got %s/%s. [%d] %s\n",
+ gettype($res), $res, mysqli_errno($link), mysqli_error($link));
+
+ /* provoke out of sync */
+ if (!mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id DESC LIMIT 2"))
+ printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ var_dump($res->fetch_assoc());
+
+ if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2"))
+ printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA)))
+ printf("[021] Expecting object, got %s/%s. [%d] %s\n",
+ gettype($res), $res, mysqli_errno($link), mysqli_error($link));
+
+ /* user conn killed, res associated with conn, fetch from res */
+ unset($link);
+ var_dump($res->fetch_assoc());
+
+
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ printf("[022] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
+ }
+
+ if (!$res = mysqli_real_query($link, "INSERT INTO test(id, label) VALUES (100, 'z')"))
+ printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA);
+
+ if (mysqli_get_server_version($link) > 50000) {
+ // let's try to play with stored procedures
+ mysqli_real_query($link, 'DROP PROCEDURE IF EXISTS p');
+ if (mysqli_real_query($link, 'CREATE PROCEDURE p(OUT ver_param VARCHAR(25)) READS SQL DATA BEGIN SELECT id FROM test WHERE id >= 100 ORDER BY id; SELECT id + 1, label FROM test WHERE id > 0 AND id < 3 ORDER BY id; SELECT VERSION() INTO ver_param;
END;')) {
- mysqli_multi_query($link, "CALL p(@version)");
- do {
- if ($res = $link->store_result(MYSQLI_STORE_RESULT_COPY_DATA)) {
- printf("---\n");
- var_dump($res->fetch_all());
- $res->free();
- } else {
- if ($link->errno) {
- echo "Store failed: (" . $link->errno . ") " . $link->error;
- }
- }
- } while ($link->more_results() && $link->next_result());
- mysqli_real_query($link, 'SELECT @version AS p_version');
- $res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA);
-
- $tmp = mysqli_fetch_assoc($res);
- if (!is_array($tmp) || empty($tmp) || !isset($tmp['p_version']) || ('' == $tmp['p_version'])) {
- printf("[024] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- var_dump($tmp);
- }
-
- mysqli_free_result($res);
- } else {
- printf("[025] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- }
- }
-
- print "done!";
+ mysqli_multi_query($link, "CALL p(@version)");
+ do {
+ if ($res = $link->store_result(MYSQLI_STORE_RESULT_COPY_DATA)) {
+ printf("---\n");
+ var_dump($res->fetch_all());
+ $res->free();
+ } else {
+ if ($link->errno) {
+ echo "Store failed: (" . $link->errno . ") " . $link->error;
+ }
+ }
+ } while ($link->more_results() && $link->next_result());
+ mysqli_real_query($link, 'SELECT @version AS p_version');
+ $res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA);
+
+ $tmp = mysqli_fetch_assoc($res);
+ if (!is_array($tmp) || empty($tmp) || !isset($tmp['p_version']) || ('' == $tmp['p_version'])) {
+ printf("[024] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ var_dump($tmp);
+ }
+
+ mysqli_free_result($res);
+ } else {
+ printf("[025] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ }
+ }
+
+ print "done!";
?>
--CLEAN--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_thread_id(): Couldn't fetch mysqli in %s on line %d
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_data_seek(): Function cannot be used with MYSQL_USE_RESULT in %s on line %d
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_warning_count(): Couldn't fetch mysqli in %s on line %d
require_once('skipifconnectfailure.inc');
require_once('connect.inc');
if (!$TEST_EXPERIMENTAL)
- die("skip - experimental (= unsupported) feature");
+ die("skip - experimental (= unsupported) feature");
?>
--FILE--
<?php
?>
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECTF--
Fatal error: Trying to clone an uncloneable object of class mysqli_warning in %s on line %d
<?php
- function inspectClass($class) {
-
- /* not used: public ReflectionClass[] getInterfaces() */
-
- printf("\nInspecting class '%s'\n", $class->getName());
- printf("isInternal: %s\n", ($class->isInternal()) ? 'yes' : 'no');
- printf("isUserDefined: %s\n", ($class->isUserDefined()) ? 'yes' : 'no');
- printf("isInstantiable: %s\n", ($class->isInstantiable()) ? 'yes' : 'no');
- printf("isInterface: %s\n", ($class->isInterface()) ? 'yes' : 'no');
- printf("isAbstract: %s\n", ($class->isAbstract()) ? 'yes' : 'no');
- printf("isFinal: %s\n", ($class->isFinal()) ? 'yes' : 'no');
- printf("isIteratable: %s\n", ($class->isIterateable()) ? 'yes' : 'no');
- printf("Modifiers: '%d'\n", $class->getModifiers());
- printf("Parent Class: '%s'\n", $class->getParentClass());
- printf("Extension: '%s'\n", $class->getExtensionName());
-
- if ($method = $class->getConstructor())
- inspectMethod($method);
-
- if ($methods = $class->getMethods()) {
- $tmp = array();
- foreach ($methods as $method)
- $tmp[$method->getName()] = $method;
-
- ksort($tmp, SORT_STRING);
- foreach ($tmp as $method)
- inspectMethod($method);
- }
-
- if ($properties = $class->getProperties()) {
- $tmp = array();
- foreach ($properties as $prop)
- $tmp[$prop->getName()] = $prop;
- ksort($tmp, SORT_STRING);
- foreach ($tmp as $prop)
- inspectProperty($prop);
- }
-
-
- if ($properties = $class->getDefaultProperties()) {
- ksort($properties, SORT_STRING);
- foreach ($properties as $name => $v)
- printf("Default property '%s'\n", $name);
- }
-
- if ($properties = $class->getStaticProperties()) {
- ksort($properties, SORT_STRING);
- foreach ($properties as $name => $v)
- printf("Static property '%s'\n", $name);
- }
-
- if ($constants = $class->getConstants()) {
- ksort($constants, SORT_STRING);
- foreach ($constant as $name => $value)
- printf("Constant '%s' = '%s'\n", $name, $value);
- }
-
- }
-
- function inspectProperty(&$prop) {
-
- printf("\nInspecting property '%s'\n", $prop->getName());
- printf("isPublic: %s\n", ($prop->isPublic()) ? 'yes' : 'no');
- printf("isPrivate: %s\n", ($prop->isPrivate()) ? 'yes' : 'no');
- printf("isProtected: %s\n", ($prop->isProtected()) ? 'yes' : 'no');
- printf("isStatic: %s\n", ($prop->isStatic()) ? 'yes' : 'no');
- printf("isDefault: %s\n", ($prop->isDefault()) ? 'yes' : 'no');
- printf("Modifiers: %d\n", $prop->getModifiers());
- // printf("Value\n"); var_export($prop->getValue());
-
- }
-
- function inspectMethod(&$method) {
-
- printf("\nInspecting method '%s'\n", $method->getName());
- printf("isFinal: %s\n", ($method->isFinal()) ? 'yes' : 'no');
- printf("isAbstract: %s\n", ($method->isAbstract()) ? 'yes' : 'no');
- printf("isPublic: %s\n", ($method->isPublic()) ? 'yes' : 'no');
- printf("isPrivate: %s\n", ($method->isPrivate()) ? 'yes' : 'no');
- printf("isProtected: %s\n", ($method->isProtected()) ? 'yes' : 'no');
- printf("isStatic: %s\n", ($method->isStatic()) ? 'yes' : 'no');
- printf("isConstructor: %s\n", ($method->isConstructor()) ? 'yes' : 'no');
- printf("isDestructor: %s\n", ($method->isDestructor()) ? 'yes' : 'no');
- printf("isInternal: %s\n", ($method->isInternal()) ? 'yes' : 'no');
- printf("isUserDefined: %s\n", ($method->isUserDefined()) ? 'yes' : 'no');
- printf("returnsReference: %s\n", ($method->returnsReference()) ? 'yes' : 'no');
- printf("Modifiers: %d\n", $method->getModifiers());
- printf("Number of Parameters: %d\n", $method->getNumberOfParameters());
- printf("Number of Required Parameters: %d\n", $method->getNumberOfRequiredParameters());
-
- if ($params = $method->getParameters()) {
- $tmp = array();
- foreach ($params as $k => $param)
- $tmp[$param->getName()] = $param;
+ function inspectClass($class) {
+
+ /* not used: public ReflectionClass[] getInterfaces() */
+
+ printf("\nInspecting class '%s'\n", $class->getName());
+ printf("isInternal: %s\n", ($class->isInternal()) ? 'yes' : 'no');
+ printf("isUserDefined: %s\n", ($class->isUserDefined()) ? 'yes' : 'no');
+ printf("isInstantiable: %s\n", ($class->isInstantiable()) ? 'yes' : 'no');
+ printf("isInterface: %s\n", ($class->isInterface()) ? 'yes' : 'no');
+ printf("isAbstract: %s\n", ($class->isAbstract()) ? 'yes' : 'no');
+ printf("isFinal: %s\n", ($class->isFinal()) ? 'yes' : 'no');
+ printf("isIteratable: %s\n", ($class->isIterateable()) ? 'yes' : 'no');
+ printf("Modifiers: '%d'\n", $class->getModifiers());
+ printf("Parent Class: '%s'\n", $class->getParentClass());
+ printf("Extension: '%s'\n", $class->getExtensionName());
+
+ if ($method = $class->getConstructor())
+ inspectMethod($method);
+
+ if ($methods = $class->getMethods()) {
+ $tmp = array();
+ foreach ($methods as $method)
+ $tmp[$method->getName()] = $method;
+
+ ksort($tmp, SORT_STRING);
+ foreach ($tmp as $method)
+ inspectMethod($method);
+ }
+
+ if ($properties = $class->getProperties()) {
+ $tmp = array();
+ foreach ($properties as $prop)
+ $tmp[$prop->getName()] = $prop;
+ ksort($tmp, SORT_STRING);
+ foreach ($tmp as $prop)
+ inspectProperty($prop);
+ }
+
+
+ if ($properties = $class->getDefaultProperties()) {
+ ksort($properties, SORT_STRING);
+ foreach ($properties as $name => $v)
+ printf("Default property '%s'\n", $name);
+ }
+
+ if ($properties = $class->getStaticProperties()) {
+ ksort($properties, SORT_STRING);
+ foreach ($properties as $name => $v)
+ printf("Static property '%s'\n", $name);
+ }
+
+ if ($constants = $class->getConstants()) {
+ ksort($constants, SORT_STRING);
+ foreach ($constant as $name => $value)
+ printf("Constant '%s' = '%s'\n", $name, $value);
+ }
+
+ }
+
+ function inspectProperty(&$prop) {
+
+ printf("\nInspecting property '%s'\n", $prop->getName());
+ printf("isPublic: %s\n", ($prop->isPublic()) ? 'yes' : 'no');
+ printf("isPrivate: %s\n", ($prop->isPrivate()) ? 'yes' : 'no');
+ printf("isProtected: %s\n", ($prop->isProtected()) ? 'yes' : 'no');
+ printf("isStatic: %s\n", ($prop->isStatic()) ? 'yes' : 'no');
+ printf("isDefault: %s\n", ($prop->isDefault()) ? 'yes' : 'no');
+ printf("Modifiers: %d\n", $prop->getModifiers());
+ // printf("Value\n"); var_export($prop->getValue());
+
+ }
+
+ function inspectMethod(&$method) {
+
+ printf("\nInspecting method '%s'\n", $method->getName());
+ printf("isFinal: %s\n", ($method->isFinal()) ? 'yes' : 'no');
+ printf("isAbstract: %s\n", ($method->isAbstract()) ? 'yes' : 'no');
+ printf("isPublic: %s\n", ($method->isPublic()) ? 'yes' : 'no');
+ printf("isPrivate: %s\n", ($method->isPrivate()) ? 'yes' : 'no');
+ printf("isProtected: %s\n", ($method->isProtected()) ? 'yes' : 'no');
+ printf("isStatic: %s\n", ($method->isStatic()) ? 'yes' : 'no');
+ printf("isConstructor: %s\n", ($method->isConstructor()) ? 'yes' : 'no');
+ printf("isDestructor: %s\n", ($method->isDestructor()) ? 'yes' : 'no');
+ printf("isInternal: %s\n", ($method->isInternal()) ? 'yes' : 'no');
+ printf("isUserDefined: %s\n", ($method->isUserDefined()) ? 'yes' : 'no');
+ printf("returnsReference: %s\n", ($method->returnsReference()) ? 'yes' : 'no');
+ printf("Modifiers: %d\n", $method->getModifiers());
+ printf("Number of Parameters: %d\n", $method->getNumberOfParameters());
+ printf("Number of Required Parameters: %d\n", $method->getNumberOfRequiredParameters());
+
+ if ($params = $method->getParameters()) {
+ $tmp = array();
+ foreach ($params as $k => $param)
+ $tmp[$param->getName()] = $param;
// ksort($tmp, SORT_STRING);
- foreach ($tmp as $param)
- inspectParameter($method, $param);
- }
+ foreach ($tmp as $param)
+ inspectParameter($method, $param);
+ }
- if ($static = $method->getStaticVariables()) {
- sort($static, SORT_STRING);
- printf("Static variables: %s\n", implode('/', $static));
- }
+ if ($static = $method->getStaticVariables()) {
+ sort($static, SORT_STRING);
+ printf("Static variables: %s\n", implode('/', $static));
+ }
- }
+ }
- function inspectParameter(&$method, &$param) {
+ function inspectParameter(&$method, &$param) {
- printf("\nInspecting parameter '%s' of method '%s'\n",
- $param->getName(), $method->getName());
- printf("isArray: %s\n", ($param->isArray()) ? 'yes': 'no');
- printf("allowsNull: %s\n", ($param->allowsNull()) ? 'yes' : 'no');
- printf("isPassedByReference: %s\n", ($param->isPassedByReference()) ? 'yes' : 'no');
- printf("isOptional: %s\n", ($param->isOptional()) ? 'yes' : 'no');
- printf("isDefaultValueAvailable: %s\n", ($param->isDefaultValueAvailable()) ? 'yes' : 'no');
- // printf("getDefaultValue: %s\n", ($param->getDefaultValue()) ? 'yes' : 'no');
+ printf("\nInspecting parameter '%s' of method '%s'\n",
+ $param->getName(), $method->getName());
+ printf("isArray: %s\n", ($param->isArray()) ? 'yes': 'no');
+ printf("allowsNull: %s\n", ($param->allowsNull()) ? 'yes' : 'no');
+ printf("isPassedByReference: %s\n", ($param->isPassedByReference()) ? 'yes' : 'no');
+ printf("isOptional: %s\n", ($param->isOptional()) ? 'yes' : 'no');
+ printf("isDefaultValueAvailable: %s\n", ($param->isDefaultValueAvailable()) ? 'yes' : 'no');
+ // printf("getDefaultValue: %s\n", ($param->getDefaultValue()) ? 'yes' : 'no');
- }
+ }
?>
<?php
if (!extension_loaded('mysqli')){
- die('skip mysqli extension not available');
+ die('skip mysqli extension not available');
}
?>
<?php
require_once('connect.inc');
if ($skip_on_connect_failure) {
- include_once('connect.inc');
- $link = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
- if (!is_object($link))
- die(sprintf("skip Can't connect to MySQL Server - [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
- mysqli_close($link);
+ include_once('connect.inc');
+ $link = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ if (!is_object($link))
+ die(sprintf("skip Can't connect to MySQL Server - [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
+ mysqli_close($link);
}
?>
<?php
- $driver = new mysqli_driver();
- if ($driver->embedded)
- die("skip test doesn't run with embedded server");
+ $driver = new mysqli_driver();
+ if ($driver->embedded)
+ die("skip test doesn't run with embedded server");
?>
<?php
- $driver = new mysqli_driver();
- if (!$driver->embedded)
- die("skip test for with embedded server only");
+ $driver = new mysqli_driver();
+ if (!$driver->embedded)
+ die("skip test for with embedded server only");
?>
require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- printf("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);
+ printf("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);
}
if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) {
- printf("Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- exit(1);
+ printf("Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ exit(1);
}
if (!mysqli_query($link, 'SET SESSION sql_mode=\'\'')) {
- printf("Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- exit(1);
+ printf("Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ exit(1);
}
if (!mysqli_query($link, 'CREATE TABLE test(id INT DEFAULT 0, label CHAR(1), PRIMARY KEY(id)) ENGINE=' . $engine)) {
- printf("Failed to create test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- exit(1);
+ printf("Failed to create test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ exit(1);
}
if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES (1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f')")) {
- printf("[%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
?>