File: show_events.inc

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (188 lines) | stat: -rw-r--r-- 5,230 bytes parent folder | download
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# ==== 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
if ($is_relay_log)
{
  if ($rpl_channel_name)
  {
    --let $include_filename= $include_filename [FOR CHANNEL $rpl_channel_name]
  }
}
--source include/begin_include_file.inc

--let $_se_old_statement= $statement

--let $statement= SHOW BINLOG EVENTS
--let $_se_for_channel=
if ($is_relay_log)
{
  --let $statement= SHOW RELAYLOG EVENTS
  if ($rpl_channel_name)
  {
    --let $_se_for_channel= FOR CHANNEL $rpl_channel_name
  }
}
--let $statement_masked= $statement

if ($binlog_file)
{
  --let $_binlog_file= $binlog_file
  if ($binlog_file == 'LAST')
  {
    if ($is_relay_log)
    {
      --source include/rpl_get_end_of_relay_log.inc
      --let $_binlog_file= $relay_log_file
    }
    if (!$is_relay_log)
    {
      --let $_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
    }
  }
  --let $statement= $statement IN '$_binlog_file'
  --let $statement_masked= $statement_masked IN <FILE>
}

--let $_binlog_start= $binlog_start

if (!$_binlog_start)
{
  # If $binlog_start is not set, we will set it as the second event's
  # position.  The first event(Description Event) is always ignored. For
  # description event's length might be changed because of adding new events,
  # 'SHOW BINLOG EVENTS LIMIT 1' is used to get the right value.
  --let $_binlog_start= query_get_value(SHOW BINLOG EVENTS LIMIT 1, End_log_pos, 1)
}

--let $statement= $statement FROM $_binlog_start
--let $statement_masked= $statement_masked FROM <POSITION>

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

if ($show_binlog_events_verbose)
{
  --echo ---- [$CURRENT_CONNECTION] $statement_masked ----
}

if ($rpl_debug)
{
  --echo statement='$statement'
}

--let $statement= $statement $_se_for_channel

# 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 ||
if ($show_binlog_events_mask_columns != '')
{
  --let $mask_columns = $show_binlog_events_mask_columns
}
if ($show_binlog_events_mask_columns == '')
{
  --let $mask_columns = 2,4,5
}
let $script=
  s{/\* xid=.* \*/}{/\* XID # \*/};
  s{COMMIT /\* XID # \*/}{COMMIT /\* 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{(binlog\.[0-9]{6};pos=)[0-9]+DOLLAR}{DOLLAR1POS};
  s{SONAME ".*"}{SONAME "LIB"};
  s{DOLLARmysqltest_vardir}{MYSQLTEST_VARDIR}g;
||
--let $pre_script= my DOLLARmysqltest_vardir = DOLLARENV{'MYSQLTEST_VARDIR'};

if (!$keep_transaction_payload_events)
{
  --let $script= $script DOLLAR_ = '' if (m{\t(?:Transaction_payload)\t});
}
if ($keep_transaction_payload_events)
{
  let $pre_script= $pre_script
    my DOLLARdec_size_regex = '(decompressed_size=[0-9]+ bytes)';
  ||
  --let $script= $script s{DOLLARdec_size_regex}{decompressed_size=## bytes};
}

if (!$keep_view_change_events)
{
  --let $script= $script DOLLAR_ = '' if (m{\t(?:View_change)\t});
}

if (!$keep_gtid_events)
{
  --let $script= $script DOLLAR_ = '' if (m{\t(?:Gtid|Previous_gtids|Anonymous_Gtid)\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_gno_regex = DOLLARuuid_regex.'(?::[0-9]+(?:-[0-9]+)?)+';
  ||
  --let $script= $script s{DOLLARuuid_gno_regex(?:,DOLLARuuid_gno_regex)*}{Gtid_set};
}
# To mask binlog and relaylog commit events
if ($mask_binlog_commit_events)
{
  --let $script= $script s{ \/\* XID \*\/}{};
  --let $script= $script s{Xid}{Query};
}
# To mask ANONYMOUS_GTID events as GTID events
if ($mask_anonymous_gtid_events)
{
  --let $script= $script s{Anonymous_Gtid}{Gtid};
  --let $script= $script s{ANONYMOUS}{Gtid_set};
}
# To mask random password generated with create/alter user
if ($mask_user_password_events)
{
 --let $script= $script s{'caching_sha2_password' AS '(.*)'}{'caching_sha2_password' AS '<non-deterministic-password-hash>'}g;
 --let $script= $script s{SET PASSWORD FOR .*}{SET PASSWORD FOR '<some_user>'='<non-deterministic-password-hash>'};
}
# Skip 'AS <..> WITH <..>' clause in the GRANT statement in case the
# partial revokes is ON 
if ($mask_grant_as_events)
{
 --let $script= $script s{ AS .* WITH ROLE .*}{};
}

if (!$keep_ddl_xid)
{
  --let $script= $script s{ /\* XID # \*/}{};
}
--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