diff options
290 files changed, 4857 insertions, 4857 deletions
diff --git a/ext/mysqli/tests/002.phpt b/ext/mysqli/tests/002.phpt index 1c98577454..0a40da8589 100644 --- a/ext/mysqli/tests/002.phpt +++ b/ext/mysqli/tests/002.phpt @@ -53,7 +53,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/003.phpt b/ext/mysqli/tests/003.phpt index c526dfbdff..426fb42114 100644 --- a/ext/mysqli/tests/003.phpt +++ b/ext/mysqli/tests/003.phpt @@ -79,7 +79,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/004.phpt b/ext/mysqli/tests/004.phpt index e19d4c3119..13572babfd 100644 --- a/ext/mysqli/tests/004.phpt +++ b/ext/mysqli/tests/004.phpt @@ -57,7 +57,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/005.phpt b/ext/mysqli/tests/005.phpt index e1f5be989f..ff569211f7 100644 --- a/ext/mysqli/tests/005.phpt +++ b/ext/mysqli/tests/005.phpt @@ -47,7 +47,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/006.phpt b/ext/mysqli/tests/006.phpt index d60c52fbde..f5dd368b0c 100644 --- a/ext/mysqli/tests/006.phpt +++ b/ext/mysqli/tests/006.phpt @@ -52,7 +52,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/007.phpt b/ext/mysqli/tests/007.phpt index 86c7fc2e57..a2081264e5 100644 --- a/ext/mysqli/tests/007.phpt +++ b/ext/mysqli/tests/007.phpt @@ -52,7 +52,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/008.phpt b/ext/mysqli/tests/008.phpt index f36e524d11..6dfeaa5058 100644 --- a/ext/mysqli/tests/008.phpt +++ b/ext/mysqli/tests/008.phpt @@ -52,7 +52,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/009.phpt b/ext/mysqli/tests/009.phpt index 906c0f027b..2e24713f89 100644 --- a/ext/mysqli/tests/009.phpt +++ b/ext/mysqli/tests/009.phpt @@ -2,12 +2,12 @@ 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 @@ -85,10 +85,10 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/010.phpt b/ext/mysqli/tests/010.phpt index b1712ca2a6..49d68df90d 100644 --- a/ext/mysqli/tests/010.phpt +++ b/ext/mysqli/tests/010.phpt @@ -55,7 +55,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/011.phpt b/ext/mysqli/tests/011.phpt index 1792fec6a2..878c5dea62 100644 --- a/ext/mysqli/tests/011.phpt +++ b/ext/mysqli/tests/011.phpt @@ -52,7 +52,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/012.phpt b/ext/mysqli/tests/012.phpt index 2d8c6500ec..d627e55263 100644 --- a/ext/mysqli/tests/012.phpt +++ b/ext/mysqli/tests/012.phpt @@ -51,7 +51,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/013.phpt b/ext/mysqli/tests/013.phpt index 21fd278489..d21d890b1d 100644 --- a/ext/mysqli/tests/013.phpt +++ b/ext/mysqli/tests/013.phpt @@ -63,7 +63,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/014.phpt b/ext/mysqli/tests/014.phpt index 576b337b57..335fb6eba7 100644 --- a/ext/mysqli/tests/014.phpt +++ b/ext/mysqli/tests/014.phpt @@ -2,16 +2,16 @@ 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 @@ -78,7 +78,7 @@ mysqli autocommit/commit/rollback ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- Num_of_rows=1 diff --git a/ext/mysqli/tests/015.phpt b/ext/mysqli/tests/015.phpt index 0d2b44d7d3..8901d1f175 100644 --- a/ext/mysqli/tests/015.phpt +++ b/ext/mysqli/tests/015.phpt @@ -2,15 +2,15 @@ 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 @@ -76,7 +76,7 @@ mysqli autocommit/commit/rollback with innodb ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- array(2) { diff --git a/ext/mysqli/tests/019.phpt b/ext/mysqli/tests/019.phpt index 4688ff9f8a..2f6276bdb6 100644 --- a/ext/mysqli/tests/019.phpt +++ b/ext/mysqli/tests/019.phpt @@ -62,7 +62,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/020.phpt b/ext/mysqli/tests/020.phpt index 57016de4b8..daa5708ab8 100644 --- a/ext/mysqli/tests/020.phpt +++ b/ext/mysqli/tests/020.phpt @@ -74,7 +74,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/021.phpt b/ext/mysqli/tests/021.phpt index d9cf52eddc..d350907d93 100644 --- a/ext/mysqli/tests/021.phpt +++ b/ext/mysqli/tests/021.phpt @@ -45,7 +45,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/022.phpt b/ext/mysqli/tests/022.phpt index fd8036fd1a..dbd2905105 100644 --- a/ext/mysqli/tests/022.phpt +++ b/ext/mysqli/tests/022.phpt @@ -50,7 +50,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/023.phpt b/ext/mysqli/tests/023.phpt index 17a8abce77..b918aaeb67 100644 --- a/ext/mysqli/tests/023.phpt +++ b/ext/mysqli/tests/023.phpt @@ -59,7 +59,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/024.phpt b/ext/mysqli/tests/024.phpt index 5294a24883..d801324738 100644 --- a/ext/mysqli/tests/024.phpt +++ b/ext/mysqli/tests/024.phpt @@ -59,7 +59,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/025.phpt b/ext/mysqli/tests/025.phpt index 3b472f9513..f0d3cd5b79 100644 --- a/ext/mysqli/tests/025.phpt +++ b/ext/mysqli/tests/025.phpt @@ -64,7 +64,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/026.phpt b/ext/mysqli/tests/026.phpt index 51b2b774bb..8d9d9140a6 100644 --- a/ext/mysqli/tests/026.phpt +++ b/ext/mysqli/tests/026.phpt @@ -51,7 +51,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/029.phpt b/ext/mysqli/tests/029.phpt index cf59999eaf..b2409e976b 100644 --- a/ext/mysqli/tests/029.phpt +++ b/ext/mysqli/tests/029.phpt @@ -33,7 +33,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/032.phpt b/ext/mysqli/tests/032.phpt index 27d8fb3fa5..5347a33f68 100644 --- a/ext/mysqli/tests/032.phpt +++ b/ext/mysqli/tests/032.phpt @@ -33,7 +33,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/036.phpt b/ext/mysqli/tests/036.phpt index 919625c8cd..e0b5375ff7 100644 --- a/ext/mysqli/tests/036.phpt +++ b/ext/mysqli/tests/036.phpt @@ -2,12 +2,12 @@ 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 @@ -49,7 +49,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/037.phpt b/ext/mysqli/tests/037.phpt index 5826a9834e..dece211f0f 100644 --- a/ext/mysqli/tests/037.phpt +++ b/ext/mysqli/tests/037.phpt @@ -39,7 +39,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/038.phpt b/ext/mysqli/tests/038.phpt index 45b724ca3c..f2fcbf69ee 100644 --- a/ext/mysqli/tests/038.phpt +++ b/ext/mysqli/tests/038.phpt @@ -39,7 +39,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/040.phpt b/ext/mysqli/tests/040.phpt index a860f30d81..1e9ec7c22b 100644 --- a/ext/mysqli/tests/040.phpt +++ b/ext/mysqli/tests/040.phpt @@ -38,7 +38,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/041.phpt b/ext/mysqli/tests/041.phpt index 86ddd67069..903277d8c8 100644 --- a/ext/mysqli/tests/041.phpt +++ b/ext/mysqli/tests/041.phpt @@ -29,7 +29,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/042.phpt b/ext/mysqli/tests/042.phpt index e84dfc2a10..9fa55ce300 100644 --- a/ext/mysqli/tests/042.phpt +++ b/ext/mysqli/tests/042.phpt @@ -55,7 +55,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/043.phpt b/ext/mysqli/tests/043.phpt index daf79ebbe4..d13d552341 100644 --- a/ext/mysqli/tests/043.phpt +++ b/ext/mysqli/tests/043.phpt @@ -47,7 +47,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/045.phpt b/ext/mysqli/tests/045.phpt index 0b7b68239c..7c357a54af 100644 --- a/ext/mysqli/tests/045.phpt +++ b/ext/mysqli/tests/045.phpt @@ -2,21 +2,21 @@ 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 diff --git a/ext/mysqli/tests/046.phpt b/ext/mysqli/tests/046.phpt index 8e4b8c3b2c..3a7c2d9340 100644 --- a/ext/mysqli/tests/046.phpt +++ b/ext/mysqli/tests/046.phpt @@ -41,7 +41,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/047.phpt b/ext/mysqli/tests/047.phpt index a89488fa58..14b0612d78 100644 --- a/ext/mysqli/tests/047.phpt +++ b/ext/mysqli/tests/047.phpt @@ -52,7 +52,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/048.phpt b/ext/mysqli/tests/048.phpt index 9328e0e282..9df8005b38 100644 --- a/ext/mysqli/tests/048.phpt +++ b/ext/mysqli/tests/048.phpt @@ -47,7 +47,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/057.phpt b/ext/mysqli/tests/057.phpt index f4b60ecd4f..92f7e767d1 100644 --- a/ext/mysqli/tests/057.phpt +++ b/ext/mysqli/tests/057.phpt @@ -69,7 +69,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/058.phpt b/ext/mysqli/tests/058.phpt index e839e7e64e..d56ea50722 100644 --- a/ext/mysqli/tests/058.phpt +++ b/ext/mysqli/tests/058.phpt @@ -55,7 +55,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/059.phpt b/ext/mysqli/tests/059.phpt index 0632553143..3faf5b9332 100644 --- a/ext/mysqli/tests/059.phpt +++ b/ext/mysqli/tests/059.phpt @@ -48,7 +48,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/060.phpt b/ext/mysqli/tests/060.phpt index 9043dd7def..0268339b3d 100644 --- a/ext/mysqli/tests/060.phpt +++ b/ext/mysqli/tests/060.phpt @@ -49,7 +49,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/061.phpt b/ext/mysqli/tests/061.phpt index 0da9c1c09d..76a40c704e 100644 --- a/ext/mysqli/tests/061.phpt +++ b/ext/mysqli/tests/061.phpt @@ -5,15 +5,15 @@ local infile handler 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); ?> @@ -21,45 +21,45 @@ 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 diff --git a/ext/mysqli/tests/065.phpt b/ext/mysqli/tests/065.phpt index 75c4b02a29..8c11846a8f 100644 --- a/ext/mysqli/tests/065.phpt +++ b/ext/mysqli/tests/065.phpt @@ -6,7 +6,7 @@ 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-- diff --git a/ext/mysqli/tests/066.phpt b/ext/mysqli/tests/066.phpt index a337e038c1..0089210718 100644 --- a/ext/mysqli/tests/066.phpt +++ b/ext/mysqli/tests/066.phpt @@ -37,7 +37,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/067.phpt b/ext/mysqli/tests/067.phpt index e36993bb6b..1ab9ed5320 100644 --- a/ext/mysqli/tests/067.phpt +++ b/ext/mysqli/tests/067.phpt @@ -2,20 +2,20 @@ 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 @@ -71,8 +71,8 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); diff --git a/ext/mysqli/tests/bug32405.phpt b/ext/mysqli/tests/bug32405.phpt index 0b3cad50ff..84ec9fd963 100644 --- a/ext/mysqli/tests/bug32405.phpt +++ b/ext/mysqli/tests/bug32405.phpt @@ -38,7 +38,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/bug34810.phpt b/ext/mysqli/tests/bug34810.phpt index b56d1a5ac7..ff7985e49b 100644 --- a/ext/mysqli/tests/bug34810.phpt +++ b/ext/mysqli/tests/bug34810.phpt @@ -54,7 +54,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/bug35103.phpt b/ext/mysqli/tests/bug35103.phpt index fc3cad04c2..fbd83fcf56 100644 --- a/ext/mysqli/tests/bug35103.phpt +++ b/ext/mysqli/tests/bug35103.phpt @@ -58,7 +58,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/bug35517.phpt b/ext/mysqli/tests/bug35517.phpt index 78b3206af4..2a199a7a33 100644 --- a/ext/mysqli/tests/bug35517.phpt +++ b/ext/mysqli/tests/bug35517.phpt @@ -41,7 +41,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/bug36745.phpt b/ext/mysqli/tests/bug36745.phpt index 7a630afdc5..744985ab41 100644 --- a/ext/mysqli/tests/bug36745.phpt +++ b/ext/mysqli/tests/bug36745.phpt @@ -9,19 +9,19 @@ require_once('skipifconnectfailure.inc'); 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 diff --git a/ext/mysqli/tests/bug36949.phpt b/ext/mysqli/tests/bug36949.phpt index 2b3cc4955b..d59ee81d90 100644 --- a/ext/mysqli/tests/bug36949.phpt +++ b/ext/mysqli/tests/bug36949.phpt @@ -54,7 +54,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/bug37090.phpt b/ext/mysqli/tests/bug37090.phpt index d24e0d4a7f..1af1c1f5a2 100644 --- a/ext/mysqli/tests/bug37090.phpt +++ b/ext/mysqli/tests/bug37090.phpt @@ -5,7 +5,7 @@ Bug #37090 (mysqli_set_charset return code) 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-- diff --git a/ext/mysqli/tests/bug42378.phpt b/ext/mysqli/tests/bug42378.phpt index 1c75141306..3b0638c840 100644 --- a/ext/mysqli/tests/bug42378.phpt +++ b/ext/mysqli/tests/bug42378.phpt @@ -10,175 +10,175 @@ require_once('skipifconnectfailure.inc'); 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 diff --git a/ext/mysqli/tests/bug42548.phpt b/ext/mysqli/tests/bug42548.phpt index 8624250eb1..c6f18f3016 100644 --- a/ext/mysqli/tests/bug42548.phpt +++ b/ext/mysqli/tests/bug42548.phpt @@ -6,10 +6,10 @@ 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 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-- diff --git a/ext/mysqli/tests/bug44897.phpt b/ext/mysqli/tests/bug44897.phpt index 948e4aaee7..b5cecd5685 100644 --- a/ext/mysqli/tests/bug44897.phpt +++ b/ext/mysqli/tests/bug44897.phpt @@ -5,16 +5,16 @@ Bug #44879 (failed to prepare statement) 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-- @@ -78,7 +78,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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"); diff --git a/ext/mysqli/tests/bug45289.phpt b/ext/mysqli/tests/bug45289.phpt index 2ddacf4fdd..974887276f 100644 --- a/ext/mysqli/tests/bug45289.phpt +++ b/ext/mysqli/tests/bug45289.phpt @@ -34,7 +34,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- [004] [%s diff --git a/ext/mysqli/tests/bug46614.phpt b/ext/mysqli/tests/bug46614.phpt index 9e78222713..d301b87f6a 100644 --- a/ext/mysqli/tests/bug46614.phpt +++ b/ext/mysqli/tests/bug46614.phpt @@ -5,7 +5,7 @@ Bug #46614 (Extended MySQLi class gives incorrect empty() result) require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); if (!defined("MYSQLI_ASYNC")) { - die("skip mysqlnd only"); + die("skip mysqlnd only"); } ?> --FILE-- diff --git a/ext/mysqli/tests/bug47050.phpt b/ext/mysqli/tests/bug47050.phpt index 0358802bac..c8e720a44c 100644 --- a/ext/mysqli/tests/bug47050.phpt +++ b/ext/mysqli/tests/bug47050.phpt @@ -5,7 +5,7 @@ Bug #47050 (mysqli_poll() modifies improper variables) require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); if (!defined("MYSQLI_ASYNC")) { - die("skip mysqlnd only"); + die("skip mysqlnd only"); } ?> --FILE-- diff --git a/ext/mysqli/tests/bug48909.phpt b/ext/mysqli/tests/bug48909.phpt index ef46c97c6a..071f53dc7c 100644 --- a/ext/mysqli/tests/bug48909.phpt +++ b/ext/mysqli/tests/bug48909.phpt @@ -40,7 +40,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done diff --git a/ext/mysqli/tests/bug49027.phpt b/ext/mysqli/tests/bug49027.phpt index 059d986584..0ff2f51935 100644 --- a/ext/mysqli/tests/bug49027.phpt +++ b/ext/mysqli/tests/bug49027.phpt @@ -48,7 +48,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- array(1) { diff --git a/ext/mysqli/tests/bug49442.phpt b/ext/mysqli/tests/bug49442.phpt index d9093f0347..4c3fbcdb24 100644 --- a/ext/mysqli/tests/bug49442.phpt +++ b/ext/mysqli/tests/bug49442.phpt @@ -7,12 +7,12 @@ require_once('skipifconnectfailure.inc'); $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); ?> @@ -22,87 +22,87 @@ mysqli.allow_persistent=1 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 diff --git a/ext/mysqli/tests/bug51605.phpt b/ext/mysqli/tests/bug51605.phpt index c57a7b36d3..c3238da289 100644 --- a/ext/mysqli/tests/bug51605.phpt +++ b/ext/mysqli/tests/bug51605.phpt @@ -12,30 +12,30 @@ mysqli.max_persistent = 0 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 diff --git a/ext/mysqli/tests/bug51647.phpt b/ext/mysqli/tests/bug51647.phpt index cd7ccf8017..abcf5e4f0e 100644 --- a/ext/mysqli/tests/bug51647.phpt +++ b/ext/mysqli/tests/bug51647.phpt @@ -7,33 +7,33 @@ require_once('skipifconnectfailure.inc'); 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(); ?> diff --git a/ext/mysqli/tests/bug52891.phpt b/ext/mysqli/tests/bug52891.phpt index 22fcb735e3..8ea2e36f35 100644 --- a/ext/mysqli/tests/bug52891.phpt +++ b/ext/mysqli/tests/bug52891.phpt @@ -5,7 +5,7 @@ Bug #52891 (Wrong data inserted with mysqli/mysqlnd when using bind_param,value 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-- @@ -100,16 +100,16 @@ if (!$IS_MYSQLND) { 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); diff --git a/ext/mysqli/tests/bug53503.phpt b/ext/mysqli/tests/bug53503.phpt index fea62fde79..0b187102f7 100644 --- a/ext/mysqli/tests/bug53503.phpt +++ b/ext/mysqli/tests/bug53503.phpt @@ -6,11 +6,11 @@ require_once('skipif.inc'); 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); @@ -19,33 +19,33 @@ 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 diff --git a/ext/mysqli/tests/bug54221.phpt b/ext/mysqli/tests/bug54221.phpt index eef4695327..602ea68583 100644 --- a/ext/mysqli/tests/bug54221.phpt +++ b/ext/mysqli/tests/bug54221.phpt @@ -12,34 +12,34 @@ mysqli.max_persistent = 0 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 diff --git a/ext/mysqli/tests/bug54674.phpt b/ext/mysqli/tests/bug54674.phpt index e18eed7f99..b3c44be290 100644 --- a/ext/mysqli/tests/bug54674.phpt +++ b/ext/mysqli/tests/bug54674.phpt @@ -12,19 +12,19 @@ mysqli.max_persistent = 0 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) diff --git a/ext/mysqli/tests/bug55283.phpt b/ext/mysqli/tests/bug55283.phpt index 843400ff98..b0714aeaaa 100644 --- a/ext/mysqli/tests/bug55283.phpt +++ b/ext/mysqli/tests/bug55283.phpt @@ -7,33 +7,33 @@ require_once('skipifconnectfailure.inc'); 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(); ?> diff --git a/ext/mysqli/tests/bug67839.phpt b/ext/mysqli/tests/bug67839.phpt index f36c2bf6e7..de33c4c4ed 100644 --- a/ext/mysqli/tests/bug67839.phpt +++ b/ext/mysqli/tests/bug67839.phpt @@ -2,63 +2,63 @@ 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 diff --git a/ext/mysqli/tests/bug68077.phpt b/ext/mysqli/tests/bug68077.phpt index 639603aa50..2be4fe97aa 100644 --- a/ext/mysqli/tests/bug68077.phpt +++ b/ext/mysqli/tests/bug68077.phpt @@ -5,14 +5,14 @@ Bug #68077 (LOAD DATA LOCAL INFILE / open_basedir restriction) 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); ?> @@ -23,42 +23,42 @@ mysqli.max_persistent=1 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 diff --git a/ext/mysqli/tests/bug69899.phpt b/ext/mysqli/tests/bug69899.phpt index 6859b91c13..4de74270cd 100644 --- a/ext/mysqli/tests/bug69899.phpt +++ b/ext/mysqli/tests/bug69899.phpt @@ -12,7 +12,7 @@ require_once __DIR__ . '/skipif.inc'; require_once __DIR__ . '/skipifconnectfailure.inc'; require_once __DIR__ . '/connect.inc'; if (!$IS_MYSQLND) { - die('skip mysqlnd only'); + die('skip mysqlnd only'); } ?> --FILE-- diff --git a/ext/mysqli/tests/bug70384.phpt b/ext/mysqli/tests/bug70384.phpt index 0f062f0035..627b9ba256 100644 --- a/ext/mysqli/tests/bug70384.phpt +++ b/ext/mysqli/tests/bug70384.phpt @@ -2,20 +2,20 @@ 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 @@ -56,7 +56,7 @@ mysqli_float_handling - ensure 4 byte float is handled correctly ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- OK diff --git a/ext/mysqli/tests/bug70949.phpt b/ext/mysqli/tests/bug70949.phpt index dc7b202152..c3b53bcf16 100644 --- a/ext/mysqli/tests/bug70949.phpt +++ b/ext/mysqli/tests/bug70949.phpt @@ -6,7 +6,7 @@ require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); require_once("connect.inc"); if (!$IS_MYSQLND) { - die("skip mysqlnd only test"); + die("skip mysqlnd only test"); } ?> --FILE-- @@ -51,7 +51,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/bug71863.phpt b/ext/mysqli/tests/bug71863.phpt index 18465e996b..1490f9fe96 100644 --- a/ext/mysqli/tests/bug71863.phpt +++ b/ext/mysqli/tests/bug71863.phpt @@ -6,7 +6,7 @@ require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); require_once("connect.inc"); if (!$IS_MYSQLND) { - die("skip mysqlnd only test"); + die("skip mysqlnd only test"); } ?> --FILE-- diff --git a/ext/mysqli/tests/bug72701.phpt b/ext/mysqli/tests/bug72701.phpt index f0eb174172..e60d0ad65b 100644 --- a/ext/mysqli/tests/bug72701.phpt +++ b/ext/mysqli/tests/bug72701.phpt @@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc'); 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"); } ?> diff --git a/ext/mysqli/tests/bug76386.phpt b/ext/mysqli/tests/bug76386.phpt index 2f5ded1de4..4ec4124d09 100644 --- a/ext/mysqli/tests/bug76386.phpt +++ b/ext/mysqli/tests/bug76386.phpt @@ -8,11 +8,11 @@ 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"); + 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); ?> diff --git a/ext/mysqli/tests/bug77956.phpt b/ext/mysqli/tests/bug77956.phpt index 6c752299d4..b1f3b1eb40 100644 --- a/ext/mysqli/tests/bug77956.phpt +++ b/ext/mysqli/tests/bug77956.phpt @@ -7,39 +7,39 @@ require_once('skipifconnectfailure.inc'); $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 diff --git a/ext/mysqli/tests/clean_table.inc b/ext/mysqli/tests/clean_table.inc index 86e5fcb379..a3dc8b66de 100644 --- a/ext/mysqli/tests/clean_table.inc +++ b/ext/mysqli/tests/clean_table.inc @@ -2,12 +2,12 @@ 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); diff --git a/ext/mysqli/tests/connect.inc b/ext/mysqli/tests/connect.inc index 6af574ad0f..103ad6804c 100644 --- a/ext/mysqli/tests/connect.inc +++ b/ext/mysqli/tests/connect.inc @@ -1,150 +1,150 @@ <?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; + } ?> diff --git a/ext/mysqli/tests/gracefull_fail_on_empty_result_set.phpt b/ext/mysqli/tests/gracefull_fail_on_empty_result_set.phpt index e37e22887a..35a9facd06 100644 --- a/ext/mysqli/tests/gracefull_fail_on_empty_result_set.phpt +++ b/ext/mysqli/tests/gracefull_fail_on_empty_result_set.phpt @@ -27,7 +27,7 @@ require_once('skipifconnectfailure.inc'); === DONE ===
--CLEAN--
<?php
- require_once("clean_table.inc");
+ require_once("clean_table.inc");
?>
--EXPECT--
bool(false)
diff --git a/ext/mysqli/tests/local_infile_tools.inc b/ext/mysqli/tests/local_infile_tools.inc index af66d4c20c..fef400d0a9 100644 --- a/ext/mysqli/tests/local_infile_tools.inc +++ b/ext/mysqli/tests/local_infile_tools.inc @@ -1,146 +1,146 @@ <?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; + } ?> diff --git a/ext/mysqli/tests/mysqli_affected_rows.phpt b/ext/mysqli/tests/mysqli_affected_rows.phpt index 95c3bb3426..7d90817769 100644 --- a/ext/mysqli/tests/mysqli_affected_rows.phpt +++ b/ext/mysqli/tests/mysqli_affected_rows.phpt @@ -2,9 +2,9 @@ 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 @@ -129,7 +129,7 @@ mysqli_affected_rows() ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_affected_rows_oo.phpt b/ext/mysqli/tests/mysqli_affected_rows_oo.phpt index 7a6a5be996..51c82de87e 100644 --- a/ext/mysqli/tests/mysqli_affected_rows_oo.phpt +++ b/ext/mysqli/tests/mysqli_affected_rows_oo.phpt @@ -2,9 +2,9 @@ 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 @@ -108,7 +108,7 @@ mysqli->affected_rows ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_auth_pam.phpt b/ext/mysqli/tests/mysqli_auth_pam.phpt index 30d2da5675..778e36f69c 100644 --- a/ext/mysqli/tests/mysqli_auth_pam.phpt +++ b/ext/mysqli/tests/mysqli_auth_pam.phpt @@ -7,22 +7,22 @@ require_once('skipifemb.inc'); 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(); @@ -34,52 +34,52 @@ mysqli_query($link, 'DROP USER pamtest'); 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 diff --git a/ext/mysqli/tests/mysqli_autocommit.phpt b/ext/mysqli/tests/mysqli_autocommit.phpt index ce470fce72..96fd838850 100644 --- a/ext/mysqli/tests/mysqli_autocommit.phpt +++ b/ext/mysqli/tests/mysqli_autocommit.phpt @@ -2,18 +2,18 @@ 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 @@ -141,7 +141,7 @@ mysqli_autocommit() ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_autocommit_oo.phpt b/ext/mysqli/tests/mysqli_autocommit_oo.phpt index 93ab10e605..80fd6c3039 100644 --- a/ext/mysqli/tests/mysqli_autocommit_oo.phpt +++ b/ext/mysqli/tests/mysqli_autocommit_oo.phpt @@ -2,19 +2,19 @@ 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 @@ -131,7 +131,7 @@ mysqli->autocommit() ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_begin_transaction.phpt b/ext/mysqli/tests/mysqli_begin_transaction.phpt index e3c36a2286..59c8277a5f 100644 --- a/ext/mysqli/tests/mysqli_begin_transaction.phpt +++ b/ext/mysqli/tests/mysqli_begin_transaction.phpt @@ -8,10 +8,10 @@ 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 @@ -116,7 +116,7 @@ if (!have_innodb($link)) ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- NULL diff --git a/ext/mysqli/tests/mysqli_change_user_get_lock.phpt b/ext/mysqli/tests/mysqli_change_user_get_lock.phpt index 4cc071d7ab..75d0930a83 100644 --- a/ext/mysqli/tests/mysqli_change_user_get_lock.phpt +++ b/ext/mysqli/tests/mysqli_change_user_get_lock.phpt @@ -11,87 +11,87 @@ die("skip - is the server still buggy?"); 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 diff --git a/ext/mysqli/tests/mysqli_change_user_insert_id.phpt b/ext/mysqli/tests/mysqli_change_user_insert_id.phpt index d25e09b2f5..960fd8dfea 100644 --- a/ext/mysqli/tests/mysqli_change_user_insert_id.phpt +++ b/ext/mysqli/tests/mysqli_change_user_insert_id.phpt @@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc'); 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-- @@ -59,7 +59,7 @@ if (!$IS_MYSQLND) { ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_change_user_locks_temporary.phpt b/ext/mysqli/tests/mysqli_change_user_locks_temporary.phpt index fa8c66f56b..a696743145 100644 --- a/ext/mysqli/tests/mysqli_change_user_locks_temporary.phpt +++ b/ext/mysqli/tests/mysqli_change_user_locks_temporary.phpt @@ -101,7 +101,7 @@ die("skip - is the server still buggy?"); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_change_user_new.phpt b/ext/mysqli/tests/mysqli_change_user_new.phpt index e9ef937406..47a80a288f 100644 --- a/ext/mysqli/tests/mysqli_change_user_new.phpt +++ b/ext/mysqli/tests/mysqli_change_user_new.phpt @@ -7,11 +7,11 @@ 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 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 diff --git a/ext/mysqli/tests/mysqli_change_user_old.phpt b/ext/mysqli/tests/mysqli_change_user_old.phpt index a077d9c4b6..18c5dd08af 100644 --- a/ext/mysqli/tests/mysqli_change_user_old.phpt +++ b/ext/mysqli/tests/mysqli_change_user_old.phpt @@ -7,11 +7,11 @@ 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 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 diff --git a/ext/mysqli/tests/mysqli_change_user_oo.phpt b/ext/mysqli/tests/mysqli_change_user_oo.phpt index 7707cca095..00922a670b 100644 --- a/ext/mysqli/tests/mysqli_change_user_oo.phpt +++ b/ext/mysqli/tests/mysqli_change_user_oo.phpt @@ -8,11 +8,11 @@ require_once('skipifconnectfailure.inc'); 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 diff --git a/ext/mysqli/tests/mysqli_change_user_rollback.phpt b/ext/mysqli/tests/mysqli_change_user_rollback.phpt index 1731abafef..9422c4ed05 100644 --- a/ext/mysqli/tests/mysqli_change_user_rollback.phpt +++ b/ext/mysqli/tests/mysqli_change_user_rollback.phpt @@ -7,10 +7,10 @@ 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())); + 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 @@ -64,7 +64,7 @@ if (!have_innodb($link)) ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_change_user_set_names.phpt b/ext/mysqli/tests/mysqli_change_user_set_names.phpt index 614aa7a023..2c063af633 100644 --- a/ext/mysqli/tests/mysqli_change_user_set_names.phpt +++ b/ext/mysqli/tests/mysqli_change_user_set_names.phpt @@ -7,19 +7,19 @@ require_once('skipifemb.inc'); 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 diff --git a/ext/mysqli/tests/mysqli_character_set.phpt b/ext/mysqli/tests/mysqli_character_set.phpt index 855141e40d..52371d78e8 100644 --- a/ext/mysqli/tests/mysqli_character_set.phpt +++ b/ext/mysqli/tests/mysqli_character_set.phpt @@ -7,7 +7,7 @@ require_once('skipifconnectfailure.inc'); 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-- @@ -101,7 +101,7 @@ if (!function_exists('mysqli_set_charset')) { ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_character_set_name_oo.phpt b/ext/mysqli/tests/mysqli_character_set_name_oo.phpt index 5d303fd503..562d8abefa 100644 --- a/ext/mysqli/tests/mysqli_character_set_name_oo.phpt +++ b/ext/mysqli/tests/mysqli_character_set_name_oo.phpt @@ -2,9 +2,9 @@ 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 diff --git a/ext/mysqli/tests/mysqli_class_mysqli_driver_reflection.phpt b/ext/mysqli/tests/mysqli_class_mysqli_driver_reflection.phpt index 7b6c0a65d9..3e0cd8a7c1 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_driver_reflection.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_driver_reflection.phpt @@ -12,7 +12,7 @@ Most of the things which we test are covered by mysqli_class_*_interface.phpt. 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 diff --git a/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt b/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt index 47beb1d79b..149356ac05 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt @@ -12,7 +12,7 @@ Most of the things which we test are covered by mysqli_class_*_interface.phpt. 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-- diff --git a/ext/mysqli/tests/mysqli_class_mysqli_result_reflection.phpt b/ext/mysqli/tests/mysqli_class_mysqli_result_reflection.phpt index b3b7759ace..0383d704f6 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_result_reflection.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_result_reflection.phpt @@ -13,7 +13,7 @@ Most of the things which we test are covered by mysqli_class_*_interface.phpt. 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 diff --git a/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt b/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt index 8fc4583a4c..2adef27c3a 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt @@ -2,9 +2,9 @@ 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 diff --git a/ext/mysqli/tests/mysqli_class_mysqli_warning.phpt b/ext/mysqli/tests/mysqli_class_mysqli_warning.phpt index 4d3c883e45..bdeee4903f 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_warning.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_warning.phpt @@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc'); require_once('connect.inc'); if (!$TEST_EXPERIMENTAL) - die("skip - experimental (= unsupported) feature"); + die("skip - experimental (= unsupported) feature"); ?> --FILE-- <?php @@ -91,7 +91,7 @@ if (!$TEST_EXPERIMENTAL) ?> --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 diff --git a/ext/mysqli/tests/mysqli_class_mysqli_warning_reflection.phpt b/ext/mysqli/tests/mysqli_class_mysqli_warning_reflection.phpt index f57945e589..c2093353aa 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_warning_reflection.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_warning_reflection.phpt @@ -12,7 +12,7 @@ Most of the things which we test are covered by mysqli_class_*_interface.phpt. 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 diff --git a/ext/mysqli/tests/mysqli_commit.phpt b/ext/mysqli/tests/mysqli_commit.phpt index 2fd3745d85..17a976f144 100644 --- a/ext/mysqli/tests/mysqli_commit.phpt +++ b/ext/mysqli/tests/mysqli_commit.phpt @@ -8,10 +8,10 @@ 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 @@ -71,7 +71,7 @@ if (!have_innodb($link)) ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_commit_oo.phpt b/ext/mysqli/tests/mysqli_commit_oo.phpt index 46069fd425..4b55ab3de1 100644 --- a/ext/mysqli/tests/mysqli_commit_oo.phpt +++ b/ext/mysqli/tests/mysqli_commit_oo.phpt @@ -8,10 +8,10 @@ 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 @@ -98,7 +98,7 @@ if (!have_innodb($link)) ?> --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 diff --git a/ext/mysqli/tests/mysqli_connect_attr.phpt b/ext/mysqli/tests/mysqli_connect_attr.phpt index 96c79b1a6b..97adfdcc51 100644 --- a/ext/mysqli/tests/mysqli_connect_attr.phpt +++ b/ext/mysqli/tests/mysqli_connect_attr.phpt @@ -6,10 +6,10 @@ 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 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';")) diff --git a/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt b/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt index 8204d0f1da..4b9d2096d0 100644 --- a/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt +++ b/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt @@ -2,13 +2,13 @@ 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 diff --git a/ext/mysqli/tests/mysqli_constants.phpt b/ext/mysqli/tests/mysqli_constants.phpt index 1994a5ec96..b281a9c9c5 100644 --- a/ext/mysqli/tests/mysqli_constants.phpt +++ b/ext/mysqli/tests/mysqli_constants.phpt @@ -10,234 +10,234 @@ require_once('skipifconnectfailure.inc'); 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! diff --git a/ext/mysqli/tests/mysqli_data_seek.phpt b/ext/mysqli/tests/mysqli_data_seek.phpt index 9bc3b12f73..656ca8545b 100644 --- a/ext/mysqli/tests/mysqli_data_seek.phpt +++ b/ext/mysqli/tests/mysqli_data_seek.phpt @@ -65,7 +65,7 @@ require_once('skipifconnectfailure.inc'); ?> --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 diff --git a/ext/mysqli/tests/mysqli_data_seek_oo.phpt b/ext/mysqli/tests/mysqli_data_seek_oo.phpt index 7fb14f0956..1940e1557c 100644 --- a/ext/mysqli/tests/mysqli_data_seek_oo.phpt +++ b/ext/mysqli/tests/mysqli_data_seek_oo.phpt @@ -74,7 +74,7 @@ require_once('skipifconnectfailure.inc'); ?> --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 diff --git a/ext/mysqli/tests/mysqli_debug.phpt b/ext/mysqli/tests/mysqli_debug.phpt index aa455d7f6e..e405e3d8c7 100644 --- a/ext/mysqli/tests/mysqli_debug.phpt +++ b/ext/mysqli/tests/mysqli_debug.phpt @@ -7,13 +7,13 @@ require_once('skipifemb.inc'); 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 @@ -63,7 +63,7 @@ if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED) ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- done%s diff --git a/ext/mysqli/tests/mysqli_debug_append.phpt b/ext/mysqli/tests/mysqli_debug_append.phpt index 8c934eabac..13f5d26320 100644 --- a/ext/mysqli/tests/mysqli_debug_append.phpt +++ b/ext/mysqli/tests/mysqli_debug_append.phpt @@ -7,16 +7,16 @@ require_once('skipifemb.inc'); 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"); ?> @@ -89,7 +89,7 @@ if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test is not for Windows platfo ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- done%s diff --git a/ext/mysqli/tests/mysqli_debug_control_string.phpt b/ext/mysqli/tests/mysqli_debug_control_string.phpt index 42a802d81a..8c860acef7 100644 --- a/ext/mysqli/tests/mysqli_debug_control_string.phpt +++ b/ext/mysqli/tests/mysqli_debug_control_string.phpt @@ -7,16 +7,16 @@ require_once('skipifemb.inc'); 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 diff --git a/ext/mysqli/tests/mysqli_debug_ini.phpt b/ext/mysqli/tests/mysqli_debug_ini.phpt index f1a37bf882..8bffedd8e5 100644 --- a/ext/mysqli/tests/mysqli_debug_ini.phpt +++ b/ext/mysqli/tests/mysqli_debug_ini.phpt @@ -7,46 +7,46 @@ require_once('skipifemb.inc'); 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" diff --git a/ext/mysqli/tests/mysqli_debug_mysqlnd_control_string.phpt b/ext/mysqli/tests/mysqli_debug_mysqlnd_control_string.phpt index 3aa0f7cb89..938d7205dc 100644 --- a/ext/mysqli/tests/mysqli_debug_mysqlnd_control_string.phpt +++ b/ext/mysqli/tests/mysqli_debug_mysqlnd_control_string.phpt @@ -7,16 +7,16 @@ require_once('skipifemb.inc'); 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 @@ -223,7 +223,7 @@ if (!$IS_MYSQLND) ?> --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. diff --git a/ext/mysqli/tests/mysqli_debug_mysqlnd_only.phpt b/ext/mysqli/tests/mysqli_debug_mysqlnd_only.phpt index 333aaa10c0..8343a99048 100644 --- a/ext/mysqli/tests/mysqli_debug_mysqlnd_only.phpt +++ b/ext/mysqli/tests/mysqli_debug_mysqlnd_only.phpt @@ -8,16 +8,16 @@ require_once('skipifconnectfailure.inc'); 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 @@ -126,7 +126,7 @@ if (!$IS_MYSQLND) ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_disable_reads_from_master.phpt b/ext/mysqli/tests/mysqli_disable_reads_from_master.phpt index 268bd619cb..5f1c1b8b17 100644 --- a/ext/mysqli/tests/mysqli_disable_reads_from_master.phpt +++ b/ext/mysqli/tests/mysqli_disable_reads_from_master.phpt @@ -7,7 +7,7 @@ require_once('skipifemb.inc'); 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-- @@ -40,7 +40,7 @@ if (!function_exists('mysqli_disable_reads_from_master')) { ?> --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 diff --git a/ext/mysqli/tests/mysqli_enable_reads_from_master.phpt b/ext/mysqli/tests/mysqli_enable_reads_from_master.phpt index 17b4b37529..88da02bdc1 100644 --- a/ext/mysqli/tests/mysqli_enable_reads_from_master.phpt +++ b/ext/mysqli/tests/mysqli_enable_reads_from_master.phpt @@ -7,7 +7,7 @@ require_once('skipifemb.inc'); 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-- diff --git a/ext/mysqli/tests/mysqli_expire_password.phpt b/ext/mysqli/tests/mysqli_expire_password.phpt index 679e210f92..f193add0be 100644 --- a/ext/mysqli/tests/mysqli_expire_password.phpt +++ b/ext/mysqli/tests/mysqli_expire_password.phpt @@ -7,45 +7,45 @@ require_once('skipifemb.inc'); 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-- @@ -118,9 +118,9 @@ if (!mysqli_query($link, sprintf("GRANT SELECT ON TABLE %s.test TO expiretest@'% ?> --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 diff --git a/ext/mysqli/tests/mysqli_explain_metadata.phpt b/ext/mysqli/tests/mysqli_explain_metadata.phpt index 157559b340..a6cad18410 100644 --- a/ext/mysqli/tests/mysqli_explain_metadata.phpt +++ b/ext/mysqli/tests/mysqli_explain_metadata.phpt @@ -157,7 +157,7 @@ if (!$IS_MYSQLND) ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_fetch_all.phpt b/ext/mysqli/tests/mysqli_fetch_all.phpt index f9a7ee3770..27116b63a6 100644 --- a/ext/mysqli/tests/mysqli_fetch_all.phpt +++ b/ext/mysqli/tests/mysqli_fetch_all.phpt @@ -6,7 +6,7 @@ require_once('skipif.inc'); 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 @@ -323,7 +323,7 @@ if (!function_exists('mysqli_fetch_all')) ?> --CLEAN-- <?php - // require_once("clean_table.inc"); + // require_once("clean_table.inc"); ?> --EXPECTF-- [005] diff --git a/ext/mysqli/tests/mysqli_fetch_all_oo.phpt b/ext/mysqli/tests/mysqli_fetch_all_oo.phpt index 9dac357ae1..02a6e15123 100644 --- a/ext/mysqli/tests/mysqli_fetch_all_oo.phpt +++ b/ext/mysqli/tests/mysqli_fetch_all_oo.phpt @@ -7,7 +7,7 @@ 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 @@ -305,7 +305,7 @@ if (!function_exists('mysqli_fetch_all')) ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- [005] diff --git a/ext/mysqli/tests/mysqli_fetch_array_assoc.phpt b/ext/mysqli/tests/mysqli_fetch_array_assoc.phpt index 4701926d6c..fe73d780f3 100644 --- a/ext/mysqli/tests/mysqli_fetch_array_assoc.phpt +++ b/ext/mysqli/tests/mysqli_fetch_array_assoc.phpt @@ -29,7 +29,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- [002] diff --git a/ext/mysqli/tests/mysqli_fetch_array_large.phpt b/ext/mysqli/tests/mysqli_fetch_array_large.phpt index 3c6a0f03f3..59d5669126 100644 --- a/ext/mysqli/tests/mysqli_fetch_array_large.phpt +++ b/ext/mysqli/tests/mysqli_fetch_array_large.phpt @@ -9,155 +9,155 @@ require_once('skipifconnectfailure.inc'); 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 diff --git a/ext/mysqli/tests/mysqli_fetch_array_many_rows.phpt b/ext/mysqli/tests/mysqli_fetch_array_many_rows.phpt index d372ef5574..29412521ce 100644 --- a/ext/mysqli/tests/mysqli_fetch_array_many_rows.phpt +++ b/ext/mysqli/tests/mysqli_fetch_array_many_rows.phpt @@ -109,7 +109,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_fetch_array_oo.phpt b/ext/mysqli/tests/mysqli_fetch_array_oo.phpt index b0e2234960..634ee96358 100644 --- a/ext/mysqli/tests/mysqli_fetch_array_oo.phpt +++ b/ext/mysqli/tests/mysqli_fetch_array_oo.phpt @@ -278,7 +278,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- [005] diff --git a/ext/mysqli/tests/mysqli_fetch_assoc.phpt b/ext/mysqli/tests/mysqli_fetch_assoc.phpt index 6b98b5f51c..6ae91ad74a 100644 --- a/ext/mysqli/tests/mysqli_fetch_assoc.phpt +++ b/ext/mysqli/tests/mysqli_fetch_assoc.phpt @@ -69,7 +69,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- [005] diff --git a/ext/mysqli/tests/mysqli_fetch_assoc_bit.phpt b/ext/mysqli/tests/mysqli_fetch_assoc_bit.phpt index 586bfb03b3..2e45def227 100644 --- a/ext/mysqli/tests/mysqli_fetch_assoc_bit.phpt +++ b/ext/mysqli/tests/mysqli_fetch_assoc_bit.phpt @@ -2,18 +2,18 @@ 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 @@ -111,7 +111,7 @@ mysqli_fetch_assoc() - BIT ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_fetch_assoc_no_alias_utf8.phpt b/ext/mysqli/tests/mysqli_fetch_assoc_no_alias_utf8.phpt index fdbf222df8..af535a803f 100644 --- a/ext/mysqli/tests/mysqli_fetch_assoc_no_alias_utf8.phpt +++ b/ext/mysqli/tests/mysqli_fetch_assoc_no_alias_utf8.phpt @@ -2,36 +2,36 @@ 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 diff --git a/ext/mysqli/tests/mysqli_fetch_assoc_oo.phpt b/ext/mysqli/tests/mysqli_fetch_assoc_oo.phpt index e4f6465176..d06d6d5705 100644 --- a/ext/mysqli/tests/mysqli_fetch_assoc_oo.phpt +++ b/ext/mysqli/tests/mysqli_fetch_assoc_oo.phpt @@ -56,7 +56,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- [005] diff --git a/ext/mysqli/tests/mysqli_fetch_assoc_zerofill.phpt b/ext/mysqli/tests/mysqli_fetch_assoc_zerofill.phpt index 551877e800..e5e0fdf4d9 100644 --- a/ext/mysqli/tests/mysqli_fetch_assoc_zerofill.phpt +++ b/ext/mysqli/tests/mysqli_fetch_assoc_zerofill.phpt @@ -72,7 +72,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_fetch_field.phpt b/ext/mysqli/tests/mysqli_fetch_field.phpt index 684795a48e..4c6276ddf8 100644 --- a/ext/mysqli/tests/mysqli_fetch_field.phpt +++ b/ext/mysqli/tests/mysqli_fetch_field.phpt @@ -84,7 +84,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- object(stdClass)#%d (13) { diff --git a/ext/mysqli/tests/mysqli_fetch_field_direct.phpt b/ext/mysqli/tests/mysqli_fetch_field_direct.phpt index be883ef625..4ed1bef8a1 100644 --- a/ext/mysqli/tests/mysqli_fetch_field_direct.phpt +++ b/ext/mysqli/tests/mysqli_fetch_field_direct.phpt @@ -42,7 +42,7 @@ require_once('skipifconnectfailure.inc'); ?> --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 diff --git a/ext/mysqli/tests/mysqli_fetch_field_direct_oo.phpt b/ext/mysqli/tests/mysqli_fetch_field_direct_oo.phpt index c240050e17..98440079d5 100644 --- a/ext/mysqli/tests/mysqli_fetch_field_direct_oo.phpt +++ b/ext/mysqli/tests/mysqli_fetch_field_direct_oo.phpt @@ -51,7 +51,7 @@ require_once('skipifconnectfailure.inc'); ?> --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 diff --git a/ext/mysqli/tests/mysqli_fetch_field_flags.phpt b/ext/mysqli/tests/mysqli_fetch_field_flags.phpt index 169c5d653f..4eb2d007dd 100644 --- a/ext/mysqli/tests/mysqli_fetch_field_flags.phpt +++ b/ext/mysqli/tests/mysqli_fetch_field_flags.phpt @@ -8,10 +8,10 @@ require_once('skipifconnectfailure.inc'); 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); ?> @@ -220,7 +220,7 @@ mysqli_close($link); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_fetch_field_oo.phpt b/ext/mysqli/tests/mysqli_fetch_field_oo.phpt index 2293c9581a..eb5d37922e 100644 --- a/ext/mysqli/tests/mysqli_fetch_field_oo.phpt +++ b/ext/mysqli/tests/mysqli_fetch_field_oo.phpt @@ -67,7 +67,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- object(stdClass)#%d (13) { diff --git a/ext/mysqli/tests/mysqli_fetch_field_types.phpt b/ext/mysqli/tests/mysqli_fetch_field_types.phpt index 31661bdda2..6b8248e02d 100644 --- a/ext/mysqli/tests/mysqli_fetch_field_types.phpt +++ b/ext/mysqli/tests/mysqli_fetch_field_types.phpt @@ -120,7 +120,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_fetch_fields.phpt b/ext/mysqli/tests/mysqli_fetch_fields.phpt index c79555c3a1..8bf1f5ee15 100644 --- a/ext/mysqli/tests/mysqli_fetch_fields.phpt +++ b/ext/mysqli/tests/mysqli_fetch_fields.phpt @@ -63,7 +63,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- object(stdClass)#%d (13) { diff --git a/ext/mysqli/tests/mysqli_fetch_lengths.phpt b/ext/mysqli/tests/mysqli_fetch_lengths.phpt index 85921f800d..aa7d1aaa2d 100644 --- a/ext/mysqli/tests/mysqli_fetch_lengths.phpt +++ b/ext/mysqli/tests/mysqli_fetch_lengths.phpt @@ -40,7 +40,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- bool(false) diff --git a/ext/mysqli/tests/mysqli_fetch_lengths_oo.phpt b/ext/mysqli/tests/mysqli_fetch_lengths_oo.phpt index c352bea8a0..ef06436c26 100644 --- a/ext/mysqli/tests/mysqli_fetch_lengths_oo.phpt +++ b/ext/mysqli/tests/mysqli_fetch_lengths_oo.phpt @@ -30,10 +30,10 @@ require_once('skipifconnectfailure.inc'); ?> --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 diff --git a/ext/mysqli/tests/mysqli_fetch_object.phpt b/ext/mysqli/tests/mysqli_fetch_object.phpt index 09ea19161a..b6decf9cb8 100644 --- a/ext/mysqli/tests/mysqli_fetch_object.phpt +++ b/ext/mysqli/tests/mysqli_fetch_object.phpt @@ -142,7 +142,7 @@ require_once('skipifconnectfailure.inc'); ?> --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 diff --git a/ext/mysqli/tests/mysqli_fetch_object_no_constructor.phpt b/ext/mysqli/tests/mysqli_fetch_object_no_constructor.phpt index cb9f98cfa6..8967e7e4fe 100644 --- a/ext/mysqli/tests/mysqli_fetch_object_no_constructor.phpt +++ b/ext/mysqli/tests/mysqli_fetch_object_no_constructor.phpt @@ -46,7 +46,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- No exception with PHP: diff --git a/ext/mysqli/tests/mysqli_fetch_object_no_object.phpt b/ext/mysqli/tests/mysqli_fetch_object_no_object.phpt index c8e2b8508e..77db2b6340 100644 --- a/ext/mysqli/tests/mysqli_fetch_object_no_object.phpt +++ b/ext/mysqli/tests/mysqli_fetch_object_no_object.phpt @@ -20,7 +20,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- %s(6) "object" diff --git a/ext/mysqli/tests/mysqli_fetch_object_oo.phpt b/ext/mysqli/tests/mysqli_fetch_object_oo.phpt index d8c8cc70fd..dffa2a9f2b 100644 --- a/ext/mysqli/tests/mysqli_fetch_object_oo.phpt +++ b/ext/mysqli/tests/mysqli_fetch_object_oo.phpt @@ -126,7 +126,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- [E_WARNING] mysqli_result::__construct(): invalid object or resource mysql%s diff --git a/ext/mysqli/tests/mysqli_fetch_row.phpt b/ext/mysqli/tests/mysqli_fetch_row.phpt index 7ca1b9a132..802e214212 100644 --- a/ext/mysqli/tests/mysqli_fetch_row.phpt +++ b/ext/mysqli/tests/mysqli_fetch_row.phpt @@ -39,7 +39,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- [004] diff --git a/ext/mysqli/tests/mysqli_field_count.phpt b/ext/mysqli/tests/mysqli_field_count.phpt index d6581c6699..7817d70aff 100644 --- a/ext/mysqli/tests/mysqli_field_count.phpt +++ b/ext/mysqli/tests/mysqli_field_count.phpt @@ -49,7 +49,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- int(0) diff --git a/ext/mysqli/tests/mysqli_field_seek.phpt b/ext/mysqli/tests/mysqli_field_seek.phpt index c34cf3f647..95100d7afb 100644 --- a/ext/mysqli/tests/mysqli_field_seek.phpt +++ b/ext/mysqli/tests/mysqli_field_seek.phpt @@ -121,7 +121,7 @@ require_once('skipifconnectfailure.inc'); ?> --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 diff --git a/ext/mysqli/tests/mysqli_field_tell.phpt b/ext/mysqli/tests/mysqli_field_tell.phpt index 9885c1d9d8..4c461660ce 100644 --- a/ext/mysqli/tests/mysqli_field_tell.phpt +++ b/ext/mysqli/tests/mysqli_field_tell.phpt @@ -56,7 +56,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- int(0) diff --git a/ext/mysqli/tests/mysqli_fork.phpt b/ext/mysqli/tests/mysqli_fork.phpt index cc4c72f561..bb9cc7adf4 100644 --- a/ext/mysqli/tests/mysqli_fork.phpt +++ b/ext/mysqli/tests/mysqli_fork.phpt @@ -7,17 +7,17 @@ require_once('skipifemb.inc'); 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 @@ -229,10 +229,10 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/mysqli_free_result.phpt b/ext/mysqli/tests/mysqli_free_result.phpt index 6cd7778319..45957aae48 100644 --- a/ext/mysqli/tests/mysqli_free_result.phpt +++ b/ext/mysqli/tests/mysqli_free_result.phpt @@ -52,7 +52,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- a diff --git a/ext/mysqli/tests/mysqli_get_charset.phpt b/ext/mysqli/tests/mysqli_get_charset.phpt index 537809dd70..5a55716582 100644 --- a/ext/mysqli/tests/mysqli_get_charset.phpt +++ b/ext/mysqli/tests/mysqli_get_charset.phpt @@ -6,7 +6,7 @@ require_once('skipif.inc'); 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 @@ -108,7 +108,7 @@ if (!function_exists('mysqli_get_charset')) ?> --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 diff --git a/ext/mysqli/tests/mysqli_get_client_stats.phpt b/ext/mysqli/tests/mysqli_get_client_stats.phpt index f7de44b1db..948212a7e9 100644 --- a/ext/mysqli/tests/mysqli_get_client_stats.phpt +++ b/ext/mysqli/tests/mysqli_get_client_stats.phpt @@ -6,7 +6,7 @@ require_once('skipif.inc'); 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-- @@ -15,909 +15,909 @@ mysqlnd.collect_memory_statistics=1 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 diff --git a/ext/mysqli/tests/mysqli_get_client_stats_implicit_free.phpt b/ext/mysqli/tests/mysqli_get_client_stats_implicit_free.phpt index 9c889caf8f..b945db128f 100644 --- a/ext/mysqli/tests/mysqli_get_client_stats_implicit_free.phpt +++ b/ext/mysqli/tests/mysqli_get_client_stats_implicit_free.phpt @@ -6,7 +6,7 @@ require_once('skipif.inc'); 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-- @@ -14,27 +14,27 @@ mysqlnd.collect_statistics=1 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 diff --git a/ext/mysqli/tests/mysqli_get_client_stats_off.phpt b/ext/mysqli/tests/mysqli_get_client_stats_off.phpt index 5d9b2aad94..edb868054d 100644 --- a/ext/mysqli/tests/mysqli_get_client_stats_off.phpt +++ b/ext/mysqli/tests/mysqli_get_client_stats_off.phpt @@ -6,7 +6,7 @@ require_once('skipif.inc'); 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-- @@ -14,31 +14,31 @@ mysqlnd.collect_statistics=0 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 diff --git a/ext/mysqli/tests/mysqli_get_client_stats_ps.phpt b/ext/mysqli/tests/mysqli_get_client_stats_ps.phpt index ea1055f806..214baf8f71 100644 --- a/ext/mysqli/tests/mysqli_get_client_stats_ps.phpt +++ b/ext/mysqli/tests/mysqli_get_client_stats_ps.phpt @@ -6,7 +6,7 @@ require_once('skipif.inc'); 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-- @@ -14,80 +14,80 @@ mysqlnd.collect_statistics=1 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 diff --git a/ext/mysqli/tests/mysqli_get_client_stats_skipped.phpt b/ext/mysqli/tests/mysqli_get_client_stats_skipped.phpt index 0358656ab5..9eca46e84a 100644 --- a/ext/mysqli/tests/mysqli_get_client_stats_skipped.phpt +++ b/ext/mysqli/tests/mysqli_get_client_stats_skipped.phpt @@ -9,7 +9,7 @@ require_once('skipif.inc'); 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-- diff --git a/ext/mysqli/tests/mysqli_get_connection_stats.phpt b/ext/mysqli/tests/mysqli_get_connection_stats.phpt index 80875a44e6..be2dd150e5 100644 --- a/ext/mysqli/tests/mysqli_get_connection_stats.phpt +++ b/ext/mysqli/tests/mysqli_get_connection_stats.phpt @@ -9,7 +9,7 @@ require_once('skipif.inc'); 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-- @@ -81,7 +81,7 @@ if (!function_exists('mysqli_get_connection_stats')) { ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_get_connection_stats_off.phpt b/ext/mysqli/tests/mysqli_get_connection_stats_off.phpt index a91d84413c..4124c8c292 100644 --- a/ext/mysqli/tests/mysqli_get_connection_stats_off.phpt +++ b/ext/mysqli/tests/mysqli_get_connection_stats_off.phpt @@ -9,7 +9,7 @@ require_once('skipif.inc'); 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-- diff --git a/ext/mysqli/tests/mysqli_get_host_info.phpt b/ext/mysqli/tests/mysqli_get_host_info.phpt index ada57f7d9f..c48430ab35 100644 --- a/ext/mysqli/tests/mysqli_get_host_info.phpt +++ b/ext/mysqli/tests/mysqli_get_host_info.phpt @@ -29,7 +29,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_get_server_info.phpt b/ext/mysqli/tests/mysqli_get_server_info.phpt index 3ea1b4a70d..d56c35062c 100644 --- a/ext/mysqli/tests/mysqli_get_server_info.phpt +++ b/ext/mysqli/tests/mysqli_get_server_info.phpt @@ -27,7 +27,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_get_warnings.phpt b/ext/mysqli/tests/mysqli_get_warnings.phpt index b0076c1859..1e57bf2135 100644 --- a/ext/mysqli/tests/mysqli_get_warnings.phpt +++ b/ext/mysqli/tests/mysqli_get_warnings.phpt @@ -7,7 +7,7 @@ require_once('skipifemb.inc'); require_once('skipifconnectfailure.inc'); require_once('connect.inc'); if (!$TEST_EXPERIMENTAL) - die("skip - experimental (= unsupported) feature"); + die("skip - experimental (= unsupported) feature"); ?> --FILE-- <?php diff --git a/ext/mysqli/tests/mysqli_info.phpt b/ext/mysqli/tests/mysqli_info.phpt index 56ee2cce05..183775a8a0 100644 --- a/ext/mysqli/tests/mysqli_info.phpt +++ b/ext/mysqli/tests/mysqli_info.phpt @@ -10,87 +10,87 @@ require_once('skipifconnectfailure.inc'); 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 diff --git a/ext/mysqli/tests/mysqli_insert_id.phpt b/ext/mysqli/tests/mysqli_insert_id.phpt index 7d4c0e085c..5c56f3e37e 100644 --- a/ext/mysqli/tests/mysqli_insert_id.phpt +++ b/ext/mysqli/tests/mysqli_insert_id.phpt @@ -132,7 +132,7 @@ require_once('skipifconnectfailure.inc'); ?> --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 diff --git a/ext/mysqli/tests/mysqli_insert_id_variation.phpt b/ext/mysqli/tests/mysqli_insert_id_variation.phpt index 16797aa94b..b3f36d4cb0 100644 --- a/ext/mysqli/tests/mysqli_insert_id_variation.phpt +++ b/ext/mysqli/tests/mysqli_insert_id_variation.phpt @@ -95,7 +95,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/mysqli_insert_packet_overflow.phpt b/ext/mysqli/tests/mysqli_insert_packet_overflow.phpt index 496e5e48fe..5e9840b910 100644 --- a/ext/mysqli/tests/mysqli_insert_packet_overflow.phpt +++ b/ext/mysqli/tests/mysqli_insert_packet_overflow.phpt @@ -6,14 +6,14 @@ require_once('skipif.inc'); 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); ?> @@ -21,92 +21,92 @@ 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 diff --git a/ext/mysqli/tests/mysqli_kill.phpt b/ext/mysqli/tests/mysqli_kill.phpt index 8b4e36afd4..5e6d769cef 100644 --- a/ext/mysqli/tests/mysqli_kill.phpt +++ b/ext/mysqli/tests/mysqli_kill.phpt @@ -75,7 +75,7 @@ require_once('skipifconnectfailure.inc'); ?> --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 diff --git a/ext/mysqli/tests/mysqli_last_insert_id.phpt b/ext/mysqli/tests/mysqli_last_insert_id.phpt index d966eca05e..27ec3f3118 100644 --- a/ext/mysqli/tests/mysqli_last_insert_id.phpt +++ b/ext/mysqli/tests/mysqli_last_insert_id.phpt @@ -176,7 +176,7 @@ API vs. SQL LAST_INSERT_ID() ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- API: %d, SQL: %d diff --git a/ext/mysqli/tests/mysqli_max_links.phpt b/ext/mysqli/tests/mysqli_max_links.phpt index f3469e20e6..25f7eee25d 100644 --- a/ext/mysqli/tests/mysqli_max_links.phpt +++ b/ext/mysqli/tests/mysqli_max_links.phpt @@ -10,31 +10,31 @@ require_once('skipifconnectfailure.inc'); 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 diff --git a/ext/mysqli/tests/mysqli_more_results.phpt b/ext/mysqli/tests/mysqli_more_results.phpt index 7f0a1f748b..eed4c273cb 100644 --- a/ext/mysqli/tests/mysqli_more_results.phpt +++ b/ext/mysqli/tests/mysqli_more_results.phpt @@ -65,7 +65,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- [004] diff --git a/ext/mysqli/tests/mysqli_multi_query.phpt b/ext/mysqli/tests/mysqli_multi_query.phpt index 05f564313d..8b01fbdf88 100644 --- a/ext/mysqli/tests/mysqli_multi_query.phpt +++ b/ext/mysqli/tests/mysqli_multi_query.phpt @@ -117,7 +117,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- [006] 3 diff --git a/ext/mysqli/tests/mysqli_mysqlnd_read_timeout.phpt b/ext/mysqli/tests/mysqli_mysqlnd_read_timeout.phpt index 4f65f77480..ec424e44bd 100644 --- a/ext/mysqli/tests/mysqli_mysqlnd_read_timeout.phpt +++ b/ext/mysqli/tests/mysqli_mysqlnd_read_timeout.phpt @@ -6,8 +6,8 @@ require_once('skipif.inc'); 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 @@ -15,18 +15,18 @@ max_execution_time=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 diff --git a/ext/mysqli/tests/mysqli_mysqlnd_read_timeout_long.phpt b/ext/mysqli/tests/mysqli_mysqlnd_read_timeout_long.phpt index 7b69aff617..3bc7dd9249 100644 --- a/ext/mysqli/tests/mysqli_mysqlnd_read_timeout_long.phpt +++ b/ext/mysqli/tests/mysqli_mysqlnd_read_timeout_long.phpt @@ -7,14 +7,14 @@ require_once('skipifemb.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(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-- @@ -23,22 +23,22 @@ mysqlnd.net_read_timeout=12 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) { diff --git a/ext/mysqli/tests/mysqli_mysqlnd_read_timeout_zero.phpt b/ext/mysqli/tests/mysqli_mysqlnd_read_timeout_zero.phpt index df273c4f14..391ac60f94 100644 --- a/ext/mysqli/tests/mysqli_mysqlnd_read_timeout_zero.phpt +++ b/ext/mysqli/tests/mysqli_mysqlnd_read_timeout_zero.phpt @@ -7,14 +7,14 @@ require_once('skipifemb.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(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-- @@ -23,21 +23,21 @@ max_execution_time=10 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) { diff --git a/ext/mysqli/tests/mysqli_next_result.phpt b/ext/mysqli/tests/mysqli_next_result.phpt index 6760cbbadc..3afa51b6b5 100644 --- a/ext/mysqli/tests/mysqli_next_result.phpt +++ b/ext/mysqli/tests/mysqli_next_result.phpt @@ -70,7 +70,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- diff --git a/ext/mysqli/tests/mysqli_no_reconnect.phpt b/ext/mysqli/tests/mysqli_no_reconnect.phpt index 481f49eedf..1f7ca8d834 100644 --- a/ext/mysqli/tests/mysqli_no_reconnect.phpt +++ b/ext/mysqli/tests/mysqli_no_reconnect.phpt @@ -10,118 +10,118 @@ require_once('skipifconnectfailure.inc'); 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! diff --git a/ext/mysqli/tests/mysqli_num_fields.phpt b/ext/mysqli/tests/mysqli_num_fields.phpt index f891b309c2..a37e8d1ee9 100644 --- a/ext/mysqli/tests/mysqli_num_fields.phpt +++ b/ext/mysqli/tests/mysqli_num_fields.phpt @@ -50,7 +50,7 @@ require_once('skipifconnectfailure.inc'); ?> --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 diff --git a/ext/mysqli/tests/mysqli_num_rows.phpt b/ext/mysqli/tests/mysqli_num_rows.phpt index c6e646e4c3..bd12ffc83b 100644 --- a/ext/mysqli/tests/mysqli_num_rows.phpt +++ b/ext/mysqli/tests/mysqli_num_rows.phpt @@ -75,7 +75,7 @@ require_once('skipifconnectfailure.inc'); ?> --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 diff --git a/ext/mysqli/tests/mysqli_options_init_command.phpt b/ext/mysqli/tests/mysqli_options_init_command.phpt index 734adcf5c8..dd43a42da6 100644 --- a/ext/mysqli/tests/mysqli_options_init_command.phpt +++ b/ext/mysqli/tests/mysqli_options_init_command.phpt @@ -70,7 +70,7 @@ require_once('skipifconnectfailure.inc'); ?> --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 diff --git a/ext/mysqli/tests/mysqli_options_int_and_float_native.phpt b/ext/mysqli/tests/mysqli_options_int_and_float_native.phpt index 94acab84bb..a4f468a9bf 100644 --- a/ext/mysqli/tests/mysqli_options_int_and_float_native.phpt +++ b/ext/mysqli/tests/mysqli_options_int_and_float_native.phpt @@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc'); require_once('connect.inc'); if (!$IS_MYSQLND) - die("skip mysqlnd only test"); + die("skip mysqlnd only test"); ?> --FILE-- <?php @@ -103,7 +103,7 @@ if (!$IS_MYSQLND) ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_pam_sha256.phpt b/ext/mysqli/tests/mysqli_pam_sha256.phpt index b263939837..c85ede53f2 100644 --- a/ext/mysqli/tests/mysqli_pam_sha256.phpt +++ b/ext/mysqli/tests/mysqli_pam_sha256.phpt @@ -11,43 +11,43 @@ phpinfo(INFO_MODULES); $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'); @@ -55,24 +55,24 @@ $link->query("DROP USER shatest@localhost"); 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(); @@ -105,9 +105,9 @@ $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! diff --git a/ext/mysqli/tests/mysqli_pam_sha256_public_key_ini.phpt b/ext/mysqli/tests/mysqli_pam_sha256_public_key_ini.phpt index cd96c55ad5..e19fbb1aaf 100644 --- a/ext/mysqli/tests/mysqli_pam_sha256_public_key_ini.phpt +++ b/ext/mysqli/tests/mysqli_pam_sha256_public_key_ini.phpt @@ -11,56 +11,56 @@ phpinfo(INFO_MODULES); $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'); @@ -68,24 +68,24 @@ $link->query("DROP USER shatest@localhost"); 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(); @@ -94,25 +94,25 @@ $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 diff --git a/ext/mysqli/tests/mysqli_pam_sha256_public_key_option.phpt b/ext/mysqli/tests/mysqli_pam_sha256_public_key_option.phpt index 190158316b..0ed6ac6dd2 100644 --- a/ext/mysqli/tests/mysqli_pam_sha256_public_key_option.phpt +++ b/ext/mysqli/tests/mysqli_pam_sha256_public_key_option.phpt @@ -11,53 +11,53 @@ phpinfo(INFO_MODULES); $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'); @@ -65,24 +65,24 @@ $link->query("DROP USER shatest@localhost"); 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(); @@ -122,11 +122,11 @@ $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! diff --git a/ext/mysqli/tests/mysqli_pam_sha256_public_key_option_invalid.phpt b/ext/mysqli/tests/mysqli_pam_sha256_public_key_option_invalid.phpt index 73b2ebe95c..37b8207e97 100644 --- a/ext/mysqli/tests/mysqli_pam_sha256_public_key_option_invalid.phpt +++ b/ext/mysqli/tests/mysqli_pam_sha256_public_key_option_invalid.phpt @@ -11,53 +11,53 @@ phpinfo(INFO_MODULES); $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'); @@ -65,24 +65,24 @@ $link->query("DROP USER shatest@localhost"); 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(); @@ -166,13 +166,13 @@ $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 diff --git a/ext/mysqli/tests/mysqli_pconn_conn_multiple.phpt b/ext/mysqli/tests/mysqli_pconn_conn_multiple.phpt index f1adcf49f5..a68a6bb339 100644 --- a/ext/mysqli/tests/mysqli_pconn_conn_multiple.phpt +++ b/ext/mysqli/tests/mysqli_pconn_conn_multiple.phpt @@ -12,133 +12,133 @@ mysqli.max_persistent=-1 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) { diff --git a/ext/mysqli/tests/mysqli_pconn_disabled.phpt b/ext/mysqli/tests/mysqli_pconn_disabled.phpt index e8c592f9ff..a59a43cbd5 100644 --- a/ext/mysqli/tests/mysqli_pconn_disabled.phpt +++ b/ext/mysqli/tests/mysqli_pconn_disabled.phpt @@ -14,44 +14,44 @@ mysqli.max_persistent=2 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 diff --git a/ext/mysqli/tests/mysqli_pconn_kill.phpt b/ext/mysqli/tests/mysqli_pconn_kill.phpt index f4be4c7c7b..5fd719cf2d 100644 --- a/ext/mysqli/tests/mysqli_pconn_kill.phpt +++ b/ext/mysqli/tests/mysqli_pconn_kill.phpt @@ -12,80 +12,80 @@ mysqli.allow_persistent=1 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 diff --git a/ext/mysqli/tests/mysqli_pconn_limits.phpt b/ext/mysqli/tests/mysqli_pconn_limits.phpt index 311d8ed21e..b00b99883a 100644 --- a/ext/mysqli/tests/mysqli_pconn_limits.phpt +++ b/ext/mysqli/tests/mysqli_pconn_limits.phpt @@ -13,77 +13,77 @@ mysqli.max_persistent=-1 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 diff --git a/ext/mysqli/tests/mysqli_pconn_max_links.phpt b/ext/mysqli/tests/mysqli_pconn_max_links.phpt index 7a96d90665..a01a78a03c 100644 --- a/ext/mysqli/tests/mysqli_pconn_max_links.phpt +++ b/ext/mysqli/tests/mysqli_pconn_max_links.phpt @@ -2,42 +2,42 @@ 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 @@ -45,147 +45,147 @@ mysqli.max_persistent=2 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 diff --git a/ext/mysqli/tests/mysqli_pconn_reuse.phpt b/ext/mysqli/tests/mysqli_pconn_reuse.phpt index 926f6b797c..89600c48d9 100644 --- a/ext/mysqli/tests/mysqli_pconn_reuse.phpt +++ b/ext/mysqli/tests/mysqli_pconn_reuse.phpt @@ -14,72 +14,72 @@ mysqli.max_persistent=2 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' diff --git a/ext/mysqli/tests/mysqli_pconn_twice.phpt b/ext/mysqli/tests/mysqli_pconn_twice.phpt index ca2acd1369..e388847507 100644 --- a/ext/mysqli/tests/mysqli_pconn_twice.phpt +++ b/ext/mysqli/tests/mysqli_pconn_twice.phpt @@ -13,57 +13,57 @@ mysqli.max_persistent=-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) { diff --git a/ext/mysqli/tests/mysqli_poll.phpt b/ext/mysqli/tests/mysqli_poll.phpt index b9c66381f9..00be1c4bcb 100644 --- a/ext/mysqli/tests/mysqli_poll.phpt +++ b/ext/mysqli/tests/mysqli_poll.phpt @@ -8,7 +8,7 @@ require_once('connect.inc'); 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 diff --git a/ext/mysqli/tests/mysqli_poll_kill.phpt b/ext/mysqli/tests/mysqli_poll_kill.phpt index 7c10d13df1..26dd85be01 100644 --- a/ext/mysqli/tests/mysqli_poll_kill.phpt +++ b/ext/mysqli/tests/mysqli_poll_kill.phpt @@ -8,7 +8,7 @@ require_once('connect.inc'); 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 diff --git a/ext/mysqli/tests/mysqli_poll_mixing_insert_select.phpt b/ext/mysqli/tests/mysqli_poll_mixing_insert_select.phpt index 0bafb2cc9b..95ddd48688 100644 --- a/ext/mysqli/tests/mysqli_poll_mixing_insert_select.phpt +++ b/ext/mysqli/tests/mysqli_poll_mixing_insert_select.phpt @@ -8,7 +8,7 @@ require_once('connect.inc'); 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 @@ -166,10 +166,10 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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"); diff --git a/ext/mysqli/tests/mysqli_poll_reference.phpt b/ext/mysqli/tests/mysqli_poll_reference.phpt index ab2ed2aee8..f039546221 100644 --- a/ext/mysqli/tests/mysqli_poll_reference.phpt +++ b/ext/mysqli/tests/mysqli_poll_reference.phpt @@ -8,13 +8,13 @@ require_once('connect.inc'); 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-- diff --git a/ext/mysqli/tests/mysqli_prepare.phpt b/ext/mysqli/tests/mysqli_prepare.phpt index 0c3bedf5b5..28a8f4e48b 100644 --- a/ext/mysqli/tests/mysqli_prepare.phpt +++ b/ext/mysqli/tests/mysqli_prepare.phpt @@ -123,10 +123,10 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/mysqli_query.phpt b/ext/mysqli/tests/mysqli_query.phpt index 08145cddcf..d35ac3dae9 100644 --- a/ext/mysqli/tests/mysqli_query.phpt +++ b/ext/mysqli/tests/mysqli_query.phpt @@ -114,7 +114,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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'); diff --git a/ext/mysqli/tests/mysqli_query_iterators.phpt b/ext/mysqli/tests/mysqli_query_iterators.phpt index 81ca8c0fae..23021ee215 100644 --- a/ext/mysqli/tests/mysqli_query_iterators.phpt +++ b/ext/mysqli/tests/mysqli_query_iterators.phpt @@ -65,7 +65,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- --- Testing default --- diff --git a/ext/mysqli/tests/mysqli_query_stored_proc.phpt b/ext/mysqli/tests/mysqli_query_stored_proc.phpt index aad39cd94d..1f7e88f754 100644 --- a/ext/mysqli/tests/mysqli_query_stored_proc.phpt +++ b/ext/mysqli/tests/mysqli_query_stored_proc.phpt @@ -6,10 +6,10 @@ 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 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-- @@ -157,7 +157,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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"); diff --git a/ext/mysqli/tests/mysqli_query_unicode.phpt b/ext/mysqli/tests/mysqli_query_unicode.phpt index 819a849d94..ec7846b77d 100644 --- a/ext/mysqli/tests/mysqli_query_unicode.phpt +++ b/ext/mysqli/tests/mysqli_query_unicode.phpt @@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc'); 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); ?> diff --git a/ext/mysqli/tests/mysqli_real_connect.phpt b/ext/mysqli/tests/mysqli_real_connect.phpt index 2e39833ffe..1b0d26e7a3 100644 --- a/ext/mysqli/tests/mysqli_real_connect.phpt +++ b/ext/mysqli/tests/mysqli_real_connect.phpt @@ -10,167 +10,167 @@ require_once('skipifconnectfailure.inc'); 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 diff --git a/ext/mysqli/tests/mysqli_real_connect_pconn.phpt b/ext/mysqli/tests/mysqli_real_connect_pconn.phpt index 0d1c4985f2..4c1bfc58fa 100644 --- a/ext/mysqli/tests/mysqli_real_connect_pconn.phpt +++ b/ext/mysqli/tests/mysqli_real_connect_pconn.phpt @@ -7,7 +7,7 @@ require_once('skipifemb.inc'); 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 @@ -15,137 +15,137 @@ mysqli.allow_persistent=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 diff --git a/ext/mysqli/tests/mysqli_real_escape_string_big5.phpt b/ext/mysqli/tests/mysqli_real_escape_string_big5.phpt index 20384d9a0f..71707510d1 100644 --- a/ext/mysqli/tests/mysqli_real_escape_string_big5.phpt +++ b/ext/mysqli/tests/mysqli_real_escape_string_big5.phpt @@ -9,11 +9,11 @@ require_once('skipifconnectfailure.inc'); 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-- @@ -72,7 +72,7 @@ mysqli_error($link)); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- bool(true) diff --git a/ext/mysqli/tests/mysqli_real_escape_string_eucjpms.phpt b/ext/mysqli/tests/mysqli_real_escape_string_eucjpms.phpt index 14bf97c635..a93405e862 100644 --- a/ext/mysqli/tests/mysqli_real_escape_string_eucjpms.phpt +++ b/ext/mysqli/tests/mysqli_real_escape_string_eucjpms.phpt @@ -9,11 +9,11 @@ require_once('skipifconnectfailure.inc'); 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-- @@ -65,7 +65,7 @@ mysqli_error($link)); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- bool(true) diff --git a/ext/mysqli/tests/mysqli_real_escape_string_euckr.phpt b/ext/mysqli/tests/mysqli_real_escape_string_euckr.phpt index cff45e06d4..97c6161b25 100644 --- a/ext/mysqli/tests/mysqli_real_escape_string_euckr.phpt +++ b/ext/mysqli/tests/mysqli_real_escape_string_euckr.phpt @@ -9,11 +9,11 @@ require_once('skipifconnectfailure.inc'); 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-- @@ -64,7 +64,7 @@ mysqli_error($link)); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- bool(true) diff --git a/ext/mysqli/tests/mysqli_real_escape_string_gb2312.phpt b/ext/mysqli/tests/mysqli_real_escape_string_gb2312.phpt index 537ac7292f..2b46fa6f8c 100644 --- a/ext/mysqli/tests/mysqli_real_escape_string_gb2312.phpt +++ b/ext/mysqli/tests/mysqli_real_escape_string_gb2312.phpt @@ -9,11 +9,11 @@ require_once('skipifconnectfailure.inc'); 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-- @@ -65,7 +65,7 @@ mysqli_error($link)); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- bool(true) diff --git a/ext/mysqli/tests/mysqli_real_escape_string_gbk.phpt b/ext/mysqli/tests/mysqli_real_escape_string_gbk.phpt index 85ac847666..510621aea8 100644 --- a/ext/mysqli/tests/mysqli_real_escape_string_gbk.phpt +++ b/ext/mysqli/tests/mysqli_real_escape_string_gbk.phpt @@ -8,11 +8,11 @@ require_once('skipifconnectfailure.inc'); 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); ?> @@ -65,7 +65,7 @@ mysqli_error($link)); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- bool(true) diff --git a/ext/mysqli/tests/mysqli_real_escape_string_sjis.phpt b/ext/mysqli/tests/mysqli_real_escape_string_sjis.phpt index 9e1562dba0..4ab50b8311 100644 --- a/ext/mysqli/tests/mysqli_real_escape_string_sjis.phpt +++ b/ext/mysqli/tests/mysqli_real_escape_string_sjis.phpt @@ -8,11 +8,11 @@ require_once('skipifconnectfailure.inc'); 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-- diff --git a/ext/mysqli/tests/mysqli_real_escape_string_unicode.phpt b/ext/mysqli/tests/mysqli_real_escape_string_unicode.phpt index b3465ad2b1..be21cae80b 100644 --- a/ext/mysqli/tests/mysqli_real_escape_string_unicode.phpt +++ b/ext/mysqli/tests/mysqli_real_escape_string_unicode.phpt @@ -81,7 +81,7 @@ require_once('skipifconnectfailure.inc'); ?> --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 diff --git a/ext/mysqli/tests/mysqli_real_query.phpt b/ext/mysqli/tests/mysqli_real_query.phpt index 9b99435d42..a8deec7833 100644 --- a/ext/mysqli/tests/mysqli_real_query.phpt +++ b/ext/mysqli/tests/mysqli_real_query.phpt @@ -96,7 +96,7 @@ if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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"); diff --git a/ext/mysqli/tests/mysqli_reap_async_query.phpt b/ext/mysqli/tests/mysqli_reap_async_query.phpt index 745323c0ce..63afa87654 100644 --- a/ext/mysqli/tests/mysqli_reap_async_query.phpt +++ b/ext/mysqli/tests/mysqli_reap_async_query.phpt @@ -8,7 +8,7 @@ require_once('connect.inc'); 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 diff --git a/ext/mysqli/tests/mysqli_reconnect.phpt b/ext/mysqli/tests/mysqli_reconnect.phpt index 606d380285..44ee4cdd4d 100644 --- a/ext/mysqli/tests/mysqli_reconnect.phpt +++ b/ext/mysqli/tests/mysqli_reconnect.phpt @@ -6,125 +6,125 @@ require_once('skipif.inc'); 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! diff --git a/ext/mysqli/tests/mysqli_release_savepoint.phpt b/ext/mysqli/tests/mysqli_release_savepoint.phpt index 8f395ef6f8..af2f5740a1 100644 --- a/ext/mysqli/tests/mysqli_release_savepoint.phpt +++ b/ext/mysqli/tests/mysqli_release_savepoint.phpt @@ -8,10 +8,10 @@ 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 @@ -73,7 +73,7 @@ if (!have_innodb($link)) ?> --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 diff --git a/ext/mysqli/tests/mysqli_report_new.phpt b/ext/mysqli/tests/mysqli_report_new.phpt index 0717aaf73b..2b8a22fc4b 100644 --- a/ext/mysqli/tests/mysqli_report_new.phpt +++ b/ext/mysqli/tests/mysqli_report_new.phpt @@ -7,11 +7,11 @@ 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 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-- @@ -42,7 +42,7 @@ if (mysqli_get_server_version($link) < 50600) ?> --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 diff --git a/ext/mysqli/tests/mysqli_report_wo_ps.phpt b/ext/mysqli/tests/mysqli_report_wo_ps.phpt index 535efb1fac..9cd9254d73 100644 --- a/ext/mysqli/tests/mysqli_report_wo_ps.phpt +++ b/ext/mysqli/tests/mysqli_report_wo_ps.phpt @@ -7,11 +7,11 @@ 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 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 @@ -98,7 +98,7 @@ if (mysqli_get_server_version($link) >= 50600) ?> --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 diff --git a/ext/mysqli/tests/mysqli_result_invalid_mode.phpt b/ext/mysqli/tests/mysqli_result_invalid_mode.phpt index 29ff65780c..7649973f9a 100644 --- a/ext/mysqli/tests/mysqli_result_invalid_mode.phpt +++ b/ext/mysqli/tests/mysqli_result_invalid_mode.phpt @@ -23,7 +23,7 @@ require_once('skipifconnectfailure.inc'); ?> --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 diff --git a/ext/mysqli/tests/mysqli_result_references.phpt b/ext/mysqli/tests/mysqli_result_references.phpt index d4fe48816a..dce3930fe5 100644 --- a/ext/mysqli/tests/mysqli_result_references.phpt +++ b/ext/mysqli/tests/mysqli_result_references.phpt @@ -78,7 +78,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- array(7) refcount(2){ diff --git a/ext/mysqli/tests/mysqli_result_references_mysqlnd.phpt b/ext/mysqli/tests/mysqli_result_references_mysqlnd.phpt index 1a8f44b3f3..85a3699175 100644 --- a/ext/mysqli/tests/mysqli_result_references_mysqlnd.phpt +++ b/ext/mysqli/tests/mysqli_result_references_mysqlnd.phpt @@ -8,7 +8,7 @@ require_once('skipifconnectfailure.inc'); 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 diff --git a/ext/mysqli/tests/mysqli_rollback.phpt b/ext/mysqli/tests/mysqli_rollback.phpt index 3a15ebbb79..c1db61830a 100644 --- a/ext/mysqli/tests/mysqli_rollback.phpt +++ b/ext/mysqli/tests/mysqli_rollback.phpt @@ -2,16 +2,16 @@ 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 @@ -68,7 +68,7 @@ mysqli_rollback() ?> --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 diff --git a/ext/mysqli/tests/mysqli_savepoint.phpt b/ext/mysqli/tests/mysqli_savepoint.phpt index 866d96aa98..edf8d48601 100644 --- a/ext/mysqli/tests/mysqli_savepoint.phpt +++ b/ext/mysqli/tests/mysqli_savepoint.phpt @@ -8,10 +8,10 @@ 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 @@ -64,7 +64,7 @@ if (!have_innodb($link)) ?> --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 diff --git a/ext/mysqli/tests/mysqli_send_query.phpt b/ext/mysqli/tests/mysqli_send_query.phpt index d07985c2b7..f03125bd2f 100644 --- a/ext/mysqli/tests/mysqli_send_query.phpt +++ b/ext/mysqli/tests/mysqli_send_query.phpt @@ -6,11 +6,11 @@ require_once('skipif.inc'); 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 diff --git a/ext/mysqli/tests/mysqli_set_charset.phpt b/ext/mysqli/tests/mysqli_set_charset.phpt index df90333867..b213d8e05a 100644 --- a/ext/mysqli/tests/mysqli_set_charset.phpt +++ b/ext/mysqli/tests/mysqli_set_charset.phpt @@ -7,41 +7,41 @@ require_once('skipifemb.inc'); 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-- @@ -123,7 +123,7 @@ if ((($res = mysqli_query($link, 'SHOW CHARACTER SET LIKE "latin1"', MYSQLI_STOR ?> --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 diff --git a/ext/mysqli/tests/mysqli_sqlstate.phpt b/ext/mysqli/tests/mysqli_sqlstate.phpt index b36291872e..bb2a9201b8 100644 --- a/ext/mysqli/tests/mysqli_sqlstate.phpt +++ b/ext/mysqli/tests/mysqli_sqlstate.phpt @@ -37,7 +37,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- NULL diff --git a/ext/mysqli/tests/mysqli_ssl_set.phpt b/ext/mysqli/tests/mysqli_ssl_set.phpt index 8463cc58b8..17274cc430 100644 --- a/ext/mysqli/tests/mysqli_ssl_set.phpt +++ b/ext/mysqli/tests/mysqli_ssl_set.phpt @@ -6,7 +6,7 @@ require_once('skipif.inc'); 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 diff --git a/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt b/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt index 1e08f0dec3..33f1b896c8 100644 --- a/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt +++ b/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt @@ -243,7 +243,7 @@ require_once('skipifconnectfailure.inc'); ?> --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) diff --git a/ext/mysqli/tests/mysqli_stmt_attr_get.phpt b/ext/mysqli/tests/mysqli_stmt_attr_get.phpt index 92937a15ce..f2da9d190c 100644 --- a/ext/mysqli/tests/mysqli_stmt_attr_get.phpt +++ b/ext/mysqli/tests/mysqli_stmt_attr_get.phpt @@ -64,7 +64,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_stmt_attr_get_prefetch.phpt b/ext/mysqli/tests/mysqli_stmt_attr_get_prefetch.phpt index b48df9d410..5cb6cd0ac2 100644 --- a/ext/mysqli/tests/mysqli_stmt_attr_get_prefetch.phpt +++ b/ext/mysqli/tests/mysqli_stmt_attr_get_prefetch.phpt @@ -23,7 +23,7 @@ die("SKIP: prefetch isn't supported at the moment"); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_stmt_attr_set.phpt b/ext/mysqli/tests/mysqli_stmt_attr_set.phpt index b3d60380cb..aa13198775 100644 --- a/ext/mysqli/tests/mysqli_stmt_attr_set.phpt +++ b/ext/mysqli/tests/mysqli_stmt_attr_set.phpt @@ -271,7 +271,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_stmt_big_prepare.phpt b/ext/mysqli/tests/mysqli_stmt_big_prepare.phpt index 5ad6f583e7..b427944852 100644 --- a/ext/mysqli/tests/mysqli_stmt_big_prepare.phpt +++ b/ext/mysqli/tests/mysqli_stmt_big_prepare.phpt @@ -44,7 +44,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_stmt_bind_param.phpt b/ext/mysqli/tests/mysqli_stmt_bind_param.phpt index d2d825438e..3b8b7f2bf2 100644 --- a/ext/mysqli/tests/mysqli_stmt_bind_param.phpt +++ b/ext/mysqli/tests/mysqli_stmt_bind_param.phpt @@ -387,7 +387,7 @@ require_once('skipifconnectfailure.inc'); ?> --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 diff --git a/ext/mysqli/tests/mysqli_stmt_bind_param_call_user_func.phpt b/ext/mysqli/tests/mysqli_stmt_bind_param_call_user_func.phpt index a8a18ace85..198f6e98ff 100644 --- a/ext/mysqli/tests/mysqli_stmt_bind_param_call_user_func.phpt +++ b/ext/mysqli/tests/mysqli_stmt_bind_param_call_user_func.phpt @@ -326,7 +326,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- Regular, procedural, using variables diff --git a/ext/mysqli/tests/mysqli_stmt_bind_param_check_param_no_change.phpt b/ext/mysqli/tests/mysqli_stmt_bind_param_check_param_no_change.phpt index b8f209ef79..2c43621ff9 100644 --- a/ext/mysqli/tests/mysqli_stmt_bind_param_check_param_no_change.phpt +++ b/ext/mysqli/tests/mysqli_stmt_bind_param_check_param_no_change.phpt @@ -64,7 +64,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- Test 1: diff --git a/ext/mysqli/tests/mysqli_stmt_bind_param_many_columns.phpt b/ext/mysqli/tests/mysqli_stmt_bind_param_many_columns.phpt index 0b054c4827..efe86972d9 100644 --- a/ext/mysqli/tests/mysqli_stmt_bind_param_many_columns.phpt +++ b/ext/mysqli/tests/mysqli_stmt_bind_param_many_columns.phpt @@ -10,87 +10,87 @@ require_once('skipifconnectfailure.inc'); 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 diff --git a/ext/mysqli/tests/mysqli_stmt_bind_param_references.phpt b/ext/mysqli/tests/mysqli_stmt_bind_param_references.phpt index e7b581f815..28dcf71da1 100644 --- a/ext/mysqli/tests/mysqli_stmt_bind_param_references.phpt +++ b/ext/mysqli/tests/mysqli_stmt_bind_param_references.phpt @@ -201,7 +201,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_stmt_bind_param_type_juggling.phpt b/ext/mysqli/tests/mysqli_stmt_bind_param_type_juggling.phpt index 72adfb04e7..13bf7d4ac9 100644 --- a/ext/mysqli/tests/mysqli_stmt_bind_param_type_juggling.phpt +++ b/ext/mysqli/tests/mysqli_stmt_bind_param_type_juggling.phpt @@ -121,7 +121,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_stmt_bind_result.phpt b/ext/mysqli/tests/mysqli_stmt_bind_result.phpt index dcd05e5f68..8a43c449a0 100644 --- a/ext/mysqli/tests/mysqli_stmt_bind_result.phpt +++ b/ext/mysqli/tests/mysqli_stmt_bind_result.phpt @@ -315,7 +315,7 @@ require_once('skipifconnectfailure.inc'); ?> --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 diff --git a/ext/mysqli/tests/mysqli_stmt_bind_result_bit.phpt b/ext/mysqli/tests/mysqli_stmt_bind_result_bit.phpt index 734d691c28..ee36837407 100644 --- a/ext/mysqli/tests/mysqli_stmt_bind_result_bit.phpt +++ b/ext/mysqli/tests/mysqli_stmt_bind_result_bit.phpt @@ -153,7 +153,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_stmt_bind_result_format.phpt b/ext/mysqli/tests/mysqli_stmt_bind_result_format.phpt index 8cff6b1496..62a3e499ae 100644 --- a/ext/mysqli/tests/mysqli_stmt_bind_result_format.phpt +++ b/ext/mysqli/tests/mysqli_stmt_bind_result_format.phpt @@ -10,204 +10,204 @@ require_once('skipifconnectfailure.inc'); 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, @@ -222,116 +222,116 @@ memory_limit=83886080 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 diff --git a/ext/mysqli/tests/mysqli_stmt_bind_result_references.phpt b/ext/mysqli/tests/mysqli_stmt_bind_result_references.phpt index fec6a3f8df..4b12285333 100644 --- a/ext/mysqli/tests/mysqli_stmt_bind_result_references.phpt +++ b/ext/mysqli/tests/mysqli_stmt_bind_result_references.phpt @@ -243,7 +243,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- plain vanilla... diff --git a/ext/mysqli/tests/mysqli_stmt_bind_result_zerofill.phpt b/ext/mysqli/tests/mysqli_stmt_bind_result_zerofill.phpt index 11755b4aef..bc623de753 100644 --- a/ext/mysqli/tests/mysqli_stmt_bind_result_zerofill.phpt +++ b/ext/mysqli/tests/mysqli_stmt_bind_result_zerofill.phpt @@ -91,7 +91,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_stmt_close.phpt b/ext/mysqli/tests/mysqli_stmt_close.phpt index 6ea64e815a..4bf67c253c 100644 --- a/ext/mysqli/tests/mysqli_stmt_close.phpt +++ b/ext/mysqli/tests/mysqli_stmt_close.phpt @@ -81,7 +81,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- Warning: mysqli_stmt_close(): invalid object or resource mysqli_stmt diff --git a/ext/mysqli/tests/mysqli_stmt_data_seek.phpt b/ext/mysqli/tests/mysqli_stmt_data_seek.phpt index f9224eef62..4a5f99dac4 100644 --- a/ext/mysqli/tests/mysqli_stmt_data_seek.phpt +++ b/ext/mysqli/tests/mysqli_stmt_data_seek.phpt @@ -83,7 +83,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- Warning: mysqli_stmt_data_seek(): invalid object or resource mysqli_stmt diff --git a/ext/mysqli/tests/mysqli_stmt_datatype_change.phpt b/ext/mysqli/tests/mysqli_stmt_datatype_change.phpt index 3a1c004c2e..5043364a66 100644 --- a/ext/mysqli/tests/mysqli_stmt_datatype_change.phpt +++ b/ext/mysqli/tests/mysqli_stmt_datatype_change.phpt @@ -61,7 +61,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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); ?> diff --git a/ext/mysqli/tests/mysqli_stmt_errno.phpt b/ext/mysqli/tests/mysqli_stmt_errno.phpt index d98a98b87a..ac992bd058 100644 --- a/ext/mysqli/tests/mysqli_stmt_errno.phpt +++ b/ext/mysqli/tests/mysqli_stmt_errno.phpt @@ -61,7 +61,7 @@ require_once('skipifconnectfailure.inc'); ?> --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 diff --git a/ext/mysqli/tests/mysqli_stmt_error.phpt b/ext/mysqli/tests/mysqli_stmt_error.phpt index ad8efef602..9d22ddc877 100644 --- a/ext/mysqli/tests/mysqli_stmt_error.phpt +++ b/ext/mysqli/tests/mysqli_stmt_error.phpt @@ -61,7 +61,7 @@ require_once('skipifconnectfailure.inc'); ?> --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 diff --git a/ext/mysqli/tests/mysqli_stmt_execute.phpt b/ext/mysqli/tests/mysqli_stmt_execute.phpt index d97111a6fd..f657810321 100644 --- a/ext/mysqli/tests/mysqli_stmt_execute.phpt +++ b/ext/mysqli/tests/mysqli_stmt_execute.phpt @@ -6,10 +6,10 @@ require_once('skipif.inc'); 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-- @@ -134,7 +134,7 @@ if (mysqli_get_server_version($link) <= 40100) { ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- Warning: mysqli_stmt_execute(): invalid object or resource mysqli_stmt diff --git a/ext/mysqli/tests/mysqli_stmt_execute_stored_proc.phpt b/ext/mysqli/tests/mysqli_stmt_execute_stored_proc.phpt index 6537b8d88b..5e421b078d 100644 --- a/ext/mysqli/tests/mysqli_stmt_execute_stored_proc.phpt +++ b/ext/mysqli/tests/mysqli_stmt_execute_stored_proc.phpt @@ -6,10 +6,10 @@ 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 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-- @@ -188,7 +188,7 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 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'); diff --git a/ext/mysqli/tests/mysqli_stmt_execute_stored_proc_next_result.phpt b/ext/mysqli/tests/mysqli_stmt_execute_stored_proc_next_result.phpt index aed04962f2..78483649c6 100644 --- a/ext/mysqli/tests/mysqli_stmt_execute_stored_proc_next_result.phpt +++ b/ext/mysqli/tests/mysqli_stmt_execute_stored_proc_next_result.phpt @@ -6,10 +6,10 @@ 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 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-- diff --git a/ext/mysqli/tests/mysqli_stmt_execute_stored_proc_out.phpt b/ext/mysqli/tests/mysqli_stmt_execute_stored_proc_out.phpt index 6ab270b8f4..52c551ffce 100644 --- a/ext/mysqli/tests/mysqli_stmt_execute_stored_proc_out.phpt +++ b/ext/mysqli/tests/mysqli_stmt_execute_stored_proc_out.phpt @@ -6,14 +6,14 @@ 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 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 ?!")); } */ ?> diff --git a/ext/mysqli/tests/mysqli_stmt_fetch.phpt b/ext/mysqli/tests/mysqli_stmt_fetch.phpt index 4b41c9213d..d1d5b56965 100644 --- a/ext/mysqli/tests/mysqli_stmt_fetch.phpt +++ b/ext/mysqli/tests/mysqli_stmt_fetch.phpt @@ -87,7 +87,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- Warning: mysqli_stmt_fetch(): invalid object or resource mysqli_stmt diff --git a/ext/mysqli/tests/mysqli_stmt_fetch_bit.phpt b/ext/mysqli/tests/mysqli_stmt_fetch_bit.phpt index 495fcdce7d..787f7eadd0 100644 --- a/ext/mysqli/tests/mysqli_stmt_fetch_bit.phpt +++ b/ext/mysqli/tests/mysqli_stmt_fetch_bit.phpt @@ -2,17 +2,17 @@ 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 @@ -70,7 +70,7 @@ Fetching BIT column values using the PS API ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_stmt_fetch_fields_win32_unicode.phpt b/ext/mysqli/tests/mysqli_stmt_fetch_fields_win32_unicode.phpt index 14333e7665..47d0ac9355 100644 --- a/ext/mysqli/tests/mysqli_stmt_fetch_fields_win32_unicode.phpt +++ b/ext/mysqli/tests/mysqli_stmt_fetch_fields_win32_unicode.phpt @@ -48,7 +48,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- OK: 1 diff --git a/ext/mysqli/tests/mysqli_stmt_fetch_geom.phpt b/ext/mysqli/tests/mysqli_stmt_fetch_geom.phpt index f76d407ad0..be74f47ce4 100644 --- a/ext/mysqli/tests/mysqli_stmt_fetch_geom.phpt +++ b/ext/mysqli/tests/mysqli_stmt_fetch_geom.phpt @@ -2,12 +2,12 @@ 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 @@ -136,7 +136,7 @@ mysqli_stmt_fetch - geometry / spatial types ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_stmt_field_count.phpt b/ext/mysqli/tests/mysqli_stmt_field_count.phpt index 847fe04a3b..9dfded6a31 100644 --- a/ext/mysqli/tests/mysqli_stmt_field_count.phpt +++ b/ext/mysqli/tests/mysqli_stmt_field_count.phpt @@ -85,7 +85,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- Warning: mysqli_stmt_field_count(): invalid object or resource mysqli_stmt diff --git a/ext/mysqli/tests/mysqli_stmt_free_result.phpt b/ext/mysqli/tests/mysqli_stmt_free_result.phpt index 292905ab63..09016bf8a5 100644 --- a/ext/mysqli/tests/mysqli_stmt_free_result.phpt +++ b/ext/mysqli/tests/mysqli_stmt_free_result.phpt @@ -76,7 +76,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- Warning: mysqli_stmt_free_result(): invalid object or resource mysqli_stmt diff --git a/ext/mysqli/tests/mysqli_stmt_get_result.phpt b/ext/mysqli/tests/mysqli_stmt_get_result.phpt index 3613865e20..e4cf8f8cf6 100644 --- a/ext/mysqli/tests/mysqli_stmt_get_result.phpt +++ b/ext/mysqli/tests/mysqli_stmt_get_result.phpt @@ -7,7 +7,7 @@ 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 @@ -202,7 +202,7 @@ if (!function_exists('mysqli_stmt_get_result')) ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- Warning: mysqli_stmt_fetch(): invalid object or resource mysqli_stmt diff --git a/ext/mysqli/tests/mysqli_stmt_get_result2.phpt b/ext/mysqli/tests/mysqli_stmt_get_result2.phpt index 00ed7adee4..2d9339e032 100644 --- a/ext/mysqli/tests/mysqli_stmt_get_result2.phpt +++ b/ext/mysqli/tests/mysqli_stmt_get_result2.phpt @@ -6,7 +6,7 @@ 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'); + die('skip mysqli_stmt_get_result not available'); ?> --FILE-- <?php @@ -153,7 +153,7 @@ if (!function_exists('mysqli_stmt_get_result')) ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- array(2) { diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_bit.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_bit.phpt index c7109063e7..b05d2abe5e 100644 --- a/ext/mysqli/tests/mysqli_stmt_get_result_bit.phpt +++ b/ext/mysqli/tests/mysqli_stmt_get_result_bit.phpt @@ -2,21 +2,21 @@ 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 @@ -127,7 +127,7 @@ Fetching BIT column values using the PS API ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_field_count.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_field_count.phpt index 8508150f98..d44aaa6f89 100644 --- a/ext/mysqli/tests/mysqli_stmt_get_result_field_count.phpt +++ b/ext/mysqli/tests/mysqli_stmt_get_result_field_count.phpt @@ -2,12 +2,12 @@ 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 @@ -43,7 +43,7 @@ mysqli_stmt_get_result() - meta data, field_count() ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- 2 2 diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_geom.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_geom.phpt index aeadc3b1d7..3e656aacba 100644 --- a/ext/mysqli/tests/mysqli_stmt_get_result_geom.phpt +++ b/ext/mysqli/tests/mysqli_stmt_get_result_geom.phpt @@ -2,15 +2,15 @@ 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 @@ -138,7 +138,7 @@ mysqli_stmt_get_result - geometry / spatial types ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_metadata.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_metadata.phpt index febc659167..d3afbba561 100644 --- a/ext/mysqli/tests/mysqli_stmt_get_result_metadata.phpt +++ b/ext/mysqli/tests/mysqli_stmt_get_result_metadata.phpt @@ -7,7 +7,7 @@ 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 @@ -207,7 +207,7 @@ if (!function_exists('mysqli_stmt_get_result')) ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- array(2) { diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_metadata_fetch_field.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_metadata_fetch_field.phpt index 5481db04f4..1486b1a9fc 100644 --- a/ext/mysqli/tests/mysqli_stmt_get_result_metadata_fetch_field.phpt +++ b/ext/mysqli/tests/mysqli_stmt_get_result_metadata_fetch_field.phpt @@ -7,7 +7,7 @@ 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 @@ -63,7 +63,7 @@ if (!function_exists('mysqli_stmt_get_result')) ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- object(stdClass)#%d (13) { diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_non_select.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_non_select.phpt index 1cd2981ed2..b6f02d0f6c 100644 --- a/ext/mysqli/tests/mysqli_stmt_get_result_non_select.phpt +++ b/ext/mysqli/tests/mysqli_stmt_get_result_non_select.phpt @@ -7,7 +7,7 @@ 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 @@ -89,7 +89,7 @@ if (!function_exists('mysqli_stmt_get_result')) ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_seek.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_seek.phpt index 51198523c9..bc365c6ad5 100644 --- a/ext/mysqli/tests/mysqli_stmt_get_result_seek.phpt +++ b/ext/mysqli/tests/mysqli_stmt_get_result_seek.phpt @@ -7,7 +7,7 @@ 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 @@ -115,7 +115,7 @@ if (!function_exists('mysqli_stmt_get_result')) ?> --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 diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_types.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_types.phpt index 7d21558593..bde61c3706 100644 --- a/ext/mysqli/tests/mysqli_stmt_get_result_types.phpt +++ b/ext/mysqli/tests/mysqli_stmt_get_result_types.phpt @@ -2,12 +2,12 @@ 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 @@ -251,7 +251,7 @@ mysqli_stmt_get_result - data types ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_stmt_get_warnings.phpt b/ext/mysqli/tests/mysqli_stmt_get_warnings.phpt index 1ebe6d051f..a4a046dc7d 100644 --- a/ext/mysqli/tests/mysqli_stmt_get_warnings.phpt +++ b/ext/mysqli/tests/mysqli_stmt_get_warnings.phpt @@ -9,16 +9,16 @@ 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 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"); ?> @@ -100,7 +100,7 @@ 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 diff --git a/ext/mysqli/tests/mysqli_stmt_init.phpt b/ext/mysqli/tests/mysqli_stmt_init.phpt index b82a855dd2..6ec1a4c038 100644 --- a/ext/mysqli/tests/mysqli_stmt_init.phpt +++ b/ext/mysqli/tests/mysqli_stmt_init.phpt @@ -46,7 +46,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- Warning: mysqli_stmt_close(): invalid object or resource mysqli_stmt diff --git a/ext/mysqli/tests/mysqli_stmt_insert_id.phpt b/ext/mysqli/tests/mysqli_stmt_insert_id.phpt index e3ef9a25ec..f70cc1a171 100644 --- a/ext/mysqli/tests/mysqli_stmt_insert_id.phpt +++ b/ext/mysqli/tests/mysqli_stmt_insert_id.phpt @@ -69,7 +69,7 @@ require_once('skipifconnectfailure.inc'); ?> --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 diff --git a/ext/mysqli/tests/mysqli_stmt_multires.phpt b/ext/mysqli/tests/mysqli_stmt_multires.phpt index 23a8ad27a8..084361ef11 100644 --- a/ext/mysqli/tests/mysqli_stmt_multires.phpt +++ b/ext/mysqli/tests/mysqli_stmt_multires.phpt @@ -94,10 +94,10 @@ require_once('skipifconnectfailure.inc'); ?> --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:" diff --git a/ext/mysqli/tests/mysqli_stmt_num_rows.phpt b/ext/mysqli/tests/mysqli_stmt_num_rows.phpt index 5355b3deb7..682ab7bc92 100644 --- a/ext/mysqli/tests/mysqli_stmt_num_rows.phpt +++ b/ext/mysqli/tests/mysqli_stmt_num_rows.phpt @@ -109,7 +109,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- run_tests.php don't fool me with your 'ungreedy' expression '.+?'! diff --git a/ext/mysqli/tests/mysqli_stmt_param_count.phpt b/ext/mysqli/tests/mysqli_stmt_param_count.phpt index e847d165f6..f3c0064541 100644 --- a/ext/mysqli/tests/mysqli_stmt_param_count.phpt +++ b/ext/mysqli/tests/mysqli_stmt_param_count.phpt @@ -62,7 +62,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- Warning: mysqli_stmt_param_count(): invalid object or resource mysqli_stmt diff --git a/ext/mysqli/tests/mysqli_stmt_prepare.phpt b/ext/mysqli/tests/mysqli_stmt_prepare.phpt index d0e38075d9..ff4fdd8c81 100644 --- a/ext/mysqli/tests/mysqli_stmt_prepare.phpt +++ b/ext/mysqli/tests/mysqli_stmt_prepare.phpt @@ -49,7 +49,7 @@ require_once('skipifconnectfailure.inc'); ?> --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 diff --git a/ext/mysqli/tests/mysqli_stmt_reset.phpt b/ext/mysqli/tests/mysqli_stmt_reset.phpt index b7ec4e3ed7..0a94491f47 100644 --- a/ext/mysqli/tests/mysqli_stmt_reset.phpt +++ b/ext/mysqli/tests/mysqli_stmt_reset.phpt @@ -101,7 +101,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- Warning: mysqli_stmt_reset(): invalid object or resource mysqli_stmt diff --git a/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt b/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt index 8f4e13ef39..4b0551082a 100644 --- a/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt +++ b/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt @@ -95,7 +95,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- Warning: mysqli_stmt_result_metadata(): invalid object or resource mysqli_stmt diff --git a/ext/mysqli/tests/mysqli_stmt_result_metadata_sqltests.phpt b/ext/mysqli/tests/mysqli_stmt_result_metadata_sqltests.phpt index 7f858e0216..fb285436d3 100644 --- a/ext/mysqli/tests/mysqli_stmt_result_metadata_sqltests.phpt +++ b/ext/mysqli/tests/mysqli_stmt_result_metadata_sqltests.phpt @@ -226,7 +226,7 @@ die("skip Check again when the Klingons visit earth - http://bugs.mysql.com/bug. ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_stmt_send_long_data.phpt b/ext/mysqli/tests/mysqli_stmt_send_long_data.phpt index 1fc2745511..8e6dfcaffa 100644 --- a/ext/mysqli/tests/mysqli_stmt_send_long_data.phpt +++ b/ext/mysqli/tests/mysqli_stmt_send_long_data.phpt @@ -128,7 +128,7 @@ require_once('skipifconnectfailure.inc'); ?> --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 diff --git a/ext/mysqli/tests/mysqli_stmt_send_long_data_packet_size_libmysql.phpt b/ext/mysqli/tests/mysqli_stmt_send_long_data_packet_size_libmysql.phpt index 38048894af..10a6471d2b 100644 --- a/ext/mysqli/tests/mysqli_stmt_send_long_data_packet_size_libmysql.phpt +++ b/ext/mysqli/tests/mysqli_stmt_send_long_data_packet_size_libmysql.phpt @@ -7,7 +7,7 @@ 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"); ?> --FILE-- <?php @@ -92,7 +92,7 @@ if (stristr(mysqli_get_client_info(), 'mysqlnd')) ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_stmt_send_long_data_packet_size_mysqlnd.phpt b/ext/mysqli/tests/mysqli_stmt_send_long_data_packet_size_mysqlnd.phpt index fa26a3a45e..e64d66fa12 100644 --- a/ext/mysqli/tests/mysqli_stmt_send_long_data_packet_size_mysqlnd.phpt +++ b/ext/mysqli/tests/mysqli_stmt_send_long_data_packet_size_mysqlnd.phpt @@ -7,7 +7,7 @@ require_once('skipifemb.inc'); 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 @@ -97,7 +97,7 @@ Warning: mysqli_stmt_send_long_data(): There was an error while sending long dat ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_stmt_sqlstate.phpt b/ext/mysqli/tests/mysqli_stmt_sqlstate.phpt index 1784106162..c684e3585a 100644 --- a/ext/mysqli/tests/mysqli_stmt_sqlstate.phpt +++ b/ext/mysqli/tests/mysqli_stmt_sqlstate.phpt @@ -53,7 +53,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECTF-- Warning: mysqli_stmt_sqlstate(): invalid object or resource mysqli_stmt diff --git a/ext/mysqli/tests/mysqli_stmt_store_result.phpt b/ext/mysqli/tests/mysqli_stmt_store_result.phpt index 89b8ed3bf8..b563e886bf 100644 --- a/ext/mysqli/tests/mysqli_stmt_store_result.phpt +++ b/ext/mysqli/tests/mysqli_stmt_store_result.phpt @@ -84,7 +84,7 @@ require_once('skipifconnectfailure.inc'); ?> --CLEAN-- <?php - require_once("clean_table.inc"); + require_once("clean_table.inc"); ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_store_result.phpt b/ext/mysqli/tests/mysqli_store_result.phpt index b87d147e38..2ac22ba767 100644 --- a/ext/mysqli/tests/mysqli_store_result.phpt +++ b/ext/mysqli/tests/mysqli_store_result.phpt @@ -57,7 +57,7 @@ require_once('skipifconnectfailure.inc'); ?> --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 diff --git a/ext/mysqli/tests/mysqli_store_result_buffered_c.phpt b/ext/mysqli/tests/mysqli_store_result_buffered_c.phpt index 548b9719d2..31645b026c 100644 --- a/ext/mysqli/tests/mysqli_store_result_buffered_c.phpt +++ b/ext/mysqli/tests/mysqli_store_result_buffered_c.phpt @@ -10,28 +10,28 @@ require_once('skipifconnectfailure.inc'); 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 diff --git a/ext/mysqli/tests/mysqli_store_result_copy.phpt b/ext/mysqli/tests/mysqli_store_result_copy.phpt index dbbb9c7bc8..136e2c5d4d 100644 --- a/ext/mysqli/tests/mysqli_store_result_copy.phpt +++ b/ext/mysqli/tests/mysqli_store_result_copy.phpt @@ -16,183 +16,183 @@ mysqlnd.mempool_default_size=1 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 diff --git a/ext/mysqli/tests/mysqli_thread_id.phpt b/ext/mysqli/tests/mysqli_thread_id.phpt index 4a71d60f41..f8e6d7fa1b 100644 --- a/ext/mysqli/tests/mysqli_thread_id.phpt +++ b/ext/mysqli/tests/mysqli_thread_id.phpt @@ -37,7 +37,7 @@ require_once('skipifconnectfailure.inc'); ?> --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 diff --git a/ext/mysqli/tests/mysqli_use_result.phpt b/ext/mysqli/tests/mysqli_use_result.phpt index 190cafa5d5..f61d51208e 100644 --- a/ext/mysqli/tests/mysqli_use_result.phpt +++ b/ext/mysqli/tests/mysqli_use_result.phpt @@ -57,7 +57,7 @@ require_once('skipifconnectfailure.inc'); ?> --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 diff --git a/ext/mysqli/tests/mysqli_warning_count.phpt b/ext/mysqli/tests/mysqli_warning_count.phpt index 9d59f26e52..128373ae36 100644 --- a/ext/mysqli/tests/mysqli_warning_count.phpt +++ b/ext/mysqli/tests/mysqli_warning_count.phpt @@ -45,7 +45,7 @@ require_once('skipifconnectfailure.inc'); ?> --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 diff --git a/ext/mysqli/tests/mysqli_warning_unclonable.phpt b/ext/mysqli/tests/mysqli_warning_unclonable.phpt index 1079ac374b..3e63339140 100644 --- a/ext/mysqli/tests/mysqli_warning_unclonable.phpt +++ b/ext/mysqli/tests/mysqli_warning_unclonable.phpt @@ -7,7 +7,7 @@ require_once('skipifemb.inc'); require_once('skipifconnectfailure.inc'); require_once('connect.inc'); if (!$TEST_EXPERIMENTAL) - die("skip - experimental (= unsupported) feature"); + die("skip - experimental (= unsupported) feature"); ?> --FILE-- <?php @@ -35,7 +35,7 @@ if (!$TEST_EXPERIMENTAL) ?> --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 diff --git a/ext/mysqli/tests/reflection_tools.inc b/ext/mysqli/tests/reflection_tools.inc index 6648526ed0..0e46c2afa9 100644 --- a/ext/mysqli/tests/reflection_tools.inc +++ b/ext/mysqli/tests/reflection_tools.inc @@ -1,121 +1,121 @@ <?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'); - } + } ?> diff --git a/ext/mysqli/tests/skipif.inc b/ext/mysqli/tests/skipif.inc index 5562aab84b..a5a5df14c2 100644 --- a/ext/mysqli/tests/skipif.inc +++ b/ext/mysqli/tests/skipif.inc @@ -1,5 +1,5 @@ <?php if (!extension_loaded('mysqli')){ - die('skip mysqli extension not available'); + die('skip mysqli extension not available'); } ?> diff --git a/ext/mysqli/tests/skipifconnectfailure.inc b/ext/mysqli/tests/skipifconnectfailure.inc index 32a976357c..ccde567baa 100644 --- a/ext/mysqli/tests/skipifconnectfailure.inc +++ b/ext/mysqli/tests/skipifconnectfailure.inc @@ -1,10 +1,10 @@ <?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); } ?> diff --git a/ext/mysqli/tests/skipifemb.inc b/ext/mysqli/tests/skipifemb.inc index ad143a42a4..2b7941d825 100644 --- a/ext/mysqli/tests/skipifemb.inc +++ b/ext/mysqli/tests/skipifemb.inc @@ -1,5 +1,5 @@ <?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"); ?> diff --git a/ext/mysqli/tests/skipifnotemb.inc b/ext/mysqli/tests/skipifnotemb.inc index fa5fb9f0a3..e88e423836 100644 --- a/ext/mysqli/tests/skipifnotemb.inc +++ b/ext/mysqli/tests/skipifnotemb.inc @@ -1,5 +1,5 @@ <?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"); ?> diff --git a/ext/mysqli/tests/table.inc b/ext/mysqli/tests/table.inc index e0d7a06c57..16b688f74b 100644 --- a/ext/mysqli/tests/table.inc +++ b/ext/mysqli/tests/table.inc @@ -2,27 +2,27 @@ 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)); } ?> |