summaryrefslogtreecommitdiff
path: root/mysql-test/include/show_events.inc
blob: 2de24951846247e6bbf9f35fc201a183e9d316d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# ==== Purpose ====
#
# Auxiliary file used in include/show_binlog_events.inc and
# include/show_relaylog_events.inc.
#
# ==== Usage ====
#
# See include/show_binlog_events.inc

--let $include_filename= show_events.inc
--source include/begin_include_file.inc

# Do not modify $binlog_start - if we did, it could wrongly persist until a
# later call of show_events.inc.
if ($binlog_start)
{
  --let $_binlog_start= $binlog_start
}
if (!$binlog_start)
{
  # If $binlog_start is not set, we will set it as the third event's
  # position (second in relay log which has not Binlog Checkpoing event).
  # The first two events (Description Event and Binlog Checkpoint
  # event) are always ignored. For description event's length might be changed
  # because of adding new events, 'SHOW BINLOG EVENTS LIMIT 2' is used to get
  # the right value.
  if ($is_relay_log)
  {
    --let $_binlog_start= query_get_value(SHOW BINLOG EVENTS LIMIT 1, End_log_pos, 1)
  }
  if (!$is_relay_log)
  {
    --let $_binlog_start= query_get_value(SHOW BINLOG EVENTS LIMIT 2, End_log_pos, 2)
  }
}

--let $_se_old_statement= $statement

--let $statement=show BINLOG events
if ($is_relay_log)
{
  --let $statement=show relaylog events
}

if ($binlog_file)
{
  --let $_binlog_file= $binlog_file
  if ($binlog_file == 'LAST')
  {
    if ($is_relay_log)
    {
      --let $_binlog_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1)
    }
    if (!$is_relay_log)
    {
      --let $_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
    }
  }
  --let $statement= $statement in '$_binlog_file'
}

--let $statement= $statement from $_binlog_start

if ($binlog_limit != '')
{
  --let $statement= $statement limit $binlog_limit
}

# Execute the statement and write to $output_file
--let $output_file= GENERATE
--source include/write_result_to_file.inc

# Filter the file through the following script.
--delimiter ||
let $script=
  # todo: use select_columns instead (requires updating all result files)
  s{([^\t]*\t)[^\t]*(\t[^\t]*\t)[^\t]*\t[^\t]*(\t[^\t]*)}{DOLLAR1#DOLLAR2#\t#DOLLAR3};
  s{/\* xid=.* \*/}{/\* XID \*/};
  s{table_id: [0-9]+}{table_id: #};
  s{file_id=[0-9]+}{file_id=#};
  s{block_len=[0-9]+}{block_len=#};
  s{Server ver:.*DOLLAR}{SERVER_VERSION, BINLOG_VERSION};
  s{SQL_LOAD-[a-z,0-9,-]*.[a-z]*}{SQL_LOAD-<SERVER UUID>-<MASTER server-id>-<file-id>.<extension>};
  s{rand_seed1=[0-9]*,rand_seed2=[0-9]*}{rand_seed1=<seed 1>,rand_seed2=<seed 2>};
  s{((?:master|slave|slave-relay)-bin\.[0-9]{6};pos=)[0-9]+DOLLAR}{DOLLAR1POS};
  s{DOLLARmysqltest_vardir}{MYSQLTEST_VARDIR}g;
||
--let $pre_script= my DOLLARmysqltest_vardir = DOLLARENV{'MYSQLTEST_VARDIR'};
if (!$keep_gtid_events)
{
  --let $script= $script DOLLAR_ = '' if (m{\t(?:Gtid|Previous_gtids)\t});
}
if ($keep_gtid_events)
{
  let $pre_script= $pre_script
    my DOLLARuuid_regex = '[0-9A-F]{8}-(?:[0-9A-F]{4}-){3}[0-9A-F]{12}';
    my DOLLARuuid_sidno_regex = DOLLARuuid_regex.'(?::[0-9]+(?:-[0-9]+)?)+';
  ||
  --let $script= $script s{DOLLARuuid_sidno_regex(?:,DOLLARuuid_sidno_regex)*}{Gtid_set};
}
--delimiter ;

#--let $select_columns= 1 3 6
--let $input_file= $output_file
--source include/filter_file.inc

# Write to result file
--cat_file $output_file

# Remove the file
--remove_file $output_file

--let $statement= $_se_old_statement

--let $include_filename= show_events.inc
--source include/end_include_file.inc