1# ==== Purpose ====
2#
3# Auxiliary file used in include/show_binlog_events.inc and
4# include/show_relaylog_events.inc.
5#
6# ==== Usage ====
7#
8# See include/show_binlog_events.inc
9
10--let $include_filename= show_events.inc
11--source include/begin_include_file.inc
12
13--let $_se_old_statement= $statement
14
15--let $statement=show BINLOG events
16if ($is_relay_log)
17{
18  if ($master_name)
19  {
20    let _master_name='$master_name';
21  }
22  if (!$master_name)
23  {
24    let _master_name=`select @@default_master_connection`;
25    if ($_master_name)
26    {
27      let _master_name='$_master_name';
28    }
29  }
30  --let $statement=show relaylog $_master_name events
31}
32
33if ($binlog_file)
34{
35  --let $_binlog_file= $binlog_file
36  if ($binlog_file == 'LAST')
37  {
38    if ($is_relay_log)
39    {
40      --let $_binlog_file= query_get_value(SHOW SLAVE $_master_name STATUS, Relay_Log_File, 1)
41    }
42    if (!$is_relay_log)
43    {
44      --let $_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
45    }
46  }
47  --let $statement= $statement in '$_binlog_file'
48}
49
50# Do not modify $binlog_start - if we did, it could wrongly persist until a
51# later call of show_events.inc.
52if ($binlog_start)
53{
54  --let $_binlog_start= $binlog_start
55}
56
57if (!$binlog_start)
58{
59  # If $binlog_start is not set, we will set it as the fourth event's
60  # position (second in relay log which has not Binlog Checkpoint nor
61  # Gtid_list events).
62  # The first three events (Description Event, Gtid list, and Binlog Checkpoint
63  # event) are always ignored. For description event's length might be changed
64  # because of adding new events, 'SHOW BINLOG EVENTS LIMIT 3' is used to get
65  # the right value.
66  if ($is_relay_log)
67  {
68    --let $_binlog_start= query_get_value($statement LIMIT 1, End_log_pos, 1)
69  }
70  if (!$is_relay_log)
71  {
72    --let $_binlog_start= query_get_value($statement LIMIT 3, End_log_pos, 3)
73  }
74}
75
76--let $statement= $statement from $_binlog_start
77
78if ($binlog_limit != '')
79{
80  --let $statement= $statement limit $binlog_limit
81}
82
83# Execute the statement and write to $output_file
84--let $output_file= GENERATE
85--source include/write_result_to_file.inc
86
87# Filter the file through the following script.
88--delimiter ||
89let $script=
90  # todo: use select_columns instead (requires updating all result files)
91  s{([^\t]*\t)[^\t]*(\t[^\t]*\t)[^\t]*\t[^\t]*(\t[^\t]*)}{DOLLAR1#DOLLAR2#\t#DOLLAR3};
92  s{/\* xid=.* \*/}{/\* XID \*/};
93  s{table_id: [0-9]+}{table_id: #};
94  s{file_id=[0-9]+}{file_id=#};
95  s{block_len=[0-9]+}{block_len=#};
96  s{Server ver:.*DOLLAR}{SERVER_VERSION, BINLOG_VERSION};
97  s{GTID [0-9]+-[0-9]+-[0-9]+}{GTID #-#-#};
98  s{\[([0-9]-[0-9]-[0-9]+,?)+\]}{[#-#-#]};
99  s{cid=[0-9]+}{cid=#};
100  s{SQL_LOAD-[a-z,0-9,-]*.[a-z]*}{SQL_LOAD-<SERVER UUID>-<MASTER server-id>-<file-id>.<extension>};
101  s{rand_seed1=[0-9]*,rand_seed2=[0-9]*}{rand_seed1=<seed 1>,rand_seed2=<seed 2>};
102  s{((?:master|slave|slave-relay)-bin\.[0-9]{6};pos=)[0-9]+DOLLAR}{DOLLAR1POS};
103  s{SONAME ".*"}{SONAME "LIB"};
104  s{DOLLARmysqltest_vardir}{MYSQLTEST_VARDIR}g;
105||
106--let $pre_script= my DOLLARmysqltest_vardir = DOLLARENV{'MYSQLTEST_VARDIR'};
107
108--delimiter ;
109
110if ($skip_checkpoint_events)
111{
112  let $filter_script=Binlog_checkpoint;
113}
114
115
116#--let $select_columns= 1 3 6
117--let $input_file= $output_file
118--source include/filter_file.inc
119
120# Write to result file
121--cat_file $output_file
122
123# Remove the file
124--remove_file $output_file
125
126--let $statement= $_se_old_statement
127
128--let $include_filename= show_events.inc
129--source include/end_include_file.inc
130