~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/t/log_tables_debug.test

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

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