1### t/log_tables_debug.test 2# 3# Log-related tests requiring a debug-build server. 4# 5 6# extra clean-up required due to Bug#38124, set to 1 when behavior has 7# changed (see explanation in log_state.test) 8let $fixed_bug38124 = 0; 9 10--source include/not_embedded.inc 11--source include/have_debug.inc 12 13# Several subtests modify global variables. Save the initial values only here, 14# but reset to the initial values per subtest. 15SET @old_general_log= @@global.general_log; 16SET @old_general_log_file= @@global.general_log_file; 17SET @old_slow_query_log= @@global.slow_query_log; 18SET @old_slow_query_log_file= @@global.slow_query_log_file; 19 20 21--echo # 22--echo # Bug#45387 Information about statement id for prepared 23--echo # statements missed from general log 24--echo # 25 26let MYSQLD_DATADIR= `SELECT @@datadir`; 27 28# set logging to our specific bug log to control the entries added 29SET @@global.general_log = ON; 30SET @@global.general_log_file = 'bug45387_general.log'; 31 32# turn on output of timestamps on all log file entries 33SET SESSION debug='+d,reset_log_last_time'; 34 35let CONN_ID= `SELECT CONNECTION_ID()`; 36FLUSH LOGS; 37 38# reset log settings 39SET @@global.general_log = @old_general_log; 40SET @@global.general_log_file = @old_general_log_file; 41SET SESSION debug='-d'; 42 43perl; 44 # get the relevant info from the surrounding perl invocation 45 $datadir= $ENV{'MYSQLD_DATADIR'}; 46 $conn_id= $ENV{'CONN_ID'}; 47 48 # loop through the log file looking for the stmt querying for conn id 49 open(FILE, "$datadir/bug45387_general.log") or 50 die("Unable to read log file $datadir/bug45387_general.log: $!\n"); 51 while(<FILE>) { 52 if (/\d{6}\s+\d+:\d+:\d+[ \t]+(\d+)[ \t]+Query[ \t]+SELECT CONNECTION_ID/) { 53 $found= $1; 54 break; 55 } 56 } 57 58 # print the result 59 if ($found == $conn_id) { 60 print "Bug#45387: ID match.\n"; 61 } else { 62 print "Bug#45387: Expected ID '$conn_id', found '$found' in log file.\n"; 63 print "Contents of log file:\n"; 64 seek(FILE, 0, 0); 65 while($line= <FILE>) { 66 print $line; 67 } 68 } 69 70 close(FILE); 71EOF 72 73--remove_file $MYSQLD_DATADIR/bug45387_general.log 74 75--echo End of 5.1 tests 76 77 78--echo # 79--echo # Cleanup 80--echo # 81 82# Reset global system variables to initial values if forgotten somewhere above. 83SET global general_log = @old_general_log; 84SET global general_log_file = @old_general_log_file; 85SET global slow_query_log = @old_slow_query_log; 86SET global slow_query_log_file = @old_slow_query_log_file; 87if(!$fixed_bug38124) 88{ 89 --disable_query_log 90 let $my_var = `SELECT @old_general_log_file`; 91 eval SET @@global.general_log_file = '$my_var'; 92 let $my_var = `SELECT @old_slow_query_log_file`; 93 eval SET @@global.slow_query_log_file = '$my_var'; 94 --enable_query_log 95} 96