1--TEST--
2mysqli_get_client_stats() - skipped rows
3--INI--
4mysqlnd.collect_statistics="1"
5mysqlnd.collect_memory_statistics="1"
6--EXTENSIONS--
7mysqli
8--SKIPIF--
9<?PHP
10require_once 'skipifconnectfailure.inc';
11?>
12--FILE--
13<?php
14    require_once 'connect.inc';
15    require_once 'table.inc';
16
17    if (!$res = mysqli_query($link, 'SELECT id FROM test', MYSQLI_STORE_RESULT))
18        printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
19
20    $num_rows = mysqli_num_rows($res);
21    assert($num_rows > 2);
22    mysqli_free_result($res);
23
24    $before = mysqli_get_client_stats();
25    printf("BEFORE: rows_skipped_normal = %d\n", $before['rows_skipped_normal']);
26
27    if (!$res = mysqli_query($link, 'SELECT id FROM test', MYSQLI_USE_RESULT))
28        printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
29
30    /* fetch all rows but the last one */
31    for ($i = 0; $i < $num_rows - 1; $i++)
32        mysqli_fetch_assoc($res);
33
34    /* enforce implicit cleaning of the wire and skipping the last row */
35    mysqli_free_result($res);
36    $after = mysqli_get_client_stats();
37    printf("AFTER: rows_skipped_normal = %d\n", $after['rows_skipped_normal']);
38
39    if ($after['rows_skipped_normal'] != $before['rows_skipped_normal'] + 1)
40        printf("Statistics should show an increase of 1 for rows_skipped_normal, ".
41                "but before=%d after=%d\n", $before['rows_skipped_normal'], $after['rows_skipped_normal']);
42
43    mysqli_close($link);
44    print "done!";
45?>
46--EXPECTF--
47BEFORE: rows_skipped_normal = %d
48AFTER: rows_skipped_normal = %d
49done!
50