Author: uwendel
Date: 2007-02-23 11:23:12 +0100 (Fri, 23 Feb 2007)
New Revision: 59
Modified:
trunk/ext/mysqli/tests/mysqli_get_cache_stats.phpt
Log:
As I understood Andrey, cache entries should be free'd on mysqli_free_result() (if there's
no more references to them). This seems not the case. Free happens only at
mysqli_close. Test fails.
Modified: trunk/ext/mysqli/tests/mysqli_get_cache_stats.phpt
===================================================================
--- trunk/ext/mysqli/tests/mysqli_get_cache_stats.phpt 2007-02-23 08:46:34 UTC (rev 58)
+++ trunk/ext/mysqli/tests/mysqli_get_cache_stats.phpt 2007-02-23 10:23:12 UTC (rev 59)
@@ -19,7 +19,88 @@
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']);
+
+ 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--
-I'm a stub
\ No newline at end of file
+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!
\ No newline at end of file
| Thread |
|---|
| • PHP mysqlnd svn commit: r59 - trunk/ext/mysqli/tests | uwendel | 23 Feb |