mysqli_get_client_stats.phpt 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296
  1. --TEST--
  2. mysqli_get_client_stats()
  3. --SKIPIF--
  4. <?PHP
  5. require_once('skipif.inc');
  6. require_once('skipifemb.inc');
  7. require_once('skipifconnectfailure.inc');
  8. if (!function_exists('mysqli_get_client_stats')) {
  9. die("skip only available with mysqlnd");
  10. }
  11. ?>
  12. --INI--
  13. mysqlnd.collect_statistics=1
  14. mysqlnd.collect_memory_statistics=1
  15. --FILE--
  16. <?php
  17. /*
  18. TODO
  19. no_index_used - difficult to simulate because server/engine dependent
  20. bad_index_used - difficult to simulate because server/engine dependent
  21. flushed_normal_sets
  22. flushed_ps_sets
  23. explicit_close
  24. implicit_close
  25. disconnect_close
  26. in_middle_of_command_close
  27. explicit_free_result
  28. implicit_free_result
  29. explicit_stmt_close
  30. implicit_stmt_close
  31. */
  32. function mysqli_get_client_stats_assert_eq($field, $current, $expected, &$test_counter, $desc = "") {
  33. $test_counter++;
  34. if (is_array($current) && is_array($expected)) {
  35. if ($current[$field] !== $expected[$field]) {
  36. printf("[%03d] %s Expecting %s = %s/%s, got %s/%s\n",
  37. $test_counter, $desc,
  38. $field, $expected[$field], gettype($expected[$field]),
  39. $current[$field], gettype($current[$field]));
  40. }
  41. } else if (is_array($current)) {
  42. if ($current[$field] !== $expected) {
  43. printf("[%03d] %s Expecting %s = %s/%s, got %s/%s\n",
  44. $test_counter, $desc,
  45. $field, $expected, gettype($expected),
  46. $current[$field], gettype($current[$field]));
  47. }
  48. } else {
  49. if ($current !== $expected) {
  50. printf("[%03d] %s Expecting %s = %s/%s, got %s/%s\n",
  51. $test_counter, $desc,
  52. $field, $expected, gettype($expected),
  53. $current, gettype($current));
  54. }
  55. }
  56. }
  57. function mysqli_get_client_stats_assert_gt($field, $current, $expected, &$test_counter, $desc = "") {
  58. $test_counter++;
  59. if (is_array($current) && is_array($expected)) {
  60. if ($current[$field] <= $expected[$field]) {
  61. printf("[%03d] %s Expecting %s > %s/%s, got %s/%s\n",
  62. $test_counter, $desc,
  63. $field, $expected[$field], gettype($expected[$field]),
  64. $current[$field], gettype($current[$field]));
  65. }
  66. } else {
  67. if ($current <= $expected) {
  68. printf("[%03d] %s Expecting %s > %s/%s, got %s/%s\n",
  69. $test_counter, $desc, $field,
  70. $expected, gettype($expected),
  71. $current, gettype($current));
  72. }
  73. }
  74. }
  75. $tmp = $link = null;
  76. if (!is_null($tmp = @mysqli_get_client_stats($link)))
  77. printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  78. require_once("connect.inc");
  79. if (!is_array($info = mysqli_get_client_stats()) || empty($info))
  80. printf("[002] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info);
  81. var_dump($info);
  82. if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
  83. printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
  84. $host, $user, $db, $port, $socket);
  85. exit(1);
  86. }
  87. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  88. printf("[004] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info);
  89. if (count($info) != count($new_info)) {
  90. printf("[005] Expecting the same number of entries in the arrays\n");
  91. var_dump($info);
  92. var_dump($new_info);
  93. }
  94. $test_counter = 6;
  95. mysqli_get_client_stats_assert_gt('bytes_sent', $new_info, $info, $test_counter);
  96. mysqli_get_client_stats_assert_gt('bytes_received', $new_info, $info, $test_counter);
  97. mysqli_get_client_stats_assert_gt('packets_sent', $new_info, $info, $test_counter);
  98. mysqli_get_client_stats_assert_gt('packets_received', $new_info, $info, $test_counter);
  99. mysqli_get_client_stats_assert_gt('protocol_overhead_in', $new_info, $info, $test_counter);
  100. mysqli_get_client_stats_assert_gt('protocol_overhead_out', $new_info, $info, $test_counter);
  101. // we assume the above as tested and in the following we check only those
  102. mysqli_get_client_stats_assert_eq('result_set_queries', $new_info, $info, $test_counter);
  103. /* we need to skip this test in unicode - we send set names utf8 during mysql_connect */
  104. if (!(version_compare(PHP_VERSION, '5.9.9', '>') == 1))
  105. mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, $info, $test_counter);
  106. mysqli_get_client_stats_assert_eq('buffered_sets', $new_info, $info, $test_counter);
  107. mysqli_get_client_stats_assert_eq('unbuffered_sets', $new_info, $info, $test_counter);
  108. mysqli_get_client_stats_assert_eq('ps_buffered_sets', $new_info, $info, $test_counter);
  109. mysqli_get_client_stats_assert_eq('ps_unbuffered_sets', $new_info, $info, $test_counter);
  110. mysqli_get_client_stats_assert_eq('rows_skipped_ps', $new_info, $info, $test_counter);
  111. mysqli_get_client_stats_assert_eq('copy_on_write_saved', $new_info, $info, $test_counter);
  112. mysqli_get_client_stats_assert_eq('copy_on_write_performed', $new_info, $info, $test_counter);
  113. mysqli_get_client_stats_assert_eq('command_buffer_too_small', $new_info, $info, $test_counter);
  114. // This is not a mistake that I use %unicode|string%(1) "1" here! Andrey did not go for int to avoid any
  115. // issues for very large numbers and 32 vs. 64bit systems
  116. mysqli_get_client_stats_assert_eq('connect_success', $new_info, "1", $test_counter);
  117. mysqli_get_client_stats_assert_eq('connect_failure', $new_info, $info, $test_counter);
  118. mysqli_get_client_stats_assert_eq('connection_reused', $new_info, $info, $test_counter);
  119. // No data fetched so far
  120. mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $new_info, "0", $test_counter);
  121. mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $new_info, "0", $test_counter);
  122. require('table.inc');
  123. if (!is_array($info = mysqli_get_client_stats()) || empty($info))
  124. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  125. ++$test_counter, gettype($info), $info);
  126. // fetch stats
  127. $expected = $info;
  128. // buffered normal
  129. print "Testing buffered normal...\n";
  130. if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS _num FROM test', MYSQLI_STORE_RESULT))
  131. printf("[%03d] SELECT COUNT() FROM test failed, [%d] %s\n",
  132. ++$test_counter, mysqli_errno($link), mysqli_error($link));
  133. $expected['rows_fetched_from_server_normal'] = (string)($expected['rows_fetched_from_server_normal'] + 1);
  134. $expected['buffered_sets'] = (string)($expected['buffered_sets'] + 1);
  135. $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
  136. $expected['rows_buffered_from_client_normal'] = (string)($expected['rows_buffered_from_client_normal'] + 1);
  137. if (!is_array($info = mysqli_get_client_stats()) || empty($info))
  138. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  139. ++$test_counter, gettype($info), $info);
  140. mysqli_get_client_stats_assert_gt('bytes_sent', $info, $expected, $test_counter);
  141. mysqli_get_client_stats_assert_gt('bytes_received', $info, $expected, $test_counter);
  142. // real_data_* get incremented after mysqli_*fetch*()
  143. mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, "0", $test_counter);
  144. mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, "0", $test_counter);
  145. mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
  146. mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_buffered', $info, $expected, $test_counter);
  147. mysqli_get_client_stats_assert_eq('buffered_sets', $info, $expected, $test_counter);
  148. mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
  149. mysqli_get_client_stats_assert_eq('rows_buffered_from_client_normal', $info, $expected, $test_counter);
  150. /* no change to rows_fetched_from_client_normal_buffered! */
  151. if (!$row = mysqli_fetch_assoc($res))
  152. printf("[%03d] fetch_assoc - SELECT COUNT() FROM test failed, [%d] %s\n",
  153. ++$test_counter, mysqli_errno($link), mysqli_error($link));
  154. $expected['rows_fetched_from_client_normal_buffered'] = (string)($expected['rows_fetched_from_client_normal_buffered'] + 1);
  155. if (!is_array($info = mysqli_get_client_stats()) || empty($info))
  156. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  157. ++$test_counter, gettype($info), $info);
  158. // fetch will increment
  159. mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter);
  160. $expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal'];
  161. mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, "0", $test_counter);
  162. mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
  163. mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_buffered', $info, $expected, $test_counter);
  164. mysqli_get_client_stats_assert_eq('rows_buffered_from_client_normal', $info, $expected, $test_counter);
  165. $num_rows = $row['_num'];
  166. mysqli_free_result($res);
  167. print "Testing buffered normal... - SELECT id, label FROM test\n";
  168. if (!$res = mysqli_query($link, 'SELECT id, label FROM test', MYSQLI_STORE_RESULT))
  169. printf("[%03d] SELECT id, label FROM test failed, [%d] %s\n",
  170. ++$test_counter, mysqli_errno($link), mysqli_error($link));
  171. assert(mysqli_num_rows($res) == $num_rows);
  172. if (!is_array($info = mysqli_get_client_stats()) || empty($info))
  173. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  174. ++$test_counter, gettype($info), $info);
  175. $expected['rows_fetched_from_server_normal'] = (string)($expected['rows_fetched_from_server_normal'] + $num_rows);
  176. $expected['rows_buffered_from_client_normal'] = (string)($expected['rows_buffered_from_client_normal'] + $num_rows);
  177. $expected['buffered_sets'] = (string)($expected['buffered_sets'] + 1);
  178. $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
  179. mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
  180. mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
  181. mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_buffered', $info, $expected, $test_counter);
  182. mysqli_get_client_stats_assert_eq('buffered_sets', $info, $expected, $test_counter);
  183. mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
  184. mysqli_get_client_stats_assert_eq('rows_buffered_from_client_normal', $info, $expected, $test_counter);
  185. mysqli_get_client_stats_assert_eq('rows_buffered_from_client_normal', $info, $expected, $test_counter);
  186. /* fetching none, but stats should not be affected - current implementation */
  187. mysqli_free_result($res);
  188. if (!is_array($info = mysqli_get_client_stats()) || empty($info))
  189. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  190. ++$test_counter, gettype($info), $info);
  191. mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
  192. mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
  193. mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_buffered', $info, $expected, $test_counter);
  194. print "Testing unbuffered normal...\n";
  195. if (!$res = mysqli_query($link, 'SELECT id, label FROM test', MYSQLI_USE_RESULT))
  196. printf("[%03d] SELECT id, label FROM test failed, [%d] %s\n",
  197. ++$test_counter, mysqli_errno($link), mysqli_error($link));
  198. if (!is_array($info = mysqli_get_client_stats()) || empty($info))
  199. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  200. ++$test_counter, gettype($info), $info);
  201. mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
  202. mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_unbuffered', $info, $expected, $test_counter);
  203. mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
  204. while ($row = mysqli_fetch_assoc($res))
  205. ;
  206. mysqli_free_result($res);
  207. $expected['rows_fetched_from_server_normal'] = (string)($expected['rows_fetched_from_server_normal'] + $num_rows);
  208. $expected['rows_fetched_from_client_normal_unbuffered'] = (string)($expected['rows_fetched_from_client_normal_unbuffered'] + $num_rows);
  209. $expected['unbuffered_sets'] = (string)($expected['unbuffered_sets'] + 1);
  210. $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
  211. if (!is_array($info = mysqli_get_client_stats()) || empty($info))
  212. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  213. ++$test_counter, gettype($info), $info);
  214. mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter);
  215. $expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal'];
  216. mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
  217. mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_unbuffered', $info, $expected, $test_counter);
  218. mysqli_get_client_stats_assert_eq('unbuffered_sets', $info, $expected, $test_counter);
  219. mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
  220. print "Testing unbuffered normal... - SELECT id, label FROM test, not all fetched\n";
  221. if (!$res = mysqli_query($link, 'SELECT id, label FROM test', MYSQLI_USE_RESULT))
  222. printf("[%03d] SELECT id, label FROM test failed, [%d] %s\n",
  223. ++$test_counter, mysqli_errno($link), mysqli_error($link));
  224. for ($i = 0; $i < $num_rows - 1; $i++)
  225. $row = mysqli_fetch_assoc($res);
  226. $expected['rows_fetched_from_server_normal'] = (string)($expected['rows_fetched_from_server_normal'] + $num_rows - 1);
  227. $expected['rows_fetched_from_client_normal_unbuffered'] = (string)($expected['rows_fetched_from_client_normal_unbuffered'] + $num_rows - 1);
  228. $expected['unbuffered_sets'] = (string)($expected['unbuffered_sets'] + 1);
  229. $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
  230. if (!is_array($info = mysqli_get_client_stats()) || empty($info))
  231. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  232. ++$test_counter, gettype($info), $info);
  233. mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter);
  234. $expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal'];
  235. mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
  236. mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_unbuffered', $info, $expected, $test_counter);
  237. mysqli_get_client_stats_assert_eq('unbuffered_sets', $info, $expected, $test_counter);
  238. mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
  239. print "Testing if implicit fetching and cleaning happens...\n";
  240. mysqli_free_result($res);
  241. /* last row has been implicitly cleaned from the wire by freeing the result set */
  242. $expected['rows_fetched_from_server_normal'] = (string)($expected['rows_fetched_from_server_normal'] + 1);
  243. $expected['rows_fetched_from_client_normal_unbuffered'] = (string)($expected['rows_fetched_from_client_normal_unbuffered'] + 1);
  244. $expected['rows_skipped_normal'] = (string)($info['rows_skipped_normal'] + 1);
  245. $expected['flushed_normal_sets'] = (string)($expected['flushed_normal_sets'] + 1);
  246. if (!is_array($info = mysqli_get_client_stats()) || empty($info))
  247. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  248. ++$test_counter, gettype($info), $info);
  249. mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
  250. mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
  251. mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_unbuffered', $info, $expected, $test_counter);
  252. mysqli_get_client_stats_assert_eq('rows_skipped_normal', $info, $expected, $test_counter);
  253. mysqli_get_client_stats_assert_eq('flushed_normal_sets', $info, $expected, $test_counter);
  254. print "Testing buffered Prepared Statements...\n";
  255. if (!$stmt = mysqli_stmt_init($link))
  256. printf("[%03d] stmt_init() failed, [%d] %s\n",
  257. ++$test_counter, mysqli_errno($link), mysqli_error($link));
  258. if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') ||
  259. !mysqli_stmt_execute($stmt))
  260. printf("[%03d] prepare/execute failed, [%d] %s\n",
  261. ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
  262. /* by default PS is unbuffered - no change */
  263. mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
  264. mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_buffered', $info, $expected, $test_counter);
  265. if (!mysqli_stmt_store_result($stmt))
  266. printf("[%03d] store_result failed, [%d] %s\n",
  267. ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
  268. mysqli_stmt_free_result($stmt);
  269. mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, "0", $test_counter);
  270. mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
  271. $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows);
  272. $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
  273. $expected['ps_buffered_sets'] = (string)($expected['ps_buffered_sets'] + 1);
  274. $expected['rows_buffered_from_client_ps'] = (string)($expected['rows_buffered_from_client_ps'] + $num_rows);
  275. if (!is_array($info = mysqli_get_client_stats()) || empty($info))
  276. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  277. ++$test_counter, gettype($info), $info);
  278. mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
  279. mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_buffered', $info, $expected, $test_counter);
  280. mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
  281. mysqli_get_client_stats_assert_eq('ps_buffered_sets', $info, $expected, $test_counter);
  282. mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter);
  283. mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, "0", $test_counter);
  284. print "Testing buffered Prepared Statements... - fetching all\n";
  285. if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') ||
  286. !mysqli_stmt_execute($stmt))
  287. printf("[%03d] prepare/execute failed, [%d] %s\n",
  288. ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
  289. $id = $label = null;
  290. if (!mysqli_stmt_bind_result($stmt, $id, $label))
  291. printf("[%03d] bind_result failed, [%d] %s\n",
  292. ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
  293. if (!mysqli_stmt_store_result($stmt))
  294. printf("[%03d] store_result failed, [%d] %s\n",
  295. ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
  296. while (mysqli_stmt_fetch($stmt))
  297. ;
  298. $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows);
  299. $expected['rows_fetched_from_client_ps_buffered'] = (string)($expected['rows_fetched_from_client_ps_buffered'] + $num_rows);
  300. $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
  301. $expected['ps_buffered_sets'] = (string)($expected['ps_buffered_sets'] + 1);
  302. $expected['rows_buffered_from_client_ps'] = (string)($expected['rows_buffered_from_client_ps'] + $num_rows);
  303. if (!is_array($info = mysqli_get_client_stats()) || empty($info))
  304. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  305. ++$test_counter, gettype($info), $info);
  306. mysqli_get_client_stats_assert_gt('bytes_received_real_data_ps', $info, $expected, $test_counter);
  307. $expected['bytes_received_real_data_ps'] = $info['bytes_received_real_data_ps'];
  308. mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
  309. mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_buffered', $info, $expected, $test_counter);
  310. mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
  311. mysqli_get_client_stats_assert_eq('ps_buffered_sets', $info, $expected, $test_counter);
  312. mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter);
  313. mysqli_stmt_free_result($stmt);
  314. print "Testing buffered Prepared Statements... - fetching all but one\n";
  315. if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') ||
  316. !mysqli_stmt_execute($stmt))
  317. printf("[%03d] prepare/execute failed, [%d] %s\n",
  318. ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
  319. $id = $label = null;
  320. if (!mysqli_stmt_bind_result($stmt, $id, $label))
  321. printf("[%03d] bind_result failed, [%d] %s\n",
  322. ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
  323. if (!mysqli_stmt_store_result($stmt))
  324. printf("[%03d] store_result failed, [%d] %s\n",
  325. ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
  326. for ($i = 0; $i < $num_rows - 1; $i++)
  327. mysqli_stmt_fetch($stmt);
  328. $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows);
  329. $expected['rows_fetched_from_client_ps_buffered'] = (string)($expected['rows_fetched_from_client_ps_buffered'] + $num_rows - 1);
  330. $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
  331. $expected['ps_buffered_sets'] = (string)($expected['ps_buffered_sets'] + 1);
  332. $expected['rows_buffered_from_client_ps'] = (string)($expected['rows_buffered_from_client_ps'] + $num_rows);
  333. if (!is_array($info = mysqli_get_client_stats()) || empty($info))
  334. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  335. ++$test_counter, gettype($info), $info);
  336. mysqli_get_client_stats_assert_gt('bytes_received_real_data_ps', $info, $expected, $test_counter);
  337. $expected['bytes_received_real_data_ps'] = $info['bytes_received_real_data_ps'];
  338. mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
  339. mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_buffered', $info, $expected, $test_counter);
  340. mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
  341. mysqli_get_client_stats_assert_eq('ps_buffered_sets', $info, $expected, $test_counter);
  342. mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter);
  343. $expected['rows_skipped_ps'] = $info['rows_skipped_ps'];
  344. mysqli_stmt_free_result($stmt);
  345. if (!is_array($info = mysqli_get_client_stats()) || empty($info))
  346. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  347. ++$test_counter, gettype($info), $info);
  348. /* buffered result set - no skipping possible! */
  349. mysqli_get_client_stats_assert_eq('rows_skipped_ps', $info, $expected, $test_counter);
  350. print "Testing unbuffered Prepared Statements... - fetching all\n";
  351. if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') ||
  352. !mysqli_stmt_execute($stmt))
  353. printf("[%03d] prepare/execute failed, [%d] %s\n",
  354. ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
  355. $id = $label = null;
  356. if (!mysqli_stmt_bind_result($stmt, $id, $label))
  357. printf("[%03d] bind_result failed, [%d] %s\n",
  358. ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
  359. $i = 0;
  360. while (mysqli_stmt_fetch($stmt))
  361. $i++;
  362. assert($num_rows = $i);
  363. $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows);
  364. $expected['rows_fetched_from_client_ps_unbuffered'] = (string)($expected['rows_fetched_from_client_ps_unbuffered'] + $num_rows);
  365. $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
  366. $expected['ps_unbuffered_sets'] = (string)($expected['ps_unbuffered_sets'] + 1);
  367. if (!is_array($info = mysqli_get_client_stats()) || empty($info))
  368. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  369. ++$test_counter, gettype($info), $info);
  370. mysqli_get_client_stats_assert_gt('bytes_received_real_data_ps', $info, $expected, $test_counter);
  371. $expected['bytes_received_real_data_ps'] = $info['bytes_received_real_data_ps'];
  372. mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
  373. mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_unbuffered', $info, $expected, $test_counter);
  374. mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
  375. mysqli_get_client_stats_assert_eq('ps_unbuffered_sets', $info, $expected, $test_counter);
  376. mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter);
  377. mysqli_stmt_free_result($stmt);
  378. print "Testing unbuffered Prepared Statements... - fetching all but one\n";
  379. if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') ||
  380. !mysqli_stmt_execute($stmt))
  381. printf("[%03d] prepare/execute failed, [%d] %s\n",
  382. ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
  383. $id = $label = null;
  384. if (!mysqli_stmt_bind_result($stmt, $id, $label))
  385. printf("[%03d] bind_result failed, [%d] %s\n",
  386. ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
  387. for ($i = 0; $i < $num_rows - 1; $i++)
  388. mysqli_stmt_fetch($stmt);
  389. $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows - 1);
  390. $expected['rows_fetched_from_client_ps_unbuffered'] = (string)($expected['rows_fetched_from_client_ps_unbuffered'] + $num_rows - 1);
  391. $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
  392. $expected['ps_unbuffered_sets'] = (string)($expected['ps_unbuffered_sets'] + 1);
  393. if (!is_array($info = mysqli_get_client_stats()) || empty($info))
  394. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  395. ++$test_counter, gettype($info), $info);
  396. mysqli_get_client_stats_assert_gt('bytes_received_real_data_ps', $info, $expected, $test_counter);
  397. $expected['bytes_received_real_data_ps'] = $info['bytes_received_real_data_ps'];
  398. mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
  399. mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_unbuffered', $info, $expected, $test_counter);
  400. mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
  401. mysqli_get_client_stats_assert_eq('ps_unbuffered_sets', $info, $expected, $test_counter);
  402. mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter);
  403. mysqli_stmt_free_result($stmt);
  404. $expected['rows_skipped_ps'] = (string)($expected['rows_skipped_ps'] + 1);
  405. $expected['flushed_ps_sets'] = (string)($expected['flushed_ps_sets'] + 1);
  406. $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + 1);
  407. if (!is_array($info = mysqli_get_client_stats()) || empty($info))
  408. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  409. ++$test_counter, gettype($info), $info);
  410. mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter);
  411. mysqli_get_client_stats_assert_eq('rows_skipped_ps', $info, $expected, $test_counter);
  412. mysqli_get_client_stats_assert_eq('flushed_ps_sets', $info, $expected, $test_counter);
  413. mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
  414. /*
  415. print "Checking for normal buffered side effects...\n";
  416. foreach ($info as $k => $v)
  417. if ($info[$k] != $expected[$k])
  418. printf("$k - $v != %s\n", $expected[$k]);
  419. */
  420. print "... done with fetch statistics\n";
  421. if (!is_array($info = mysqli_get_client_stats()) || empty($info))
  422. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  423. ++$test_counter, gettype($info), $info);
  424. mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
  425. mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter);
  426. //
  427. // result_set_queries statistics
  428. //
  429. if (!is_array($info = mysqli_get_client_stats()) || empty($info))
  430. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  431. ++$test_counter, gettype($info), $info);
  432. if (!$res = mysqli_query($link, "SELECT id, label FROM test"))
  433. printf("[%03d] SELECT failed, [%d] %s\n", ++$test_counter,
  434. mysqli_errno($link), mysqli_error($link));
  435. $rows = 0;
  436. while ($row = mysqli_fetch_assoc($res))
  437. $rows++;
  438. if (0 == $rows)
  439. printf("[%03d] Expecting at least one result, [%d] %s\n", ++$test_counter,
  440. mysqli_errno($link), mysqli_error($link));
  441. mysqli_free_result($res);
  442. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  443. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  444. ++$test_counter, gettype($new_info), $new_info);
  445. mysqli_get_client_stats_assert_eq('result_set_queries', $new_info, (string)($info['result_set_queries'] + 1), $test_counter);
  446. $info = $new_info;
  447. mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter);
  448. $expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal'];
  449. //
  450. // non_result_set_queries - DDL
  451. //
  452. // CREATE TABLE, DROP TABLE
  453. if (!mysqli_query($link, "DROP TABLE IF EXISTS non_result_set_queries_test"))
  454. printf("[%03d] DROP TABLE failed, [%d] %s\n", ++$test_counter,
  455. mysqli_errno($link), mysqli_error($link));
  456. if (!mysqli_query($link, "CREATE TABLE non_result_set_queries_test(id INT) ENGINE = " . $engine)) {
  457. printf("[%03d] CREATE TABLE failed, [%d] %s\n", ++$test_counter,
  458. mysqli_errno($link), mysqli_error($link));
  459. } else {
  460. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  461. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  462. ++$test_counter, gettype($new_info), $new_info);
  463. mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 2), $test_counter, 'CREATE/DROP TABLE');
  464. }
  465. $info = $new_info;
  466. // ALERT TABLE
  467. if (!mysqli_query($link, "ALTER TABLE non_result_set_queries_test ADD label CHAR(1)")) {
  468. printf("[%03d] ALTER TABLE failed, [%d] %s\n", ++$test_counter,
  469. mysqli_errno($link), mysqli_error($link));
  470. } else {
  471. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  472. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  473. ++$test_counter, gettype($new_info), $new_info);
  474. mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'ALTER TABLE');
  475. }
  476. $info = $new_info;
  477. // CREATE INDEX, DROP INDEX
  478. if (!mysqli_query($link, "CREATE INDEX idx_1 ON non_result_set_queries_test(id)")) {
  479. printf("[%03d] CREATE INDEX failed, [%d] %s\n", ++$test_counter,
  480. mysqli_errno($link), mysqli_error($link));
  481. } else {
  482. if (!mysqli_query($link, "DROP INDEX idx_1 ON non_result_set_queries_test"))
  483. printf("[%03d] DROP INDEX failed, [%d] %s\n", ++$test_counter,
  484. mysqli_errno($link), mysqli_error($link));
  485. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  486. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  487. ++$test_counter, gettype($new_info), $new_info);
  488. mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 2), $test_counter, 'DROP INDEX');
  489. }
  490. $info = $new_info;
  491. // RENAME TABLE
  492. if (!mysqli_query($link, "DROP TABLE IF EXISTS client_stats_test"))
  493. printf("[%03d] Cleanup, DROP TABLE client_stats_test failed, [%d] %s\n", ++$test_counter,
  494. mysqli_errno($link), mysqli_error($link));
  495. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  496. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  497. ++$test_counter, gettype($new_info), $new_info);
  498. $info = $new_info;
  499. if (!mysqli_query($link, "RENAME TABLE non_result_set_queries_test TO client_stats_test")) {
  500. printf("[%03d] RENAME TABLE failed, [%d] %s\n", ++$test_counter,
  501. mysqli_errno($link), mysqli_error($link));
  502. } else {
  503. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  504. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  505. ++$test_counter, gettype($new_info), $new_info);
  506. mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'RENAME TABLE');
  507. }
  508. $info = $new_info;
  509. if (!mysqli_query($link, "DROP TABLE IF EXISTS non_result_set_queries_test"))
  510. printf("[%03d] Cleanup, DROP TABLE failed, [%d] %s\n", ++$test_counter,
  511. mysqli_errno($link), mysqli_error($link));
  512. if (!mysqli_query($link, "DROP TABLE IF EXISTS client_stats_test"))
  513. printf("[%03d] Cleanup, DROP TABLE failed, [%d] %s\n", ++$test_counter,
  514. mysqli_errno($link), mysqli_error($link));
  515. // Let's see if we have privileges for CREATE DATABASE
  516. mysqli_query($link, "DROP DATABASE IF EXISTS mysqli_get_client_stats");
  517. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  518. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  519. ++$test_counter, gettype($new_info), $new_info);
  520. $info = $new_info;
  521. // CREATE, ALTER, RENAME, DROP DATABASE
  522. if (mysqli_query($link, "CREATE DATABASE mysqli_get_client_stats")) {
  523. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  524. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  525. ++$test_counter, gettype($new_info), $new_info);
  526. mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'CREATE DATABASE');
  527. $info = $new_info;
  528. if (!mysqli_query($link, "ALTER DATABASE DEFAULT CHARACTER SET latin1"))
  529. printf("[%03d] ALTER DATABASE failed, [%d] %s\n", ++$test_counter,
  530. mysqli_errno($link), mysqli_error($link));
  531. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  532. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  533. ++$test_counter, gettype($new_info), $new_info);
  534. mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'CREATE DATABASE');
  535. $info = $new_info;
  536. if (mysqli_get_server_version($link) > 51700) {
  537. if (!mysqli_query($link, "RENAME DATABASE mysqli_get_client_stats TO mysqli_get_client_stats_"))
  538. printf("[%03d] RENAME DATABASE failed, [%d] %s\n", ++$test_counter,
  539. mysqli_errno($link), mysqli_error($link));
  540. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  541. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  542. ++$test_counter, gettype($new_info), $new_info);
  543. mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'CREATE DATABASE');
  544. $info = $new_info;
  545. } else {
  546. if (!mysqli_query($link, "CREATE DATABASE mysqli_get_client_stats_"))
  547. printf("[%03d] CREATE DATABASE failed, [%d] %s\n", ++$test_counter,
  548. mysqli_errno($link), mysqli_error($link));
  549. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  550. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  551. ++$test_counter, gettype($new_info), $new_info);
  552. $info = $new_info;
  553. }
  554. if (!mysqli_query($link, "DROP DATABASE mysqli_get_client_stats_"))
  555. printf("[%03d] DROP DATABASE failed, [%d] %s\n", ++$test_counter,
  556. mysqli_errno($link), mysqli_error($link));
  557. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  558. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  559. ++$test_counter, gettype($new_info), $new_info);
  560. mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'DROP DATABASE');
  561. $info = $new_info;
  562. }
  563. // CREATE SERVER, ALTER SERVER, DROP SERVER
  564. // We don't really try to use federated, we just want to see if the syntax works
  565. mysqli_query($link, "DROP SERVER IF EXISTS myself");
  566. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  567. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  568. ++$test_counter, gettype($new_info), $new_info);
  569. $info = $new_info;
  570. $sql = sprintf("CREATE SERVER myself FOREIGN DATA WRAPPER mysql OPTIONS (user '%s', password '%s', database '%s')",
  571. $user, $passwd, $db);
  572. if (mysqli_query($link, $sql)) {
  573. // server knows about it
  574. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  575. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  576. ++$test_counter, gettype($new_info), $new_info);
  577. mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'CREATE SERVER');
  578. $info = $new_info;
  579. if (!mysqli_query($link, sprintf("ALTER SERVER myself OPTIONS(user '%s_')", $user)))
  580. printf("[%03d] ALTER SERVER failed, [%d] %s\n", ++$test_counter,
  581. mysqli_errno($link), mysqli_error($link));
  582. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  583. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  584. ++$test_counter, gettype($new_info), $new_info);
  585. mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'ALTER SERVER');
  586. $info = $new_info;
  587. if (!mysqli_query($link, "DROP SERVER myself"))
  588. printf("[%03d] DROP SERVER failed, [%d] %s\n", ++$test_counter,
  589. mysqli_errno($link), mysqli_error($link));
  590. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  591. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  592. ++$test_counter, gettype($new_info), $new_info);
  593. mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'DROP SERVER');
  594. $info = $new_info;
  595. }
  596. mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
  597. mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter);
  598. /*
  599. We don't test the NDB ones.
  600. 13.1. Data Definition Statements
  601. 13.1.3. ALTER LOGFILE GROUP Syntax
  602. 13.1.4. ALTER TABLESPACE Syntax
  603. 13.1.9. CREATE LOGFILE GROUP Syntax
  604. 13.1.10. CREATE TABLESPACE Syntax
  605. 13.1.15. DROP LOGFILE GROUP Syntax
  606. 13.1.16. DROP TABLESPACE Syntax
  607. */
  608. //
  609. // DML
  610. //
  611. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  612. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  613. ++$test_counter, gettype($new_info), $new_info);
  614. $info = $new_info;
  615. if (!mysqli_query($link, "INSERT INTO test(id) VALUES (100)"))
  616. printf("[%03d] INSERT failed, [%d] %s\n", ++$test_counter,
  617. mysqli_errno($link), mysqli_error($link));
  618. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  619. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  620. ++$test_counter, gettype($new_info), $new_info);
  621. mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'INSERT');
  622. $info = $new_info;
  623. if (!mysqli_query($link, "UPDATE test SET label ='z' WHERE id = 100"))
  624. printf("[%03d] UPDATE failed, [%d] %s\n", ++$test_counter,
  625. mysqli_errno($link), mysqli_error($link));
  626. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  627. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  628. ++$test_counter, gettype($new_info), $new_info);
  629. mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'UPDATE');
  630. $info = $new_info;
  631. if (!mysqli_query($link, "REPLACE INTO test(id, label) VALUES (100, 'b')"))
  632. printf("[%03d] INSERT failed, [%d] %s\n", ++$test_counter,
  633. mysqli_errno($link), mysqli_error($link));
  634. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  635. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  636. ++$test_counter, gettype($new_info), $new_info);
  637. mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'REPLACE');
  638. $info = $new_info;
  639. // NOTE: this will NOT update dbl_ddls counter
  640. if (!$res = mysqli_query($link, "SELECT id, label FROM test WHERE id = 100"))
  641. printf("[%03d] SELECT@dml failed, [%d] %s\n", ++$test_counter,
  642. mysqli_errno($link), mysqli_error($link));
  643. mysqli_free_result($res);
  644. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  645. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  646. ++$test_counter, gettype($new_info), $new_info);
  647. mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, $info, $test_counter, 'SELECT@dml');
  648. $info = $new_info;
  649. if (!mysqli_query($link, "DELETE FROM test WHERE id = 100"))
  650. printf("[%03d] DELETE failed, [%d] %s\n", ++$test_counter,
  651. mysqli_errno($link), mysqli_error($link));
  652. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  653. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  654. ++$test_counter, gettype($new_info), $new_info);
  655. mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'DELETE');
  656. $info = $new_info;
  657. if (!$res = mysqli_query($link, "TRUNCATE TABLE test"))
  658. printf("[%03d] TRUNCATE failed, [%d] %s\n", ++$test_counter,
  659. mysqli_errno($link), mysqli_error($link));
  660. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  661. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  662. ++$test_counter, gettype($new_info), $new_info);
  663. mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'TRUNCATE');
  664. $info = $new_info;
  665. $file = tempnam(sys_get_temp_dir(), 'mysqli_test');
  666. if ($fp = fopen($file, 'w')) {
  667. @fwrite($fp, '1;"a"');
  668. fclose($fp);
  669. chmod($file, 0644);
  670. $sql = sprintf('LOAD DATA LOCAL INFILE "%s" INTO TABLE test', mysqli_real_escape_string($link, $file));
  671. if (mysqli_query($link, $sql)) {
  672. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  673. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  674. ++$test_counter, gettype($new_info), $new_info);
  675. mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'LOAD DATA LOCAL');
  676. $info = $new_info;
  677. }
  678. unlink($file);
  679. }
  680. mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
  681. mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter);
  682. /*
  683. We skip those:
  684. 13.2. Data Manipulation Statements
  685. 13.2.2. DO Syntax
  686. 13.2.3. HANDLER Syntax
  687. 13.2.5. LOAD DATA INFILE Syntax
  688. */
  689. mysqli_query($link, "DELETE FROM test");
  690. if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES (1, 'a'), (2, 'b')"))
  691. printf("[%03d] Cannot insert new records, [%d] %s\n", ++$test_counter,
  692. mysqli_errno($link), mysqli_error($link));
  693. if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id"))
  694. printf("[%03d] Cannot SELECT with mysqli_real_query(), [%d] %s\n", ++$test_counter,
  695. mysqli_errno($link), mysqli_error($link));
  696. if (!is_object($res = mysqli_use_result($link)))
  697. printf("[%03d] mysqli_use_result() failed, [%d] %s\n", ++$test_counter,
  698. mysqli_errno($link), mysqli_error($link));
  699. while ($row = mysqli_fetch_assoc($res))
  700. ;
  701. mysqli_free_result($res);
  702. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  703. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  704. ++$test_counter, gettype($new_info), $new_info);
  705. mysqli_get_client_stats_assert_eq('unbuffered_sets', $new_info, (string)($info['unbuffered_sets'] + 1), $test_counter, 'mysqli_use_result()');
  706. $info = $new_info;
  707. if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id"))
  708. printf("[%03d] Cannot SELECT with mysqli_real_query() II, [%d] %s\n", ++$test_counter,
  709. mysqli_errno($link), mysqli_error($link));
  710. if (!is_object($res = mysqli_store_result($link)))
  711. printf("[%03d] mysqli_use_result() failed, [%d] %s\n", ++$test_counter,
  712. mysqli_errno($link), mysqli_error($link));
  713. while ($row = mysqli_fetch_assoc($res))
  714. ;
  715. mysqli_free_result($res);
  716. if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
  717. printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
  718. ++$test_counter, gettype($new_info), $new_info);
  719. mysqli_get_client_stats_assert_eq('buffered_sets', $new_info, (string)($info['buffered_sets'] + 1), $test_counter, 'mysqli_use_result()');
  720. $info = $new_info;
  721. mysqli_close($link);
  722. mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter);
  723. $expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal'];
  724. mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter);
  725. /*
  726. no_index_used
  727. bad_index_used
  728. flushed_normal_sets
  729. flushed_ps_sets
  730. explicit_close
  731. implicit_close
  732. disconnect_close
  733. in_middle_of_command_close
  734. explicit_free_result
  735. implicit_free_result
  736. explicit_stmt_close
  737. implicit_stmt_close
  738. */
  739. print "done!";
  740. ?>
  741. --CLEAN--
  742. <?php
  743. require_once("connect.inc");
  744. if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
  745. printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
  746. if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
  747. printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  748. if (!mysqli_query($link, "DROP TABLE IF EXISTS non_result_set_queries_test"))
  749. printf("[c003] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  750. if (!mysqli_query($link, "DROP TABLE IF EXISTS client_stats_test"))
  751. printf("[c004] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  752. if (!mysqli_query($link, "DROP DATABASE IF EXISTS mysqli_get_client_stats_"))
  753. printf("[c005] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  754. if (!mysqli_query($link, "DROP DATABASE IF EXISTS mysqli_get_client_stats"))
  755. printf("[c006] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  756. if (!mysqli_query($link, "DROP SERVER IF EXISTS myself"))
  757. printf("[c007] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  758. mysqli_close($link);
  759. ?>
  760. --EXPECTF--
  761. array(161) {
  762. [%u|b%"bytes_sent"]=>
  763. %unicode|string%(1) "0"
  764. [%u|b%"bytes_received"]=>
  765. %unicode|string%(1) "0"
  766. [%u|b%"packets_sent"]=>
  767. %unicode|string%(1) "0"
  768. [%u|b%"packets_received"]=>
  769. %unicode|string%(1) "0"
  770. [%u|b%"protocol_overhead_in"]=>
  771. %unicode|string%(1) "0"
  772. [%u|b%"protocol_overhead_out"]=>
  773. %unicode|string%(1) "0"
  774. [%u|b%"bytes_received_ok_packet"]=>
  775. %unicode|string%(1) "0"
  776. [%u|b%"bytes_received_eof_packet"]=>
  777. %unicode|string%(1) "0"
  778. [%u|b%"bytes_received_rset_header_packet"]=>
  779. %unicode|string%(1) "0"
  780. [%u|b%"bytes_received_rset_field_meta_packet"]=>
  781. %unicode|string%(1) "0"
  782. [%u|b%"bytes_received_rset_row_packet"]=>
  783. %unicode|string%(1) "0"
  784. [%u|b%"bytes_received_prepare_response_packet"]=>
  785. %unicode|string%(1) "0"
  786. [%u|b%"bytes_received_change_user_packet"]=>
  787. %unicode|string%(1) "0"
  788. [%u|b%"packets_sent_command"]=>
  789. %unicode|string%(1) "0"
  790. [%u|b%"packets_received_ok"]=>
  791. %unicode|string%(1) "0"
  792. [%u|b%"packets_received_eof"]=>
  793. %unicode|string%(1) "0"
  794. [%u|b%"packets_received_rset_header"]=>
  795. %unicode|string%(1) "0"
  796. [%u|b%"packets_received_rset_field_meta"]=>
  797. %unicode|string%(1) "0"
  798. [%u|b%"packets_received_rset_row"]=>
  799. %unicode|string%(1) "0"
  800. [%u|b%"packets_received_prepare_response"]=>
  801. %unicode|string%(1) "0"
  802. [%u|b%"packets_received_change_user"]=>
  803. %unicode|string%(1) "0"
  804. [%u|b%"result_set_queries"]=>
  805. %unicode|string%(1) "0"
  806. [%u|b%"non_result_set_queries"]=>
  807. %unicode|string%(1) "0"
  808. [%u|b%"no_index_used"]=>
  809. %unicode|string%(1) "0"
  810. [%u|b%"bad_index_used"]=>
  811. %unicode|string%(1) "0"
  812. [%u|b%"slow_queries"]=>
  813. %unicode|string%(1) "0"
  814. [%u|b%"buffered_sets"]=>
  815. %unicode|string%(1) "0"
  816. [%u|b%"unbuffered_sets"]=>
  817. %unicode|string%(1) "0"
  818. [%u|b%"ps_buffered_sets"]=>
  819. %unicode|string%(1) "0"
  820. [%u|b%"ps_unbuffered_sets"]=>
  821. %unicode|string%(1) "0"
  822. [%u|b%"flushed_normal_sets"]=>
  823. %unicode|string%(1) "0"
  824. [%u|b%"flushed_ps_sets"]=>
  825. %unicode|string%(1) "0"
  826. [%u|b%"ps_prepared_never_executed"]=>
  827. %unicode|string%(1) "0"
  828. [%u|b%"ps_prepared_once_executed"]=>
  829. %unicode|string%(1) "0"
  830. [%u|b%"rows_fetched_from_server_normal"]=>
  831. %unicode|string%(1) "0"
  832. [%u|b%"rows_fetched_from_server_ps"]=>
  833. %unicode|string%(1) "0"
  834. [%u|b%"rows_buffered_from_client_normal"]=>
  835. %unicode|string%(1) "0"
  836. [%u|b%"rows_buffered_from_client_ps"]=>
  837. %unicode|string%(1) "0"
  838. [%u|b%"rows_fetched_from_client_normal_buffered"]=>
  839. %unicode|string%(1) "0"
  840. [%u|b%"rows_fetched_from_client_normal_unbuffered"]=>
  841. %unicode|string%(1) "0"
  842. [%u|b%"rows_fetched_from_client_ps_buffered"]=>
  843. %unicode|string%(1) "0"
  844. [%u|b%"rows_fetched_from_client_ps_unbuffered"]=>
  845. %unicode|string%(1) "0"
  846. [%u|b%"rows_fetched_from_client_ps_cursor"]=>
  847. %unicode|string%(1) "0"
  848. [%u|b%"rows_affected_normal"]=>
  849. %unicode|string%(1) "0"
  850. [%u|b%"rows_affected_ps"]=>
  851. %unicode|string%(1) "0"
  852. [%u|b%"rows_skipped_normal"]=>
  853. %unicode|string%(1) "0"
  854. [%u|b%"rows_skipped_ps"]=>
  855. %unicode|string%(1) "0"
  856. [%u|b%"copy_on_write_saved"]=>
  857. %unicode|string%(1) "0"
  858. [%u|b%"copy_on_write_performed"]=>
  859. %unicode|string%(1) "0"
  860. [%u|b%"command_buffer_too_small"]=>
  861. %unicode|string%(1) "0"
  862. [%u|b%"connect_success"]=>
  863. %unicode|string%(1) "0"
  864. [%u|b%"connect_failure"]=>
  865. %unicode|string%(1) "0"
  866. [%u|b%"connection_reused"]=>
  867. %unicode|string%(1) "0"
  868. [%u|b%"reconnect"]=>
  869. %unicode|string%(1) "0"
  870. [%u|b%"pconnect_success"]=>
  871. %unicode|string%(1) "0"
  872. [%u|b%"active_connections"]=>
  873. %unicode|string%(1) "0"
  874. [%u|b%"active_persistent_connections"]=>
  875. %unicode|string%(1) "0"
  876. [%u|b%"explicit_close"]=>
  877. %unicode|string%(1) "0"
  878. [%u|b%"implicit_close"]=>
  879. %unicode|string%(1) "0"
  880. [%u|b%"disconnect_close"]=>
  881. %unicode|string%(1) "0"
  882. [%u|b%"in_middle_of_command_close"]=>
  883. %unicode|string%(1) "0"
  884. [%u|b%"explicit_free_result"]=>
  885. %unicode|string%(1) "0"
  886. [%u|b%"implicit_free_result"]=>
  887. %unicode|string%(1) "0"
  888. [%u|b%"explicit_stmt_close"]=>
  889. %unicode|string%(1) "0"
  890. [%u|b%"implicit_stmt_close"]=>
  891. %unicode|string%(1) "0"
  892. [%u|b%"mem_emalloc_count"]=>
  893. %unicode|string%(1) "0"
  894. [%u|b%"mem_emalloc_amount"]=>
  895. %unicode|string%(1) "0"
  896. [%u|b%"mem_ecalloc_count"]=>
  897. %unicode|string%(1) "0"
  898. [%u|b%"mem_ecalloc_amount"]=>
  899. %unicode|string%(1) "0"
  900. [%u|b%"mem_erealloc_count"]=>
  901. %unicode|string%(1) "0"
  902. [%u|b%"mem_erealloc_amount"]=>
  903. %unicode|string%(1) "0"
  904. [%u|b%"mem_efree_count"]=>
  905. %unicode|string%(1) "0"
  906. [%u|b%"mem_efree_amount"]=>
  907. %unicode|string%(1) "0"
  908. [%u|b%"mem_malloc_count"]=>
  909. %unicode|string%(1) "0"
  910. [%u|b%"mem_malloc_amount"]=>
  911. %unicode|string%(1) "0"
  912. [%u|b%"mem_calloc_count"]=>
  913. %unicode|string%(%d) "%d"
  914. [%u|b%"mem_calloc_amount"]=>
  915. %unicode|string%(%d) "%d"
  916. [%u|b%"mem_realloc_count"]=>
  917. %unicode|string%(1) "0"
  918. [%u|b%"mem_realloc_amount"]=>
  919. %unicode|string%(1) "0"
  920. [%u|b%"mem_free_count"]=>
  921. %unicode|string%(1) "0"
  922. [%u|b%"mem_free_amount"]=>
  923. %unicode|string%(1) "0"
  924. [%u|b%"mem_estrndup_count"]=>
  925. %unicode|string%(1) "0"
  926. [%u|b%"mem_strndup_count"]=>
  927. %unicode|string%(1) "0"
  928. [%u|b%"mem_estndup_count"]=>
  929. %unicode|string%(1) "0"
  930. [%u|b%"mem_strdup_count"]=>
  931. %unicode|string%(1) "0"
  932. [%u|b%"proto_text_fetched_null"]=>
  933. %unicode|string%(1) "0"
  934. [%u|b%"proto_text_fetched_bit"]=>
  935. %unicode|string%(1) "0"
  936. [%u|b%"proto_text_fetched_tinyint"]=>
  937. %unicode|string%(1) "0"
  938. [%u|b%"proto_text_fetched_short"]=>
  939. %unicode|string%(1) "0"
  940. [%u|b%"proto_text_fetched_int24"]=>
  941. %unicode|string%(1) "0"
  942. [%u|b%"proto_text_fetched_int"]=>
  943. %unicode|string%(1) "0"
  944. [%u|b%"proto_text_fetched_bigint"]=>
  945. %unicode|string%(1) "0"
  946. [%u|b%"proto_text_fetched_decimal"]=>
  947. %unicode|string%(1) "0"
  948. [%u|b%"proto_text_fetched_float"]=>
  949. %unicode|string%(1) "0"
  950. [%u|b%"proto_text_fetched_double"]=>
  951. %unicode|string%(1) "0"
  952. [%u|b%"proto_text_fetched_date"]=>
  953. %unicode|string%(1) "0"
  954. [%u|b%"proto_text_fetched_year"]=>
  955. %unicode|string%(1) "0"
  956. [%u|b%"proto_text_fetched_time"]=>
  957. %unicode|string%(1) "0"
  958. [%u|b%"proto_text_fetched_datetime"]=>
  959. %unicode|string%(1) "0"
  960. [%u|b%"proto_text_fetched_timestamp"]=>
  961. %unicode|string%(1) "0"
  962. [%u|b%"proto_text_fetched_string"]=>
  963. %unicode|string%(1) "0"
  964. [%u|b%"proto_text_fetched_blob"]=>
  965. %unicode|string%(1) "0"
  966. [%u|b%"proto_text_fetched_enum"]=>
  967. %unicode|string%(1) "0"
  968. [%u|b%"proto_text_fetched_set"]=>
  969. %unicode|string%(1) "0"
  970. [%u|b%"proto_text_fetched_geometry"]=>
  971. %unicode|string%(1) "0"
  972. [%u|b%"proto_text_fetched_other"]=>
  973. %unicode|string%(1) "0"
  974. [%u|b%"proto_binary_fetched_null"]=>
  975. %unicode|string%(1) "0"
  976. [%u|b%"proto_binary_fetched_bit"]=>
  977. %unicode|string%(1) "0"
  978. [%u|b%"proto_binary_fetched_tinyint"]=>
  979. %unicode|string%(1) "0"
  980. [%u|b%"proto_binary_fetched_short"]=>
  981. %unicode|string%(1) "0"
  982. [%u|b%"proto_binary_fetched_int24"]=>
  983. %unicode|string%(1) "0"
  984. [%u|b%"proto_binary_fetched_int"]=>
  985. %unicode|string%(1) "0"
  986. [%u|b%"proto_binary_fetched_bigint"]=>
  987. %unicode|string%(1) "0"
  988. [%u|b%"proto_binary_fetched_decimal"]=>
  989. %unicode|string%(1) "0"
  990. [%u|b%"proto_binary_fetched_float"]=>
  991. %unicode|string%(1) "0"
  992. [%u|b%"proto_binary_fetched_double"]=>
  993. %unicode|string%(1) "0"
  994. [%u|b%"proto_binary_fetched_date"]=>
  995. %unicode|string%(1) "0"
  996. [%u|b%"proto_binary_fetched_year"]=>
  997. %unicode|string%(1) "0"
  998. [%u|b%"proto_binary_fetched_time"]=>
  999. %unicode|string%(1) "0"
  1000. [%u|b%"proto_binary_fetched_datetime"]=>
  1001. %unicode|string%(1) "0"
  1002. [%u|b%"proto_binary_fetched_timestamp"]=>
  1003. %unicode|string%(1) "0"
  1004. [%u|b%"proto_binary_fetched_string"]=>
  1005. %unicode|string%(1) "0"
  1006. [%u|b%"proto_binary_fetched_json"]=>
  1007. %unicode|string%(1) "0"
  1008. [%u|b%"proto_binary_fetched_blob"]=>
  1009. %unicode|string%(1) "0"
  1010. [%u|b%"proto_binary_fetched_enum"]=>
  1011. %unicode|string%(1) "0"
  1012. [%u|b%"proto_binary_fetched_set"]=>
  1013. %unicode|string%(1) "0"
  1014. [%u|b%"proto_binary_fetched_geometry"]=>
  1015. %unicode|string%(1) "0"
  1016. [%u|b%"proto_binary_fetched_other"]=>
  1017. %unicode|string%(1) "0"
  1018. [%u|b%"init_command_executed_count"]=>
  1019. %unicode|string%(1) "0"
  1020. [%u|b%"init_command_failed_count"]=>
  1021. %unicode|string%(1) "0"
  1022. [%u|b%"com_quit"]=>
  1023. %unicode|string%(1) "0"
  1024. [%u|b%"com_init_db"]=>
  1025. %unicode|string%(1) "0"
  1026. [%u|b%"com_query"]=>
  1027. %unicode|string%(1) "0"
  1028. [%u|b%"com_field_list"]=>
  1029. %unicode|string%(1) "0"
  1030. [%u|b%"com_create_db"]=>
  1031. %unicode|string%(1) "0"
  1032. [%u|b%"com_drop_db"]=>
  1033. %unicode|string%(1) "0"
  1034. [%u|b%"com_refresh"]=>
  1035. %unicode|string%(1) "0"
  1036. [%u|b%"com_shutdown"]=>
  1037. %unicode|string%(1) "0"
  1038. [%u|b%"com_statistics"]=>
  1039. %unicode|string%(1) "0"
  1040. [%u|b%"com_process_info"]=>
  1041. %unicode|string%(1) "0"
  1042. [%u|b%"com_connect"]=>
  1043. %unicode|string%(1) "0"
  1044. [%u|b%"com_process_kill"]=>
  1045. %unicode|string%(1) "0"
  1046. [%u|b%"com_debug"]=>
  1047. %unicode|string%(1) "0"
  1048. [%u|b%"com_ping"]=>
  1049. %unicode|string%(1) "0"
  1050. [%u|b%"com_time"]=>
  1051. %unicode|string%(1) "0"
  1052. [%u|b%"com_delayed_insert"]=>
  1053. %unicode|string%(1) "0"
  1054. [%u|b%"com_change_user"]=>
  1055. %unicode|string%(1) "0"
  1056. [%u|b%"com_binlog_dump"]=>
  1057. %unicode|string%(1) "0"
  1058. [%u|b%"com_table_dump"]=>
  1059. %unicode|string%(1) "0"
  1060. [%u|b%"com_connect_out"]=>
  1061. %unicode|string%(1) "0"
  1062. [%u|b%"com_register_slave"]=>
  1063. %unicode|string%(1) "0"
  1064. [%u|b%"com_stmt_prepare"]=>
  1065. %unicode|string%(1) "0"
  1066. [%u|b%"com_stmt_execute"]=>
  1067. %unicode|string%(1) "0"
  1068. [%u|b%"com_stmt_send_long_data"]=>
  1069. %unicode|string%(1) "0"
  1070. [%u|b%"com_stmt_close"]=>
  1071. %unicode|string%(1) "0"
  1072. [%u|b%"com_stmt_reset"]=>
  1073. %unicode|string%(1) "0"
  1074. [%u|b%"com_stmt_set_option"]=>
  1075. %unicode|string%(1) "0"
  1076. [%u|b%"com_stmt_fetch"]=>
  1077. %unicode|string%(1) "0"
  1078. [%u|b%"com_deamon"]=>
  1079. %unicode|string%(1) "0"
  1080. [%u|b%"bytes_received_real_data_normal"]=>
  1081. %unicode|string%(1) "0"
  1082. [%u|b%"bytes_received_real_data_ps"]=>
  1083. %unicode|string%(1) "0"
  1084. }
  1085. Testing buffered normal...
  1086. Testing buffered normal... - SELECT id, label FROM test
  1087. Testing unbuffered normal...
  1088. Testing unbuffered normal... - SELECT id, label FROM test, not all fetched
  1089. Testing if implicit fetching and cleaning happens...
  1090. Testing buffered Prepared Statements...
  1091. Testing buffered Prepared Statements... - fetching all
  1092. Testing buffered Prepared Statements... - fetching all but one
  1093. Testing unbuffered Prepared Statements... - fetching all
  1094. Testing unbuffered Prepared Statements... - fetching all but one
  1095. ... done with fetch statistics
  1096. done!