cvs: php-src(PHP_5_3) /ext/mysqli/tests mysqli_get_cache_stats.phpt mysqli_get_cache_stats_free_buffered.phpt mysqli_get_charset.phpt
mysqli_get_client_info.phpt mysqli_get_client_stats.phpt mysqli_get_client_stats_implicit_free.phpt mysqli_get_client_stats_off.phpt
mysqli_get_client_stats_ps.phpt mysqli_get_client_stats_skipped.phpt mysqli_get_client_version.phpt mysqli_get_connection_stats.phpt
mysqli_get_host_info.phpt mysqli_get_proto_info.phpt mysqli_get_server_info.phpt mysqli_get_server_version.phpt mysqli_get_warnings.phpt
mysqli_info.phpt mysqli_init.phpt mysqli_insert_id.phpt mysqli_kill.phpt
| From: | Ulf Wendel | Date: | Wed, 10 Oct 2007 10:16:00 +0000 |
| Subject: | cvs: php-src(PHP_5_3) /ext/mysqli/tests mysqli_get_cache_stats.phpt mysqli_get_cache_stats_free_buffered.phpt mysqli_get_charset.phpt mysqli_get_client_info.phpt mysqli_get_client_stats.phpt mysqli_get_client_stats_implicit_free.phpt mysqli_get_client_stats_off.phpt mysqli_get_client_stats_ps.phpt mysqli_get_client_stats_skipped.phpt mysqli_get_client_version.phpt mysqli_get_connection_stats.phpt mysqli_get_host_info.phpt mysqli_get_proto_info.phpt mysqli_get_server_info.phpt mysqli_get_server_version.phpt mysqli_get_warnings.phpt mysqli_info.phpt mysqli_init.phpt mysqli_insert_id.phpt mysqli_kill.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-46603@lists.php.net to get a copy of this message | ||
uw Wed Oct 10 10:16:00 2007 UTC
Added files: (Branch: PHP_5_3)
/php-src/ext/mysqli/tests mysqli_get_cache_stats_free_buffered.phpt
mysqli_get_cache_stats.phpt
mysqli_get_charset.phpt
mysqli_get_client_info.phpt
mysqli_get_client_stats_implicit_free.phpt
mysqli_get_client_stats_off.phpt
mysqli_get_client_stats.phpt
mysqli_get_client_stats_ps.phpt
mysqli_get_client_stats_skipped.phpt
mysqli_get_client_version.phpt
mysqli_get_connection_stats.phpt
mysqli_get_host_info.phpt
mysqli_get_proto_info.phpt
mysqli_get_server_info.phpt
mysqli_get_server_version.phpt
mysqli_get_warnings.phpt mysqli_info.phpt
mysqli_init.phpt mysqli_insert_id.phpt
mysqli_kill.phpt
Log:
Adding new tests: mysqli_g*.phpt mysqli_i*.phpt mysqli_k*.phpt
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_cache_stats_free_buffered.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_cache_stats_free_buffered.phpt +++ php-src/ext/mysqli/tests/mysqli_get_cache_stats_free_buffered.phpt --TEST-- mysqli_get_cache_stats() - freeing for buffered result sets --SKIPIF-- <?PHP require_once('skipif.inc'); require_once('skipifemb.inc'); if (!function_exists('mysqli_get_cache_stats')) { die("skip only available with mysqlnd"); } if (ini_get("unicode.semantics")) { die("skip: zval cache works now only in non-unicode mode"); } ?> --FILE-- <?php include "connect.inc"; require_once('table.inc'); if (!is_array($info = mysqli_get_cache_stats()) || empty($info)) printf("[001] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id")) printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $rows = array(); while ($rows[] = mysqli_fetch_assoc($res)) ; mysqli_free_result($res); if (!is_array($new_info = mysqli_get_cache_stats()) || empty($new_info)) printf("[003] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info); if ($new_info['free_items'] >= $info['free_items']) { printf("[004] mysqli_free_result() should not yet have free slots again, because \$rows still exists\n"); var_dump($info); var_dump($new_info); } /* nothing should change because GC will happen some time after free_result */ unset($rows); if (!is_array($new_info = mysqli_get_cache_stats()) || empty($new_info)) printf("[005] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info); if (defined("WE_HAVE_GARBAGE_COLLECTOR_TO_FREE_AFTER_ON_UNSET_AFTER_FREE_RESULT")) { /* For now we can't reclaim the slots after the free_result is called. unset() should happen before free_result(). */ if ($new_info['free_items'] < $info['free_items']) { printf("[006] \$rows has been unset, free item count should be back to the original value\n"); var_dump($info); var_dump($new_info); } } else { /* We have to reset $info */ $info = mysqli_get_cache_stats(); } if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id")) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $rows = array(); while ($rows[] = mysqli_fetch_assoc($res)) ; unset($rows); mysqli_free_result($res); if (!is_array($new_info = mysqli_get_cache_stats()) || empty($new_info)) printf("[008] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info); if ($new_info['free_items'] < $info['free_items']) { printf("[009] \$rows has been unset, mysqli_free_result() has been called, free item count should be back to the original value\n"); var_dump($info); var_dump($new_info); } mysqli_close($link); if (!is_array($new_info = mysqli_get_cache_stats()) || empty($new_info)) printf("[010] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info); if ($new_info['free_items'] < $info['free_items']) { printf("[011] connection has been closed, free item count should be back to the original value\n"); var_dump($info); var_dump($new_info); } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_cache_stats.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_cache_stats.phpt +++ php-src/ext/mysqli/tests/mysqli_get_cache_stats.phpt --TEST-- mysqli_get_cache_stats() --SKIPIF-- <?PHP require_once('skipif.inc'); require_once('skipifemb.inc'); if (!function_exists('mysqli_get_cache_stats')) { die("skip only available with mysqlnd"); } if (ini_get("unicode.semantics")) { die("skip: zval cache works now only in non-unicode mode"); } ?> --FILE-- <?php $tmp = $link = null; if (!is_null($tmp = @mysqli_get_cache_stats($link))) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); include "connect.inc"; if (!is_array($info = mysqli_get_cache_stats()) || empty($info)) printf("[002] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); var_dump($info); if ($info['size'] !== $info['free_items']) printf("[003] Unused cache should have size (%d) == free_items (%d)\n", $info['size'], $info['free_items']); require_once('table.inc'); if (!is_array($new_info = mysqli_get_cache_stats()) || empty($new_info)) printf("[004] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info); if ($info['size'] !== $new_info['size']) printf("[005] Cache size should not have changes! Expecting int/%d, got %s/%d\n", $info['size'], gettype($new_info['size']), $new_info['size']); if (count($info) != count($new_info)) { printf("[006] Both arrays should have the same number of entries\n"); var_dump($info); var_dump($new_info); } if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id")) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($res = mysqli_use_result($link))) printf("[008] Expecting object, got %s/%s. [%d] %s\n", gettype($res), $res, mysqli_errno($link), mysqli_error($link)); if (!$row = mysqli_fetch_assoc($res)) printf("[009] There should be at least one row in the test table for this test, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_array($new_info = mysqli_get_cache_stats()) || empty($new_info)) printf("[010] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info); if ($new_info['get_hits'] <= $info['get_hits']) printf("[011] get_hits should have increased, %d (new) <= %d (old)!\n", $new_info['get_hits'], $info['get_hits']); if (!$row = mysqli_fetch_assoc($res)) printf("[012] There should be two rows in the test table for this test, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_array($new_info = mysqli_get_cache_stats()) || empty($new_info)) printf("[013] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info); if ($new_info['put_misses'] <= $info['put_misses']) printf("[014] put_misses should have increased, %d (new) <= %d (old)!\n", $new_info['put_misses'], $info['put_misses']); if ($new_info['references'] < $info['references'] + 2) printf("[015] reference counter should have increased, %d (new) < %d + 2 (old)!\n", $new_info['references'], $info['references']); unset($row); mysqli_free_result($res); if (!is_array($info = mysqli_get_cache_stats()) || empty($info)) printf("[016] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); if ($info['free_items'] <= $new_info['free_items']) printf("[017] Looks like cached entries never get free'd.\n"); mysqli_close($link); print "done!"; ?> --EXPECTF-- array(7) { ["put_hits"]=> int(0) ["put_misses"]=> int(0) ["get_hits"]=> int(0) ["get_misses"]=> int(0) ["size"]=> int(%d) ["free_items"]=> int(%d) ["references"]=> int(%d) } done! --UEXPECTF-- array(7) { [u"put_hits"]=> int(0) [u"put_misses"]=> int(0) [u"get_hits"]=> int(0) [u"get_misses"]=> int(0) [u"size"]=> int(%d) [u"free_items"]=> int(%d) [u"references"]=> int(%d) } done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_charset.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_charset.phpt +++ php-src/ext/mysqli/tests/mysqli_get_charset.phpt --TEST-- mysqli_get_charset() --SKIPIF-- <?php require_once('skipifemb.inc'); require_once('skipif.inc'); if (!function_exists('mysqli_get_charset')) die("skip: function not available"); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_get_charset())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_charset($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_set_charset($link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysqli_query($link, 'SELECT version() AS server_version')) printf("[004] [%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)) printf("[005] Cannot determine server version, need MySQL Server 4.1+ for the test!\n"); if ($version[0] <= 4 && $version[1] < 1) printf("[006] Need MySQL Server 4.1+ for the test!\n"); if (!$res = mysqli_query($link, 'SELECT @@character_set_connection AS charset, @@collation_connection AS collation')) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (!($character_set_connection = $tmp['charset']) || !($collation_connection = $tmp['collation'])) printf("[008] Cannot determine current character set and collation\n"); if (!$res = mysqli_query($link, $sql = sprintf('SHOW CHARACTER SET LIKE "%s"', $character_set_connection))) printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); if (empty($tmp)) printf("[010] Cannot fetch Maxlen and/or Comment, test will fail: $sql\n"); $maxlen = (isset($tmp['Maxlen'])) ? $tmp['Maxlen'] : ''; $comment = (isset($tmp['Description'])) ? $tmp['Description'] : ''; if (!$res = mysqli_query($link, sprintf('SHOW COLLATION LIKE "%s"', $collation_connection))) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (!($id = $tmp['Id'])) printf("[012] Cannot fetch Id/Number, test will fail\n"); if (!$res = mysqli_query($link, sprintf('SHOW VARIABLES LIKE "character_sets_dir"'))) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (!($character_sets_dir = $tmp['Value'])) printf("[014] Cannot fetch character_sets_dir, test will fail\n"); if (!is_object($charset = mysqli_get_charset($link))) printf("[015] Expecting object/std_class, got %s/%s\n", gettype($charset), $charset); if (!isset($charset->charset) || !in_array(gettype($charset->charset), array("string", "unicode")) || ($character_set_connection !== $charset->charset)) printf("[016] Expecting string/%s, got %s/%s\n", $character_set_connection, gettype($charset->charset), $charset->charset); if (!isset($charset->collation) || !in_array(gettype($charset->collation), array("string", "unicode")) || ($collation_connection !== $charset->collation)) printf("[017] Expecting string/%s, got %s/%s\n", $collation_connection, gettype($charset->collation), $charset->collation); if (!isset($charset->dir) || !is_string($charset->dir)) printf("[019] Expecting string - ideally %s*, got %s/%s\n", $character_sets_dir, gettype($charset->dir), $charset->dir); if (!isset($charset->min_length) || !(is_int($charset->min_length)) || ($charset->min_length < 0) || ($charset->min_length > $charset->max_length)) printf("[020] Expecting int between 0 ... %d, got %s/%s\n", $charset->max_length, gettype($charset->min_length), $charset->min_length); if (!isset($charset->number) || !is_int($charset->number) || ($charset->number !== (int)$id)) printf("[021] Expecting int/%d, got %s/%s\n", $id, gettype($charset->number), $charset->number); if (!isset($charset->state) || !is_int($charset->state)) printf("[022] Expecting int/any, got %s/%s\n", gettype($charset->state), $charset->state); mysqli_close($link); if (NULL !== ($tmp = mysqli_get_charset($link))) printf("[023] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_get_charset(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_client_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_client_info.phpt +++ php-src/ext/mysqli/tests/mysqli_get_client_info.phpt --TEST-- mysqli_get_client_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_string($info = mysqli_get_client_info()) || ('' === $info)) printf("[001] Expecting string/any_non_empty, got %s/%s\n", gettype($info), $info); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_client_stats_implicit_free.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_client_stats_implicit_free.phpt +++ php-src/ext/mysqli/tests/mysqli_get_client_stats_implicit_free.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_client_stats_off.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_client_stats_off.phpt +++ php-src/ext/mysqli/tests/mysqli_get_client_stats_off.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_client_stats.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_client_stats.phpt +++ php-src/ext/mysqli/tests/mysqli_get_client_stats.phpt --TEST-- mysqli_get_client_stats() --SKIPIF-- <?PHP require_once('skipif.inc'); require_once('skipifemb.inc'); if (!function_exists('mysqli_get_client_stats')) { die("skip only available with mysqlnd"); } ?> --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); include "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 = 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 */ if (!ini_get("unicode.semantics")) 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_fetched_from_server', $new_info, $info, $test_counter); mysqli_get_client_stats_assert_eq('rows_fetched_from_client', $new_info, $info, $test_counter); mysqli_get_client_stats_assert_eq('rows_skipped', $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); 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); // // result_set_queries statistics // 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; // // 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, RENAME, 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_get_server_version($link) > 51700) { if (!mysqli_query($link, "RENAME DATABASE mysqli_get_client_stats TO mysqli_get_client_stats_")) printf("[%03d] RENAME 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; } else { 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; } /* 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); } /* 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; /* 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!"; ?> --EXPECTF-- array(33) { ["bytes_sent"]=> string(1) "0" ["bytes_received"]=> string(1) "0" ["packets_sent"]=> string(1) "0" ["packets_received"]=> string(1) "0" ["protocol_overhead_in"]=> string(1) "0" ["protocol_overhead_out"]=> string(1) "0" ["result_set_queries"]=> string(1) "0" ["non_result_set_queries"]=> string(1) "0" ["no_index_used"]=> string(1) "0" ["bad_index_used"]=> string(1) "0" ["buffered_sets"]=> string(1) "0" ["unbuffered_sets"]=> string(1) "0" ["ps_buffered_sets"]=> string(1) "0" ["ps_unbuffered_sets"]=> string(1) "0" ["flushed_normal_sets"]=> string(1) "0" ["flushed_ps_sets"]=> string(1) "0" ["rows_fetched_from_server"]=> string(1) "0" ["rows_fetched_from_client"]=> string(1) "0" ["rows_skipped"]=> string(1) "0" ["copy_on_write_saved"]=> string(1) "0" ["copy_on_write_performed"]=> string(1) "0" ["command_buffer_too_small"]=> string(1) "0" ["connect_success"]=> string(1) "0" ["connect_failure"]=> string(1) "0" ["connection_reused"]=> string(1) "0" ["explicit_close"]=> string(1) "0" ["implicit_close"]=> string(1) "0" ["disconnect_close"]=> string(1) "0" ["in_middle_of_command_close"]=> string(1) "0" ["explicit_free_result"]=> string(1) "0" ["implicit_free_result"]=> string(1) "0" ["explicit_stmt_close"]=> string(1) "0" ["implicit_stmt_close"]=> string(1) "0" } done! --UEXPECTF-- array(33) { [u"bytes_sent"]=> unicode(1) "0" [u"bytes_received"]=> unicode(1) "0" [u"packets_sent"]=> unicode(1) "0" [u"packets_received"]=> unicode(1) "0" [u"protocol_overhead_in"]=> unicode(1) "0" [u"protocol_overhead_out"]=> unicode(1) "0" [u"result_set_queries"]=> unicode(1) "0" [u"non_result_set_queries"]=> unicode(1) "0" [u"no_index_used"]=> unicode(1) "0" [u"bad_index_used"]=> unicode(1) "0" [u"buffered_sets"]=> unicode(1) "0" [u"unbuffered_sets"]=> unicode(1) "0" [u"ps_buffered_sets"]=> unicode(1) "0" [u"ps_unbuffered_sets"]=> unicode(1) "0" [u"flushed_normal_sets"]=> unicode(1) "0" [u"flushed_ps_sets"]=> unicode(1) "0" [u"rows_fetched_from_server"]=> unicode(1) "0" [u"rows_fetched_from_client"]=> unicode(1) "0" [u"rows_skipped"]=> unicode(1) "0" [u"copy_on_write_saved"]=> unicode(1) "0" [u"copy_on_write_performed"]=> unicode(1) "0" [u"command_buffer_too_small"]=> unicode(1) "0" [u"connect_success"]=> unicode(1) "0" [u"connect_failure"]=> unicode(1) "0" [u"connection_reused"]=> unicode(1) "0" [u"explicit_close"]=> unicode(1) "0" [u"implicit_close"]=> unicode(1) "0" [u"disconnect_close"]=> unicode(1) "0" [u"in_middle_of_command_close"]=> unicode(1) "0" [u"explicit_free_result"]=> unicode(1) "0" [u"implicit_free_result"]=> unicode(1) "0" [u"explicit_stmt_close"]=> unicode(1) "0" [u"implicit_stmt_close"]=> unicode(1) "0" } done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_client_stats_ps.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_client_stats_ps.phpt +++ php-src/ext/mysqli/tests/mysqli_get_client_stats_ps.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_client_stats_skipped.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_client_stats_skipped.phpt +++ php-src/ext/mysqli/tests/mysqli_get_client_stats_skipped.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_client_version.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_client_version.phpt +++ php-src/ext/mysqli/tests/mysqli_get_client_version.phpt --TEST-- mysqli_get_client_version() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_int($info = mysqli_get_client_version()) || ($info < 100)) printf("[001] Expecting int/any_non_empty, got %s/%s\n", gettype($info), $info); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_connection_stats.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_connection_stats.phpt +++ php-src/ext/mysqli/tests/mysqli_get_connection_stats.phpt --TEST-- mysqli_get_connection_stats() --SKIPIF-- <?PHP require_once('skipif.inc'); require_once('skipifemb.inc'); if (!function_exists('mysqli_get_connection_stats')) { die("skip only available with mysqlnd"); } ?> --FILE-- <?php $tmp = $link = null; if (!is_null($tmp = @mysqli_get_connection_stats())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_connection_stats($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); include "connect.inc"; include "table.inc"; if (!is_array($info = mysqli_get_connection_stats($link)) || empty($info)) printf("[003] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); if (!is_array($info2 = mysqli_get_client_stats()) || empty($info2)) printf("[004] Expecting array/any_non_empty, got %s/%s\n", gettype($info2), $info2); if ($info !== $info2) { printf("[005] The hashes should be identical\n"); var_dump($info); var_dump($info2); } mysqli_close($link); include "table.inc"; if (!is_array($info = mysqli_get_connection_stats($link)) || empty($info)) printf("[006] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); if (!is_array($info2 = mysqli_get_client_stats()) || empty($info2)) printf("[007] Expecting array/any_non_empty, got %s/%s\n", gettype($info2), $info2); // assuming the test is run in a plain-vanilla CLI environment if ($info === $info2) { printf("[008] The hashes should not be identical\n"); var_dump($info); var_dump($info2); } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_host_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_host_info.phpt +++ php-src/ext/mysqli/tests/mysqli_get_host_info.phpt --TEST-- mysqli_get_host_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_null($tmp = @mysqli_get_host_info())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_host_info(NULL))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require "table.inc"; if (!is_string($info = mysqli_get_host_info($link)) || ('' === $info)) printf("[003] Expecting string/any_non_empty, got %s/%s\n", gettype($info), $info); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_proto_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_proto_info.phpt +++ php-src/ext/mysqli/tests/mysqli_get_proto_info.phpt --TEST-- mysqli_get_proto_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_null($tmp = @mysqli_get_proto_info())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_proto_info(NULL))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require "table.inc"; if (!is_int($info = mysqli_get_proto_info($link)) || ($info < 1)) printf("[003] Expecting int/any_non_empty, got %s/%s\n", gettype($info), $info); if (!is_null($tmp = @mysqli_get_proto_info('too many', 'arguments'))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_server_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_server_info.phpt +++ php-src/ext/mysqli/tests/mysqli_get_server_info.phpt --TEST-- mysqli_get_server_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_null($tmp = @mysqli_get_server_info())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_server_info(NULL))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require "table.inc"; if (!is_string($info = mysqli_get_server_info($link)) || ('' === $info)) printf("[003] Expecting string/any_non_empty, got %s/%s\n", gettype($info), $info); if (!is_null($tmp = @mysqli_get_server_info('too', 'many arguments'))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_server_version.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_server_version.phpt +++ php-src/ext/mysqli/tests/mysqli_get_server_version.phpt --TEST-- mysqli_get_server_version() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_null($tmp = @mysqli_get_server_version())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_server_version(NULL))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require "table.inc"; /* 5.1.5 -> 50105 -- major_version*10000 + minor_version *100 + sub_version */ /* < 30000 = pre 3.2.3, very unlikely! */ if (!is_int($info = mysqli_get_server_version($link)) || ($info < (3 * 10000))) printf("[003] Expecting int/any >= 30000, got %s/%s\n", gettype($info), $info); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_warnings.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_warnings.phpt +++ php-src/ext/mysqli/tests/mysqli_get_warnings.phpt --TEST-- mysqli_get_warnings() - TODO --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); if (!$TEST_EXPERIMENTAL) die("skip - experimental (= unsupported) feature"); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_get_warnings())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_warnings($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_warnings(''))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { printf("[003] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); } if (false !== ($tmp = mysqli_get_warnings($link))) { printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); } if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, "CREATE TABLE test (id SMALLINT)")) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, "INSERT INTO test (id) VALUES (1000000)")) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($warning = mysqli_get_warnings($link)) || 'mysqli_warning' != get_class($warning)) { printf("[008] Expecting object/mysqli_warning, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); } if (!method_exists($warning, 'next')) printf("[009] Borked object, method next is missing\n"); $properties = array_merge(get_object_vars($warning), get_class_vars(get_class($warning))); if (!empty($properties)) printf("[010] Properties have always been magic, hidden things - why are they visible now, a BC break...\n"); if ((!is_string($warning->message)) || ('' == $warning->message)) /* NULL or not there at all */ printf("[011] Expecting string/not empty, got %s/%s\n", gettype($warning->message), $warning->message); if ((!is_string($warning->sqlstate)) || ('' == $warning->sqlstate)) /* NULL or not there at all */ printf("[012] Expecting string/not empty, got %s/%s\n", gettype($warning->sqlstate), $warning->sqlstate); if ((!is_int($warning->errno)) || (0 == $warning->errno)) /* NULL or not there at all */ printf("[013] Expecting int/not 0, got %s/%s\n", gettype($warning->errno), $warning->errno); if (false !== ($tmp = $warning->next())) printf("[014] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, "INSERT INTO test (id) VALUES (1000000), (1000001)")) printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (($tmp = mysqli_warning_count($link)) !== 2) printf("[016] Expecting 2 warnings, got %d warnings", $tmp); if (!is_object($warning = mysqli_get_warnings($link)) || 'mysqli_warning' != get_class($warning)) { printf("[017] Expecting object/mysqli_warning, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); } if (true !== ($tmp = $warning->next())) printf("[018] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = $warning->next())) printf("[020] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[021] Cannot create mysqli object: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); if (!$mysqli->query("DROP TABLE IF EXISTS t1")) printf("[022] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$mysqli->query("CREATE TABLE t1 (a smallint)")) printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($warning = new mysqli_warning($mysqli))) printf("[024] Expecting object/mysqli_warning, got %s/%s", gettype($warning), $warning); if (!is_string($warning->message) || ('' == $warning->message)) printf("[025] Expecting string, got %s/%s", gettype($warning->message), $warning->message); if (!$mysqli->query("DROP TABLE t1")) printf("[026] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); /* Yes, I really want to check if the object property is empty */ if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[027] Cannot create mysqli object: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); $warning = new mysqli_warning($mysqli); if (false !== ($tmp = $warning->next())) printf("[028] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if ('' != ($tmp = $warning->message)) printf("[029] Expecting string/empty, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[030] Cannot create mysqli object: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); if (!$mysqli->query("DROP TABLE IF EXISTS t1")) printf("[031] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$mysqli->query("CREATE TABLE t1 (a smallint)")) printf("[032] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); /* out of range, three warnings */ if (!$mysqli->query("INSERT IGNORE INTO t1(a) VALUES (65536), (65536), (65536)")) printf("[033] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $warning = new mysqli_warning($mysqli); $i = 1; while ($warning->next() && ('' != ($tmp = $warning->message))) { if (ini_get('unicode.semantics') && !is_unicode($tmp)) printf("[033a] Warning should have been a unicode string, got %s/%s", gettype($tmp), $tmp); $i++; } if (3 != $i) printf("[034] Expecting three warnings, got %d warnings\n", $i); $stmt = mysqli_stmt_init(); $warning = new mysqli_warning($stmt); if (false !== ($tmp = $warning->next())) printf("[035] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_info.phpt +++ php-src/ext/mysqli/tests/mysqli_info.phpt --TEST-- mysqli_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "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(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)); // NOTE: empty string, no multiple insert syntax if (!is_string($tmp = mysqli_info($link)) || ('' != $tmp)) printf("[004] Expecting string/empty, 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 (!is_string($tmp = mysqli_info($link)) || ('' == $tmp)) printf("[006] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp); if (ini_get('unicode.semantics') && !is_unicode($tmp)) printf("[007] Expecting unicode, because unicode mode it on. Got binary string\n"); 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 (!$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 (!$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 (!$res = mysqli_query($link, "SELECT 1")) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_string($tmp = mysqli_info($link)) || ('' != $tmp)) printf("[014] Expecting string/empty, 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; if (!fwrite($fp, b"100;'a';\n") || !fwrite($fp, b"101;'b';\n") || !fwrite($fp, b"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 (!is_string($tmp = mysqli_info($link)) || ('' == $tmp)) printf("[015] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp); unlink($file); } while (false); } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_init.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_init.phpt +++ php-src/ext/mysqli/tests/mysqli_init.phpt --TEST-- mysqli_init() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php $link = mysqli_init(); if (!is_object($link) && false !== $link) printf("[001] Expecting object/mysqli_link or boolean/false, got %s/%s\n", gettype($link), $link); if (is_object($link) && 'mysqli' != get_class($link)) printf("[002] Expecting object of type mysqli got object of type %s\n", get_class($link)); if ($link) mysqli_close($link); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_insert_id.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_insert_id.phpt +++ php-src/ext/mysqli/tests/mysqli_insert_id.phpt --TEST-- mysqli_insert_id() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_insert_id())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_insert_id($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (0 !== ($tmp = mysqli_insert_id($link))) printf("[003] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id LIMIT 1")) { printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (0 !== ($tmp = mysqli_insert_id($link))) printf("[005] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); mysqli_free_result($res); // no auto_increment column if (!$res = mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, 'a')")) { printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (0 !== ($tmp = mysqli_insert_id($link))) printf("[007] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, "ALTER TABLE test MODIFY id INT NOT NULL AUTO_INCREMENT")) { printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (!$res = mysqli_query($link, "INSERT INTO test(label) VALUES ('a')")) { printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (($last_id = mysqli_insert_id($link)) <= 0) printf("[010] Expecting int/any >0, got %s/%s\n", gettype($last_id), $last_id); if (mysqli_query($link, "LOCK TABLE test WRITE")) { /* we need exclusive access for a moment */ /* let's hope nobody changes auto_increment_increment while this code executes */ do { if (mysqli_get_server_version($link) >= 50000) { if (!$res = mysqli_query($link, 'SELECT @@auto_increment_increment AS inc')) { printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } if (!$row = mysqli_fetch_assoc($res)) { printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } mysqli_free_result($res); $inc = $row['inc']; } else { $inc = 1; } if (!mysqli_query($link, "INSERT INTO test(label) VALUES ('b')")) { printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } if (($next_id = mysqli_insert_id($link)) <= $last_id) /* very likely a bug, but someone could have done something on the server between the second last insert and the lock, therefore don't stop just bail */ printf("[014] Expecting int/any > %d, got %s/%s\n", $last_id, gettype($next_id), $next_id); $last_id = $next_id; if (!mysqli_query($link, "INSERT INTO test(label) VALUES ('c'), ('d'), ('e')")) { printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } /* Note: For a multiple-row insert, LAST_INSERT_ID() and mysql_insert_id() actually return the AUTO_INCREMENT key from the first of the inserted rows. This allows multiple-row inserts to be reproduced correctly on other servers in a replication setup. */ if (($next_id = mysqli_insert_id($link)) != $last_id + $inc) { printf("[016] Expecting int/%d, got %s/%s\n", $last_id + 1, gettype($next_id), $next_id); break; } if (!$res = mysqli_query($link, "SELECT LAST_INSERT_ID() AS last_id")) { printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } if (!$row = mysqli_fetch_assoc($res)) { printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } mysqli_free_result($res); if ($next_id != $row['last_id']) { printf("[018] Something is wrong, check manually. Expecting %s got %s.\n", $next_id, $row['last_id']); break; } } while (false); mysqli_query($link, "UNLOCK TABLE test"); } mysqli_close($link); var_dump(mysqli_insert_id($link)); print "done!"; ?> --EXPECTF-- Warning: mysqli_insert_id(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_kill.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_kill.phpt +++ php-src/ext/mysqli/tests/mysqli_kill.phpt --TEST-- mysqli_kill() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_kill())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_kill($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); // Zend will cast the NULL to 0 if (!is_bool($tmp = mysqli_kill($link, null))) printf("[003] Expecting boolean/any, got %s/%s\n", gettype($tmp), $tmp); if (!$thread_id = mysqli_thread_id($link)) printf("[004] Cannot determine thread id, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_kill($link, $thread_id); if (!is_bool($tmp)) printf("[005] Expecting boolean/any, got %s/%s\n", gettype($tmp), $tmp); if ($res = mysqli_query($link, "SELECT id FROM test LIMIT 1")) pintf("[006] Expecting boolean/false, got %s/%s\n", gettype($res), $res); var_dump($error = mysqli_error($link)); if (!is_string($error) || ('' === $error)) printf("[007] Expecting string/any non empty, got %s/%s\n", gettype($error), $error); var_dump($res); var_dump($link); mysqli_close($link); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[008] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); mysqli_kill($link, -1); if ((!$res = mysqli_query($link, "SELECT id FROM test LIMIT 1")) || (!$tmp = mysqli_fetch_assoc($res))) { printf("[009] Connection should not be gone, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } var_dump($tmp); mysqli_free_result($res); mysqli_close($link); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[010] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); mysqli_change_user($link, "This might work if you accept anonymous users in your setup", "password", $db); mysqli_kill($link, -1); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_kill(): processid should have positive value in %s on line %d string(%d) "%s" bool(false) object(mysqli)#%d (0) { } Warning: mysqli_kill(): processid should have positive value in %s on line %d array(1) { ["id"]=> string(1) "1" } Warning: mysqli_kill(): processid should have positive value in %s on line %d done! --UEXPECTF-- Warning: mysqli_kill(): processid should have positive value in %s on line %d unicode(%d) "%s" bool(false) object(mysqli)#%d (0) { } Warning: mysqli_kill(): processid should have positive value in %s on line %d array(1) { [u"id"]=> unicode(1) "1" } Warning: mysqli_kill(): processid should have positive value in %s on line %d done!
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_cache_stats_free_buffered.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_cache_stats_free_buffered.phpt +++ php-src/ext/mysqli/tests/mysqli_get_cache_stats_free_buffered.phpt --TEST-- mysqli_get_cache_stats() - freeing for buffered result sets --SKIPIF-- <?PHP require_once('skipif.inc'); require_once('skipifemb.inc'); if (!function_exists('mysqli_get_cache_stats')) { die("skip only available with mysqlnd"); } if (ini_get("unicode.semantics")) { die("skip: zval cache works now only in non-unicode mode"); } ?> --FILE-- <?php include "connect.inc"; require_once('table.inc'); if (!is_array($info = mysqli_get_cache_stats()) || empty($info)) printf("[001] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id")) printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $rows = array(); while ($rows[] = mysqli_fetch_assoc($res)) ; mysqli_free_result($res); if (!is_array($new_info = mysqli_get_cache_stats()) || empty($new_info)) printf("[003] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info); if ($new_info['free_items'] >= $info['free_items']) { printf("[004] mysqli_free_result() should not yet have free slots again, because \$rows still exists\n"); var_dump($info); var_dump($new_info); } /* nothing should change because GC will happen some time after free_result */ unset($rows); if (!is_array($new_info = mysqli_get_cache_stats()) || empty($new_info)) printf("[005] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info); if (defined("WE_HAVE_GARBAGE_COLLECTOR_TO_FREE_AFTER_ON_UNSET_AFTER_FREE_RESULT")) { /* For now we can't reclaim the slots after the free_result is called. unset() should happen before free_result(). */ if ($new_info['free_items'] < $info['free_items']) { printf("[006] \$rows has been unset, free item count should be back to the original value\n"); var_dump($info); var_dump($new_info); } } else { /* We have to reset $info */ $info = mysqli_get_cache_stats(); } if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id")) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $rows = array(); while ($rows[] = mysqli_fetch_assoc($res)) ; unset($rows); mysqli_free_result($res); if (!is_array($new_info = mysqli_get_cache_stats()) || empty($new_info)) printf("[008] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info); if ($new_info['free_items'] < $info['free_items']) { printf("[009] \$rows has been unset, mysqli_free_result() has been called, free item count should be back to the original value\n"); var_dump($info); var_dump($new_info); } mysqli_close($link); if (!is_array($new_info = mysqli_get_cache_stats()) || empty($new_info)) printf("[010] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info); if ($new_info['free_items'] < $info['free_items']) { printf("[011] connection has been closed, free item count should be back to the original value\n"); var_dump($info); var_dump($new_info); } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_cache_stats.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_cache_stats.phpt +++ php-src/ext/mysqli/tests/mysqli_get_cache_stats.phpt --TEST-- mysqli_get_cache_stats() --SKIPIF-- <?PHP require_once('skipif.inc'); require_once('skipifemb.inc'); if (!function_exists('mysqli_get_cache_stats')) { die("skip only available with mysqlnd"); } if (ini_get("unicode.semantics")) { die("skip: zval cache works now only in non-unicode mode"); } ?> --FILE-- <?php $tmp = $link = null; if (!is_null($tmp = @mysqli_get_cache_stats($link))) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); include "connect.inc"; if (!is_array($info = mysqli_get_cache_stats()) || empty($info)) printf("[002] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); var_dump($info); if ($info['size'] !== $info['free_items']) printf("[003] Unused cache should have size (%d) == free_items (%d)\n", $info['size'], $info['free_items']); require_once('table.inc'); if (!is_array($new_info = mysqli_get_cache_stats()) || empty($new_info)) printf("[004] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info); if ($info['size'] !== $new_info['size']) printf("[005] Cache size should not have changes! Expecting int/%d, got %s/%d\n", $info['size'], gettype($new_info['size']), $new_info['size']); if (count($info) != count($new_info)) { printf("[006] Both arrays should have the same number of entries\n"); var_dump($info); var_dump($new_info); } if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id")) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($res = mysqli_use_result($link))) printf("[008] Expecting object, got %s/%s. [%d] %s\n", gettype($res), $res, mysqli_errno($link), mysqli_error($link)); if (!$row = mysqli_fetch_assoc($res)) printf("[009] There should be at least one row in the test table for this test, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_array($new_info = mysqli_get_cache_stats()) || empty($new_info)) printf("[010] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info); if ($new_info['get_hits'] <= $info['get_hits']) printf("[011] get_hits should have increased, %d (new) <= %d (old)!\n", $new_info['get_hits'], $info['get_hits']); if (!$row = mysqli_fetch_assoc($res)) printf("[012] There should be two rows in the test table for this test, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_array($new_info = mysqli_get_cache_stats()) || empty($new_info)) printf("[013] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info); if ($new_info['put_misses'] <= $info['put_misses']) printf("[014] put_misses should have increased, %d (new) <= %d (old)!\n", $new_info['put_misses'], $info['put_misses']); if ($new_info['references'] < $info['references'] + 2) printf("[015] reference counter should have increased, %d (new) < %d + 2 (old)!\n", $new_info['references'], $info['references']); unset($row); mysqli_free_result($res); if (!is_array($info = mysqli_get_cache_stats()) || empty($info)) printf("[016] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); if ($info['free_items'] <= $new_info['free_items']) printf("[017] Looks like cached entries never get free'd.\n"); mysqli_close($link); print "done!"; ?> --EXPECTF-- array(7) { ["put_hits"]=> int(0) ["put_misses"]=> int(0) ["get_hits"]=> int(0) ["get_misses"]=> int(0) ["size"]=> int(%d) ["free_items"]=> int(%d) ["references"]=> int(%d) } done! --UEXPECTF-- array(7) { [u"put_hits"]=> int(0) [u"put_misses"]=> int(0) [u"get_hits"]=> int(0) [u"get_misses"]=> int(0) [u"size"]=> int(%d) [u"free_items"]=> int(%d) [u"references"]=> int(%d) } done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_charset.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_charset.phpt +++ php-src/ext/mysqli/tests/mysqli_get_charset.phpt --TEST-- mysqli_get_charset() --SKIPIF-- <?php require_once('skipifemb.inc'); require_once('skipif.inc'); if (!function_exists('mysqli_get_charset')) die("skip: function not available"); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_get_charset())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_charset($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_set_charset($link, $link))) printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (!$res = mysqli_query($link, 'SELECT version() AS server_version')) printf("[004] [%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)) printf("[005] Cannot determine server version, need MySQL Server 4.1+ for the test!\n"); if ($version[0] <= 4 && $version[1] < 1) printf("[006] Need MySQL Server 4.1+ for the test!\n"); if (!$res = mysqli_query($link, 'SELECT @@character_set_connection AS charset, @@collation_connection AS collation')) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (!($character_set_connection = $tmp['charset']) || !($collation_connection = $tmp['collation'])) printf("[008] Cannot determine current character set and collation\n"); if (!$res = mysqli_query($link, $sql = sprintf('SHOW CHARACTER SET LIKE "%s"', $character_set_connection))) printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); if (empty($tmp)) printf("[010] Cannot fetch Maxlen and/or Comment, test will fail: $sql\n"); $maxlen = (isset($tmp['Maxlen'])) ? $tmp['Maxlen'] : ''; $comment = (isset($tmp['Description'])) ? $tmp['Description'] : ''; if (!$res = mysqli_query($link, sprintf('SHOW COLLATION LIKE "%s"', $collation_connection))) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (!($id = $tmp['Id'])) printf("[012] Cannot fetch Id/Number, test will fail\n"); if (!$res = mysqli_query($link, sprintf('SHOW VARIABLES LIKE "character_sets_dir"'))) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_fetch_assoc($res); mysqli_free_result($res); if (!($character_sets_dir = $tmp['Value'])) printf("[014] Cannot fetch character_sets_dir, test will fail\n"); if (!is_object($charset = mysqli_get_charset($link))) printf("[015] Expecting object/std_class, got %s/%s\n", gettype($charset), $charset); if (!isset($charset->charset) || !in_array(gettype($charset->charset), array("string", "unicode")) || ($character_set_connection !== $charset->charset)) printf("[016] Expecting string/%s, got %s/%s\n", $character_set_connection, gettype($charset->charset), $charset->charset); if (!isset($charset->collation) || !in_array(gettype($charset->collation), array("string", "unicode")) || ($collation_connection !== $charset->collation)) printf("[017] Expecting string/%s, got %s/%s\n", $collation_connection, gettype($charset->collation), $charset->collation); if (!isset($charset->dir) || !is_string($charset->dir)) printf("[019] Expecting string - ideally %s*, got %s/%s\n", $character_sets_dir, gettype($charset->dir), $charset->dir); if (!isset($charset->min_length) || !(is_int($charset->min_length)) || ($charset->min_length < 0) || ($charset->min_length > $charset->max_length)) printf("[020] Expecting int between 0 ... %d, got %s/%s\n", $charset->max_length, gettype($charset->min_length), $charset->min_length); if (!isset($charset->number) || !is_int($charset->number) || ($charset->number !== (int)$id)) printf("[021] Expecting int/%d, got %s/%s\n", $id, gettype($charset->number), $charset->number); if (!isset($charset->state) || !is_int($charset->state)) printf("[022] Expecting int/any, got %s/%s\n", gettype($charset->state), $charset->state); mysqli_close($link); if (NULL !== ($tmp = mysqli_get_charset($link))) printf("[023] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- Warning: mysqli_get_charset(): Couldn't fetch mysqli in %s on line %d done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_client_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_client_info.phpt +++ php-src/ext/mysqli/tests/mysqli_get_client_info.phpt --TEST-- mysqli_get_client_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_string($info = mysqli_get_client_info()) || ('' === $info)) printf("[001] Expecting string/any_non_empty, got %s/%s\n", gettype($info), $info); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_client_stats_implicit_free.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_client_stats_implicit_free.phpt +++ php-src/ext/mysqli/tests/mysqli_get_client_stats_implicit_free.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_client_stats_off.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_client_stats_off.phpt +++ php-src/ext/mysqli/tests/mysqli_get_client_stats_off.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_client_stats.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_client_stats.phpt +++ php-src/ext/mysqli/tests/mysqli_get_client_stats.phpt --TEST-- mysqli_get_client_stats() --SKIPIF-- <?PHP require_once('skipif.inc'); require_once('skipifemb.inc'); if (!function_exists('mysqli_get_client_stats')) { die("skip only available with mysqlnd"); } ?> --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); include "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 = 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 */ if (!ini_get("unicode.semantics")) 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_fetched_from_server', $new_info, $info, $test_counter); mysqli_get_client_stats_assert_eq('rows_fetched_from_client', $new_info, $info, $test_counter); mysqli_get_client_stats_assert_eq('rows_skipped', $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); 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); // // result_set_queries statistics // 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; // // 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, RENAME, 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_get_server_version($link) > 51700) { if (!mysqli_query($link, "RENAME DATABASE mysqli_get_client_stats TO mysqli_get_client_stats_")) printf("[%03d] RENAME 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; } else { 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; } /* 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); } /* 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; /* 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!"; ?> --EXPECTF-- array(33) { ["bytes_sent"]=> string(1) "0" ["bytes_received"]=> string(1) "0" ["packets_sent"]=> string(1) "0" ["packets_received"]=> string(1) "0" ["protocol_overhead_in"]=> string(1) "0" ["protocol_overhead_out"]=> string(1) "0" ["result_set_queries"]=> string(1) "0" ["non_result_set_queries"]=> string(1) "0" ["no_index_used"]=> string(1) "0" ["bad_index_used"]=> string(1) "0" ["buffered_sets"]=> string(1) "0" ["unbuffered_sets"]=> string(1) "0" ["ps_buffered_sets"]=> string(1) "0" ["ps_unbuffered_sets"]=> string(1) "0" ["flushed_normal_sets"]=> string(1) "0" ["flushed_ps_sets"]=> string(1) "0" ["rows_fetched_from_server"]=> string(1) "0" ["rows_fetched_from_client"]=> string(1) "0" ["rows_skipped"]=> string(1) "0" ["copy_on_write_saved"]=> string(1) "0" ["copy_on_write_performed"]=> string(1) "0" ["command_buffer_too_small"]=> string(1) "0" ["connect_success"]=> string(1) "0" ["connect_failure"]=> string(1) "0" ["connection_reused"]=> string(1) "0" ["explicit_close"]=> string(1) "0" ["implicit_close"]=> string(1) "0" ["disconnect_close"]=> string(1) "0" ["in_middle_of_command_close"]=> string(1) "0" ["explicit_free_result"]=> string(1) "0" ["implicit_free_result"]=> string(1) "0" ["explicit_stmt_close"]=> string(1) "0" ["implicit_stmt_close"]=> string(1) "0" } done! --UEXPECTF-- array(33) { [u"bytes_sent"]=> unicode(1) "0" [u"bytes_received"]=> unicode(1) "0" [u"packets_sent"]=> unicode(1) "0" [u"packets_received"]=> unicode(1) "0" [u"protocol_overhead_in"]=> unicode(1) "0" [u"protocol_overhead_out"]=> unicode(1) "0" [u"result_set_queries"]=> unicode(1) "0" [u"non_result_set_queries"]=> unicode(1) "0" [u"no_index_used"]=> unicode(1) "0" [u"bad_index_used"]=> unicode(1) "0" [u"buffered_sets"]=> unicode(1) "0" [u"unbuffered_sets"]=> unicode(1) "0" [u"ps_buffered_sets"]=> unicode(1) "0" [u"ps_unbuffered_sets"]=> unicode(1) "0" [u"flushed_normal_sets"]=> unicode(1) "0" [u"flushed_ps_sets"]=> unicode(1) "0" [u"rows_fetched_from_server"]=> unicode(1) "0" [u"rows_fetched_from_client"]=> unicode(1) "0" [u"rows_skipped"]=> unicode(1) "0" [u"copy_on_write_saved"]=> unicode(1) "0" [u"copy_on_write_performed"]=> unicode(1) "0" [u"command_buffer_too_small"]=> unicode(1) "0" [u"connect_success"]=> unicode(1) "0" [u"connect_failure"]=> unicode(1) "0" [u"connection_reused"]=> unicode(1) "0" [u"explicit_close"]=> unicode(1) "0" [u"implicit_close"]=> unicode(1) "0" [u"disconnect_close"]=> unicode(1) "0" [u"in_middle_of_command_close"]=> unicode(1) "0" [u"explicit_free_result"]=> unicode(1) "0" [u"implicit_free_result"]=> unicode(1) "0" [u"explicit_stmt_close"]=> unicode(1) "0" [u"implicit_stmt_close"]=> unicode(1) "0" } done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_client_stats_ps.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_client_stats_ps.phpt +++ php-src/ext/mysqli/tests/mysqli_get_client_stats_ps.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_client_stats_skipped.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_client_stats_skipped.phpt +++ php-src/ext/mysqli/tests/mysqli_get_client_stats_skipped.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_client_version.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_client_version.phpt +++ php-src/ext/mysqli/tests/mysqli_get_client_version.phpt --TEST-- mysqli_get_client_version() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_int($info = mysqli_get_client_version()) || ($info < 100)) printf("[001] Expecting int/any_non_empty, got %s/%s\n", gettype($info), $info); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_connection_stats.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_connection_stats.phpt +++ php-src/ext/mysqli/tests/mysqli_get_connection_stats.phpt --TEST-- mysqli_get_connection_stats() --SKIPIF-- <?PHP require_once('skipif.inc'); require_once('skipifemb.inc'); if (!function_exists('mysqli_get_connection_stats')) { die("skip only available with mysqlnd"); } ?> --FILE-- <?php $tmp = $link = null; if (!is_null($tmp = @mysqli_get_connection_stats())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_connection_stats($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); include "connect.inc"; include "table.inc"; if (!is_array($info = mysqli_get_connection_stats($link)) || empty($info)) printf("[003] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); if (!is_array($info2 = mysqli_get_client_stats()) || empty($info2)) printf("[004] Expecting array/any_non_empty, got %s/%s\n", gettype($info2), $info2); if ($info !== $info2) { printf("[005] The hashes should be identical\n"); var_dump($info); var_dump($info2); } mysqli_close($link); include "table.inc"; if (!is_array($info = mysqli_get_connection_stats($link)) || empty($info)) printf("[006] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); if (!is_array($info2 = mysqli_get_client_stats()) || empty($info2)) printf("[007] Expecting array/any_non_empty, got %s/%s\n", gettype($info2), $info2); // assuming the test is run in a plain-vanilla CLI environment if ($info === $info2) { printf("[008] The hashes should not be identical\n"); var_dump($info); var_dump($info2); } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_host_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_host_info.phpt +++ php-src/ext/mysqli/tests/mysqli_get_host_info.phpt --TEST-- mysqli_get_host_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_null($tmp = @mysqli_get_host_info())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_host_info(NULL))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require "table.inc"; if (!is_string($info = mysqli_get_host_info($link)) || ('' === $info)) printf("[003] Expecting string/any_non_empty, got %s/%s\n", gettype($info), $info); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_proto_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_proto_info.phpt +++ php-src/ext/mysqli/tests/mysqli_get_proto_info.phpt --TEST-- mysqli_get_proto_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_null($tmp = @mysqli_get_proto_info())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_proto_info(NULL))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require "table.inc"; if (!is_int($info = mysqli_get_proto_info($link)) || ($info < 1)) printf("[003] Expecting int/any_non_empty, got %s/%s\n", gettype($info), $info); if (!is_null($tmp = @mysqli_get_proto_info('too many', 'arguments'))) printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_server_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_server_info.phpt +++ php-src/ext/mysqli/tests/mysqli_get_server_info.phpt --TEST-- mysqli_get_server_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_null($tmp = @mysqli_get_server_info())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_server_info(NULL))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require "table.inc"; if (!is_string($info = mysqli_get_server_info($link)) || ('' === $info)) printf("[003] Expecting string/any_non_empty, got %s/%s\n", gettype($info), $info); if (!is_null($tmp = @mysqli_get_server_info('too', 'many arguments'))) printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_server_version.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_server_version.phpt +++ php-src/ext/mysqli/tests/mysqli_get_server_version.phpt --TEST-- mysqli_get_server_version() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; if (!is_null($tmp = @mysqli_get_server_version())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_server_version(NULL))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require "table.inc"; /* 5.1.5 -> 50105 -- major_version*10000 + minor_version *100 + sub_version */ /* < 30000 = pre 3.2.3, very unlikely! */ if (!is_int($info = mysqli_get_server_version($link)) || ($info < (3 * 10000))) printf("[003] Expecting int/any >= 30000, got %s/%s\n", gettype($info), $info); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_get_warnings.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_get_warnings.phpt +++ php-src/ext/mysqli/tests/mysqli_get_warnings.phpt --TEST-- mysqli_get_warnings() - TODO --SKIPIF-- <?php require_once('skipif.inc'); require_once('skipifemb.inc'); require_once('connect.inc'); if (!$TEST_EXPERIMENTAL) die("skip - experimental (= unsupported) feature"); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_get_warnings())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_warnings($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_get_warnings(''))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { printf("[003] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); } if (false !== ($tmp = mysqli_get_warnings($link))) { printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); } if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, "CREATE TABLE test (id SMALLINT)")) printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, "INSERT INTO test (id) VALUES (1000000)")) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($warning = mysqli_get_warnings($link)) || 'mysqli_warning' != get_class($warning)) { printf("[008] Expecting object/mysqli_warning, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); } if (!method_exists($warning, 'next')) printf("[009] Borked object, method next is missing\n"); $properties = array_merge(get_object_vars($warning), get_class_vars(get_class($warning))); if (!empty($properties)) printf("[010] Properties have always been magic, hidden things - why are they visible now, a BC break...\n"); if ((!is_string($warning->message)) || ('' == $warning->message)) /* NULL or not there at all */ printf("[011] Expecting string/not empty, got %s/%s\n", gettype($warning->message), $warning->message); if ((!is_string($warning->sqlstate)) || ('' == $warning->sqlstate)) /* NULL or not there at all */ printf("[012] Expecting string/not empty, got %s/%s\n", gettype($warning->sqlstate), $warning->sqlstate); if ((!is_int($warning->errno)) || (0 == $warning->errno)) /* NULL or not there at all */ printf("[013] Expecting int/not 0, got %s/%s\n", gettype($warning->errno), $warning->errno); if (false !== ($tmp = $warning->next())) printf("[014] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (!mysqli_query($link, "INSERT INTO test (id) VALUES (1000000), (1000001)")) printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (($tmp = mysqli_warning_count($link)) !== 2) printf("[016] Expecting 2 warnings, got %d warnings", $tmp); if (!is_object($warning = mysqli_get_warnings($link)) || 'mysqli_warning' != get_class($warning)) { printf("[017] Expecting object/mysqli_warning, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); } if (true !== ($tmp = $warning->next())) printf("[018] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (false !== ($tmp = $warning->next())) printf("[020] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); mysqli_close($link); if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[021] Cannot create mysqli object: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); if (!$mysqli->query("DROP TABLE IF EXISTS t1")) printf("[022] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$mysqli->query("CREATE TABLE t1 (a smallint)")) printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_object($warning = new mysqli_warning($mysqli))) printf("[024] Expecting object/mysqli_warning, got %s/%s", gettype($warning), $warning); if (!is_string($warning->message) || ('' == $warning->message)) printf("[025] Expecting string, got %s/%s", gettype($warning->message), $warning->message); if (!$mysqli->query("DROP TABLE t1")) printf("[026] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); /* Yes, I really want to check if the object property is empty */ if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[027] Cannot create mysqli object: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); $warning = new mysqli_warning($mysqli); if (false !== ($tmp = $warning->next())) printf("[028] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); if ('' != ($tmp = $warning->message)) printf("[029] Expecting string/empty, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) printf("[030] Cannot create mysqli object: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); if (!$mysqli->query("DROP TABLE IF EXISTS t1")) printf("[031] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$mysqli->query("CREATE TABLE t1 (a smallint)")) printf("[032] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); /* out of range, three warnings */ if (!$mysqli->query("INSERT IGNORE INTO t1(a) VALUES (65536), (65536), (65536)")) printf("[033] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $warning = new mysqli_warning($mysqli); $i = 1; while ($warning->next() && ('' != ($tmp = $warning->message))) { if (ini_get('unicode.semantics') && !is_unicode($tmp)) printf("[033a] Warning should have been a unicode string, got %s/%s", gettype($tmp), $tmp); $i++; } if (3 != $i) printf("[034] Expecting three warnings, got %d warnings\n", $i); $stmt = mysqli_stmt_init(); $warning = new mysqli_warning($stmt); if (false !== ($tmp = $warning->next())) printf("[035] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_info.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_info.phpt +++ php-src/ext/mysqli/tests/mysqli_info.phpt --TEST-- mysqli_info() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "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(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)); // NOTE: empty string, no multiple insert syntax if (!is_string($tmp = mysqli_info($link)) || ('' != $tmp)) printf("[004] Expecting string/empty, 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 (!is_string($tmp = mysqli_info($link)) || ('' == $tmp)) printf("[006] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp); if (ini_get('unicode.semantics') && !is_unicode($tmp)) printf("[007] Expecting unicode, because unicode mode it on. Got binary string\n"); 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 (!$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 (!$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 (!$res = mysqli_query($link, "SELECT 1")) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!is_string($tmp = mysqli_info($link)) || ('' != $tmp)) printf("[014] Expecting string/empty, 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; if (!fwrite($fp, b"100;'a';\n") || !fwrite($fp, b"101;'b';\n") || !fwrite($fp, b"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 (!is_string($tmp = mysqli_info($link)) || ('' == $tmp)) printf("[015] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp); unlink($file); } while (false); } print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_init.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_init.phpt +++ php-src/ext/mysqli/tests/mysqli_init.phpt --TEST-- mysqli_init() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php $link = mysqli_init(); if (!is_object($link) && false !== $link) printf("[001] Expecting object/mysqli_link or boolean/false, got %s/%s\n", gettype($link), $link); if (is_object($link) && 'mysqli' != get_class($link)) printf("[002] Expecting object of type mysqli got object of type %s\n", get_class($link)); if ($link) mysqli_close($link); print "done!"; ?> --EXPECTF-- done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_insert_id.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_insert_id.phpt +++ php-src/ext/mysqli/tests/mysqli_insert_id.phpt --TEST-- mysqli_insert_id() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_insert_id())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_insert_id($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); if (0 !== ($tmp = mysqli_insert_id($link))) printf("[003] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id LIMIT 1")) { printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (0 !== ($tmp = mysqli_insert_id($link))) printf("[005] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); mysqli_free_result($res); // no auto_increment column if (!$res = mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, 'a')")) { printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (0 !== ($tmp = mysqli_insert_id($link))) printf("[007] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!$res = mysqli_query($link, "ALTER TABLE test MODIFY id INT NOT NULL AUTO_INCREMENT")) { printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (!$res = mysqli_query($link, "INSERT INTO test(label) VALUES ('a')")) { printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (($last_id = mysqli_insert_id($link)) <= 0) printf("[010] Expecting int/any >0, got %s/%s\n", gettype($last_id), $last_id); if (mysqli_query($link, "LOCK TABLE test WRITE")) { /* we need exclusive access for a moment */ /* let's hope nobody changes auto_increment_increment while this code executes */ do { if (mysqli_get_server_version($link) >= 50000) { if (!$res = mysqli_query($link, 'SELECT @@auto_increment_increment AS inc')) { printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } if (!$row = mysqli_fetch_assoc($res)) { printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } mysqli_free_result($res); $inc = $row['inc']; } else { $inc = 1; } if (!mysqli_query($link, "INSERT INTO test(label) VALUES ('b')")) { printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } if (($next_id = mysqli_insert_id($link)) <= $last_id) /* very likely a bug, but someone could have done something on the server between the second last insert and the lock, therefore don't stop just bail */ printf("[014] Expecting int/any > %d, got %s/%s\n", $last_id, gettype($next_id), $next_id); $last_id = $next_id; if (!mysqli_query($link, "INSERT INTO test(label) VALUES ('c'), ('d'), ('e')")) { printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } /* Note: For a multiple-row insert, LAST_INSERT_ID() and mysql_insert_id() actually return the AUTO_INCREMENT key from the first of the inserted rows. This allows multiple-row inserts to be reproduced correctly on other servers in a replication setup. */ if (($next_id = mysqli_insert_id($link)) != $last_id + $inc) { printf("[016] Expecting int/%d, got %s/%s\n", $last_id + 1, gettype($next_id), $next_id); break; } if (!$res = mysqli_query($link, "SELECT LAST_INSERT_ID() AS last_id")) { printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } if (!$row = mysqli_fetch_assoc($res)) { printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } mysqli_free_result($res); if ($next_id != $row['last_id']) { printf("[018] Something is wrong, check manually. Expecting %s got %s.\n", $next_id, $row['last_id']); break; } } while (false); mysqli_query($link, "UNLOCK TABLE test"); } mysqli_close($link); var_dump(mysqli_insert_id($link)); print "done!"; ?> --EXPECTF-- Warning: mysqli_insert_id(): Couldn't fetch mysqli in %s on line %d NULL done! http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_kill.phpt?view=markup&rev=1.1 Index: php-src/ext/mysqli/tests/mysqli_kill.phpt +++ php-src/ext/mysqli/tests/mysqli_kill.phpt --TEST-- mysqli_kill() --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysqli_kill())) printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); if (!is_null($tmp = @mysqli_kill($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); // Zend will cast the NULL to 0 if (!is_bool($tmp = mysqli_kill($link, null))) printf("[003] Expecting boolean/any, got %s/%s\n", gettype($tmp), $tmp); if (!$thread_id = mysqli_thread_id($link)) printf("[004] Cannot determine thread id, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $tmp = mysqli_kill($link, $thread_id); if (!is_bool($tmp)) printf("[005] Expecting boolean/any, got %s/%s\n", gettype($tmp), $tmp); if ($res = mysqli_query($link, "SELECT id FROM test LIMIT 1")) pintf("[006] Expecting boolean/false, got %s/%s\n", gettype($res), $res); var_dump($error = mysqli_error($link)); if (!is_string($error) || ('' === $error)) printf("[007] Expecting string/any non empty, got %s/%s\n", gettype($error), $error); var_dump($res); var_dump($link); mysqli_close($link); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[008] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); mysqli_kill($link, -1); if ((!$res = mysqli_query($link, "SELECT id FROM test LIMIT 1")) || (!$tmp = mysqli_fetch_assoc($res))) { printf("[009] Connection should not be gone, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } var_dump($tmp); mysqli_free_result($res); mysqli_close($link); if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[010] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); mysqli_change_user($link, "This might work if you accept anonymous users in your setup", "password", $db); mysqli_kill($link, -1); mysqli_close($link); print "done!"; ?> --EXPECTF-- Warning: mysqli_kill(): processid should have positive value in %s on line %d string(%d) "%s" bool(false) object(mysqli)#%d (0) { } Warning: mysqli_kill(): processid should have positive value in %s on line %d array(1) { ["id"]=> string(1) "1" } Warning: mysqli_kill(): processid should have positive value in %s on line %d done! --UEXPECTF-- Warning: mysqli_kill(): processid should have positive value in %s on line %d unicode(%d) "%s" bool(false) object(mysqli)#%d (0) { } Warning: mysqli_kill(): processid should have positive value in %s on line %d array(1) { [u"id"]=> unicode(1) "1" } Warning: mysqli_kill(): processid should have positive value in %s on line %d done!