2007-10-10 10:16:00 +00:00
|
|
|
--TEST--
|
|
|
|
mysqli_get_connection_stats()
|
2009-07-01 12:52:58 +00:00
|
|
|
--INI--
|
|
|
|
mysqlnd.collect_statistics="1"
|
|
|
|
mysqlnd.collect_memory_statistics="1"
|
2007-10-10 10:16:00 +00:00
|
|
|
--SKIPIF--
|
|
|
|
<?PHP
|
|
|
|
require_once('skipif.inc');
|
|
|
|
require_once('skipifemb.inc');
|
|
|
|
require_once('skipifconnectfailure.inc');
|
|
|
|
if (!function_exists('mysqli_get_connection_stats')) {
|
|
|
|
die("skip only available with mysqlnd");
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
--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);
|
|
|
|
|
2009-10-19 20:07:25 +00:00
|
|
|
require("table.inc");
|
2007-10-10 10:16:00 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
foreach ($info as $k => &$v) {
|
|
|
|
if (strpos($k, "mem_") === 0) {
|
|
|
|
$v = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
foreach ($info2 as $k => &$v) {
|
|
|
|
if (strpos($k, "mem_") === 0) {
|
|
|
|
$v = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($info !== $info2) {
|
2009-07-01 12:52:58 +00:00
|
|
|
printf("[005] The hashes should be identical except of the memory related fields\n");
|
2007-10-10 10:16:00 +00:00
|
|
|
var_dump($info);
|
|
|
|
var_dump($info2);
|
|
|
|
}
|
|
|
|
|
2009-09-24 08:19:56 +00:00
|
|
|
if (!is_array($info = $link->get_connection_stats()) || empty($info))
|
|
|
|
printf("[006] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info);
|
|
|
|
|
|
|
|
foreach ($info as $k => &$v) {
|
|
|
|
if (strpos($k, "mem_") === 0) {
|
|
|
|
$v = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($info !== $info2) {
|
|
|
|
printf("[007] The hashes should be identical except of the memory related fields\n");
|
|
|
|
var_dump($info);
|
|
|
|
var_dump($info2);
|
|
|
|
}
|
|
|
|
|
2007-10-10 10:16:00 +00:00
|
|
|
mysqli_close($link);
|
2009-10-19 20:07:25 +00:00
|
|
|
require("table.inc");
|
2007-10-10 10:16:00 +00:00
|
|
|
|
|
|
|
if (!is_array($info = mysqli_get_connection_stats($link)) || empty($info))
|
2009-09-24 08:19:56 +00:00
|
|
|
printf("[008] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info);
|
2007-10-10 10:16:00 +00:00
|
|
|
|
|
|
|
if (!is_array($info2 = mysqli_get_client_stats()) || empty($info2))
|
2009-09-24 08:19:56 +00:00
|
|
|
printf("[009] Expecting array/any_non_empty, got %s/%s\n", gettype($info2), $info2);
|
2007-10-10 10:16:00 +00:00
|
|
|
|
|
|
|
// assuming the test is run in a plain-vanilla CLI environment
|
|
|
|
if ($info === $info2) {
|
2009-09-24 08:19:56 +00:00
|
|
|
printf("[010] The hashes should not be identical\n");
|
2007-10-10 10:16:00 +00:00
|
|
|
var_dump($info);
|
|
|
|
var_dump($info2);
|
|
|
|
}
|
|
|
|
|
|
|
|
print "done!";
|
|
|
|
?>
|
2009-07-06 14:39:10 +00:00
|
|
|
--CLEAN--
|
|
|
|
<?php
|
|
|
|
require_once("clean_table.inc");
|
|
|
|
?>
|
2007-10-10 10:16:00 +00:00
|
|
|
--EXPECTF--
|
|
|
|
done!
|