1--TEST--
2mysqli_get_client_stats() - implicit_free_result
3--SKIPIF--
4<?PHP
5require_once('skipif.inc');
6require_once('skipifemb.inc');
7require_once('skipifconnectfailure.inc');
8if (!function_exists('mysqli_get_client_stats')) {
9	die("skip only available with mysqlnd");
10}
11?>
12--INI--
13mysqlnd.collect_statistics=1
14mysqlnd.collect_memory_statistics=1
15--FILE--
16<?php
17	require_once('connect.inc');
18	require_once('table.inc');
19
20	$stats = mysqli_get_client_stats();
21	printf("BEGINNING: implicit_free_result = %d\n",	$stats['implicit_free_result']);
22
23	if (!$res = mysqli_query($link, 'SELECT id FROM test'))
24		printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
25
26	mysqli_free_result($res);
27	mysqli_close($link);
28
29	$after = mysqli_get_client_stats();
30	if ($after['implicit_free_result'] != $stats['implicit_free_result'])
31		printf("[002] Where is the missing mysqli_free_result() call? implicit_free_result has changed by %d.\n",
32			$after['implicit_free_result'] - $stats['implicit_free_result']);
33
34	$stats = $after;
35	printf("END: implicit_free_result = %d\n",	$stats['implicit_free_result']);
36
37	print "done!";
38?>
39--CLEAN--
40<?php
41	require_once("clean_table.inc");
42?>
43--EXPECTF--
44BEGINNING: implicit_free_result = %d
45END: implicit_free_result = %d
46done!
47