1--TEST-- 2mysqli_debug() - invalid debug control strings 3--EXTENSIONS-- 4mysqli 5--SKIPIF-- 6<?php 7require_once('skipifconnectfailure.inc'); 8 9if (!function_exists('mysqli_debug')) 10 die("skip: mysqli_debug() not available"); 11 12if (!defined('MYSQLI_DEBUG_TRACE_ENABLED')) 13 die("skip: can't say for sure if mysqli_debug works"); 14 15if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED) 16 die("skip: debug functionality not enabled"); 17 18if (!$IS_MYSQLND) 19 die("SKIP Libmysql feature not sufficiently spec'd in MySQL C API documentation"); 20?> 21--FILE-- 22<?php 23 require_once('connect.inc'); 24 require_once('table.inc'); 25 26 function try_control_string($link, $control_string, $trace_file, $offset) { 27 28 if (true !== ($tmp = mysqli_debug($control_string))) { 29 printf("[%03d][control string '%s'] Expecting boolean/true, got %s/%s.\n", 30 $offset + 1, 31 $control_string, 32 gettype($tmp), 33 $tmp); 34 return false; 35 } 36 37 if (!$res = mysqli_query($link, 'SELECT * FROM test')) { 38 printf("[%03d][control string '%s'] [%d] %s.\n", 39 $offset + 2, 40 $control_string, 41 mysqli_errno($link), 42 mysqli_error($link)); 43 return false; 44 } 45 46 clearstatcache(); 47 if (!file_exists($trace_file)) { 48 printf("[%03d][control string '%s'] Trace file has not been written.\n", 49 $offset + 3, 50 $control_string, 51 gettype($tmp), 52 $tmp); 53 return false; 54 } 55 56 unlink($trace_file); 57 } 58 59 $trace_file = sprintf('%s%s%s', sys_get_temp_dir(), DIRECTORY_SEPARATOR, 'mysqli_debug_phpt.trace'); 60 try_control_string($link, 't:,,:o,' . $trace_file, $trace_file, 10); 61 try_control_string($link, ':' . chr(0) . 'A,' . $trace_file, $trace_file, 20); 62 try_control_string($link, 't:o,' . $trace_file . ':abc', $trace_file, 30); 63 try_control_string($link, 't:o,' . $trace_file . ':ABC,123:b', $trace_file, 40); 64 try_control_string($link, 't:ABC,123:b;:o,' . $trace_file, $trace_file, 50); 65 try_control_string($link, 't:A;BC,123:b;:o,' . $trace_file, $trace_file, 60); 66 try_control_string($link, 't:p:o,' . $trace_file, $trace_file, 70); 67 try_control_string($link, 't:p,1,,2:o,' . $trace_file, $trace_file, 80); 68 try_control_string($link, 't:z,1,,2:o,' . $trace_file, $trace_file, 90);# 69 70 mysqli_close($link); 71 print "done"; 72 if ($IS_MYSQLND) 73 print "libmysql/DBUG package prints some debug info here." 74?> 75--EXPECTF-- 76Warning: mysqli_debug(): Unrecognized format ',' in %s on line %d 77 78Warning: mysqli_debug(): Consecutive semicolons at position 0 in %s on line %d 79[023][control string '%s'] Trace file has not been written. 80 81Warning: mysqli_debug(): Colon expected, 'b' found in %s on line %d 82 83Warning: mysqli_debug(): Colon expected, 'c' found in %s on line %d 84 85Warning: mysqli_debug(): Colon expected, 'B' found in %s on line %d 86 87Warning: mysqli_debug(): Colon expected, 'C' found in %s on line %d 88 89Warning: mysqli_debug(): Colon expected, ',' found in %s on line %d 90 91Warning: mysqli_debug(): Colon expected, '1' found in %s on line %d 92 93Warning: mysqli_debug(): Colon expected, '2' found in %s on line %d 94 95Warning: mysqli_debug(): Colon expected, '3' found in %s on line %d 96 97Warning: mysqli_debug(): Unrecognized format 'b' in %s on line %d 98 99Warning: mysqli_debug(): Colon expected, 'B' found in %s on line %d 100 101Warning: mysqli_debug(): Colon expected, 'C' found in %s on line %d 102 103Warning: mysqli_debug(): Colon expected, ',' found in %s on line %d 104 105Warning: mysqli_debug(): Colon expected, '1' found in %s on line %d 106 107Warning: mysqli_debug(): Colon expected, '2' found in %s on line %d 108 109Warning: mysqli_debug(): Colon expected, '3' found in %s on line %d 110 111Warning: mysqli_debug(): Unrecognized format 'b' in %s on line %d 112 113Warning: mysqli_debug(): Colon expected, ';' found in %s on line %d 114 115Warning: mysqli_debug(): Colon expected, ';' found in %s on line %d 116 117Warning: mysqli_debug(): Colon expected, 'B' found in %s on line %d 118 119Warning: mysqli_debug(): Colon expected, 'C' found in %s on line %d 120 121Warning: mysqli_debug(): Colon expected, ',' found in %s on line %d 122 123Warning: mysqli_debug(): Colon expected, '1' found in %s on line %d 124 125Warning: mysqli_debug(): Colon expected, '2' found in %s on line %d 126 127Warning: mysqli_debug(): Colon expected, '3' found in %s on line %d 128 129Warning: mysqli_debug(): Unrecognized format 'b' in %s on line %d 130 131Warning: mysqli_debug(): Colon expected, ';' found in %s on line %d 132 133Warning: mysqli_debug(): Unrecognized format 'z' in %s on line %d 134done%s 135