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