| 1 |
# |
| 2 |
# This include file is used by more than one test suite |
| 3 |
# (currently binlog and binlog_encryption). |
| 4 |
# Please check all dependent tests after modifying it |
| 5 |
# |
| 6 |
# Usage: |
| 7 |
# --let use_remote_mysqlbinlog= 1 # optional |
| 8 |
# --source suite/binlog/include/binlog_row_annotate.inc |
| 9 |
# |
| 10 |
# By default, the script uses mysqlbinlog both with direct access to files |
| 11 |
# and via connection to the server. In some cases, direct access to files |
| 12 |
# might be impossible (e.g. with encryption). If use_remote_mysqlbinlog |
| 13 |
# flag is set, this part of the logic will be omitted. |
| 14 |
# |
| 15 |
|
| 16 |
############################################################################### |
| 17 |
# WL47: Store in binlog text of statements that caused RBR events |
| 18 |
# new event: ANNOTATE_ROWS_EVENT |
| 19 |
# new master option: --binlog-annotate-row-events |
| 20 |
# new mysqlbinlog option: --skip-annotate-row-events |
| 21 |
# |
| 22 |
# Intended to test that: |
| 23 |
# *** If the --binlog-annotate-row-events option is switched on on master |
| 24 |
# then Annotate_rows events: |
| 25 |
# - are generated; |
| 26 |
# - are generated only once for "multi-table-maps" rbr queries; |
| 27 |
# - are not generated when the corresponding queries are filtered away; |
| 28 |
# - are generated when the corresponding queries are filtered away partialy |
| 29 |
# (e.g. in case of multi-delete). |
| 30 |
# *** Annotate_rows events are printed by mysqlbinlog started without |
| 31 |
# --skip-annotate-row-events options both in remote and local cases. |
| 32 |
# *** Annotate_rows events are not printed by mysqlbinlog started with |
| 33 |
# --skip-annotate-row-events options both in remote and local cases. |
| 34 |
############################################################################### |
| 35 |
|
| 36 |
set @old_binlog_checksum=@@binlog_checksum; |
| 37 |
set global binlog_checksum=NONE; |
| 38 |
--let datadir= `select @@datadir` |
| 39 |
|
| 40 |
--source include/have_log_bin.inc |
| 41 |
--source include/binlog_start_pos.inc |
| 42 |
--source include/have_binlog_format_row.inc |
| 43 |
|
| 44 |
set sql_mode=""; |
| 45 |
let $collation_server=`select @@collation_server`; |
| 46 |
|
| 47 |
# Fix timestamp to avoid varying results |
| 48 |
SET timestamp=1000000000; |
| 49 |
|
| 50 |
# Delete all existing binary logs |
| 51 |
RESET MASTER; |
| 52 |
|
| 53 |
CREATE DATABASE test1; |
| 54 |
CREATE TABLE test1.t1(a int); |
| 55 |
|
| 56 |
CREATE DATABASE test2; |
| 57 |
CREATE TABLE test2.t2(a int); |
| 58 |
CREATE VIEW test2.v2 AS SELECT * FROM test2.t2; |
| 59 |
|
| 60 |
CREATE DATABASE test3; |
| 61 |
CREATE TABLE test3.t3(a int); |
| 62 |
|
| 63 |
CREATE DATABASE xtest1; |
| 64 |
CREATE TABLE xtest1.xt1(a int); |
| 65 |
|
| 66 |
CREATE DATABASE xtest2; |
| 67 |
CREATE TABLE xtest2.xt2(a int); |
| 68 |
|
| 69 |
# By default SESSION binlog_annotate_row_events = OFF |
| 70 |
|
| 71 |
INSERT INTO test1.t1 VALUES (1), (2), (3); |
| 72 |
|
| 73 |
SET SESSION binlog_annotate_row_events = ON; |
| 74 |
|
| 75 |
INSERT INTO test2.t2 VALUES (1), (2), (3); |
| 76 |
INSERT INTO test3.t3 VALUES (1), (2), (3); |
| 77 |
|
| 78 |
# This query generates two Table maps but the Annotate |
| 79 |
# event should appear only once before the first Table map |
| 80 |
DELETE test1.t1, test2.t2 |
| 81 |
FROM test1.t1 INNER JOIN test2.t2 INNER JOIN test3.t3 |
| 82 |
WHERE test1.t1.a=test2.t2.a AND test2.t2.a=test3.t3.a; |
| 83 |
|
| 84 |
# This event should be filtered out together with Annotate event |
| 85 |
INSERT INTO xtest1.xt1 VALUES (1), (2), (3); |
| 86 |
|
| 87 |
# This event should pass the filter |
| 88 |
INSERT INTO test2.v2 VALUES (1), (2), (3); |
| 89 |
|
| 90 |
# This event should pass the filter only for test2.t2 part |
| 91 |
DELETE xtest1.xt1, test2.t2 |
| 92 |
FROM xtest1.xt1 INNER JOIN test2.t2 INNER JOIN test3.t3 |
| 93 |
WHERE xtest1.xt1.a=test2.t2.a AND test2.t2.a=test3.t3.a; |
| 94 |
|
| 95 |
# These events should be filtered out together with Annotate events |
| 96 |
INSERT INTO xtest1.xt1 VALUES (1), (2), (3); |
| 97 |
INSERT INTO xtest2.xt2 VALUES (1), (2), (3); |
| 98 |
DELETE xtest1.xt1, xtest2.xt2 |
| 99 |
FROM xtest1.xt1 INNER JOIN xtest2.xt2 INNER JOIN test3.t3 |
| 100 |
WHERE xtest1.xt1.a=xtest2.xt2.a AND xtest2.xt2.a=test3.t3.a; |
| 101 |
|
| 102 |
FLUSH LOGS; |
| 103 |
|
| 104 |
--echo ##################################################################################### |
| 105 |
--echo # The following Annotate_rows events should appear below: |
| 106 |
--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3) |
| 107 |
--echo # - INSERT INTO test3.t3 VALUES (1), (2), (3) |
| 108 |
--echo # - DELETE test1.t1, test2.t2 FROM <...> |
| 109 |
--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3) |
| 110 |
--echo # - DELETE xtest1.xt1, test2.t2 FROM <...> |
| 111 |
--echo ##################################################################################### |
| 112 |
|
| 113 |
--source include/show_binlog_events.inc |
| 114 |
|
| 115 |
if (!$use_remote_mysqlbinlog) |
| 116 |
{ |
| 117 |
--echo # |
| 118 |
--echo ##################################################################################### |
| 119 |
--echo # mysqlbinlog |
| 120 |
--echo # The following Annotates should appear in this output: |
| 121 |
--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3) |
| 122 |
--echo # - INSERT INTO test3.t3 VALUES (1), (2), (3) |
| 123 |
--echo # - DELETE test1.t1, test2.t2 FROM <...> (with two subsequent Table maps) |
| 124 |
--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3) |
| 125 |
--echo # - DELETE xtest1.xt1, test2.t2 FROM <...> (with one subsequent Table map) |
| 126 |
--echo ##################################################################################### |
| 127 |
|
| 128 |
--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /collation_server=[0-9]+/collation_server=X/ /character_set_client=[a-zA-Z0-9]+/character_set_client=X/ /collation_connection=[0-9]+/collation_connection=X/ /xid=\d*/xid=<xid>/ |
| 129 |
--exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $datadir/master-bin.000001 |
| 130 |
|
| 131 |
--echo # |
| 132 |
--echo ##################################################################################### |
| 133 |
--echo # mysqlbinlog --database=test1 |
| 134 |
--echo # The following Annotate should appear in this output: |
| 135 |
--echo # - DELETE test1.t1, test2.t2 FROM <...> |
| 136 |
--echo ##################################################################################### |
| 137 |
|
| 138 |
--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /collation_server=[0-9]+/collation_server=X/ /character_set_client=[a-zA-Z0-9]+/character_set_client=X/ /collation_connection=[0-9]+/collation_connection=X/ /xid=\d*/xid=<xid>/ |
| 139 |
--exec $MYSQL_BINLOG --base64-output=decode-rows --database=test1 -v -v $datadir/master-bin.000001 |
| 140 |
|
| 141 |
--echo # |
| 142 |
--echo ##################################################################################### |
| 143 |
--echo # mysqlbinlog --skip-annotate-row-events |
| 144 |
--echo # No Annotates should appear in this output |
| 145 |
--echo ##################################################################################### |
| 146 |
|
| 147 |
--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /collation_server=[0-9]+/collation_server=X/ /character_set_client=[a-zA-Z0-9]+/character_set_client=X/ /collation_connection=[0-9]+/collation_connection=X/ /xid=\d*/xid=<xid>/ |
| 148 |
--exec $MYSQL_BINLOG --base64-output=decode-rows --skip-annotate-row-events -v -v $datadir/master-bin.000001 |
| 149 |
|
| 150 |
--let use_remote_mysqlbinlog= 0 |
| 151 |
} |
| 152 |
|
| 153 |
--echo # |
| 154 |
--echo ##################################################################################### |
| 155 |
--echo # mysqlbinlog --read-from-remote-server |
| 156 |
--echo # The following Annotates should appear in this output: |
| 157 |
--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3) |
| 158 |
--echo # - INSERT INTO test3.t3 VALUES (1), (2), (3) |
| 159 |
--echo # - DELETE test1.t1, test2.t2 FROM <...> (with two subsequent Table maps) |
| 160 |
--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3) |
| 161 |
--echo # - DELETE xtest1.xt1, test2.t2 FROM <...> (with one subsequent Table map) |
| 162 |
--echo ##################################################################################### |
| 163 |
|
| 164 |
--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /collation_server=[0-9]+/collation_server=X/ /character_set_client=[a-zA-Z0-9]+/character_set_client=X/ /collation_connection=[0-9]+/collation_connection=X/ /xid=\d*/xid=<xid>/ |
| 165 |
--exec $MYSQL_BINLOG --base64-output=decode-rows -v -v --read-from-remote-server --user=root --host=localhost --port=$MASTER_MYPORT master-bin.000001 |
| 166 |
|
| 167 |
--echo # |
| 168 |
--echo ##################################################################################### |
| 169 |
--echo # mysqlbinlog --read-from-remote-server --database=test1 |
| 170 |
--echo # The following Annotate should appear in this output: |
| 171 |
--echo # - DELETE test1.t1, test2.t2 FROM <...> |
| 172 |
--echo ##################################################################################### |
| 173 |
|
| 174 |
--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /collation_server=[0-9]+/collation_server=X/ /character_set_client=[a-zA-Z0-9]+/character_set_client=X/ /collation_connection=[0-9]+/collation_connection=X/ /xid=\d*/xid=<xid>/ |
| 175 |
--exec $MYSQL_BINLOG --base64-output=decode-rows --database=test1 -v -v --read-from-remote-server --user=root --host=localhost --port=$MASTER_MYPORT master-bin.000001 |
| 176 |
|
| 177 |
--echo # |
| 178 |
--echo ##################################################################################### |
| 179 |
--echo # mysqlbinlog --read-from-remote-server --skip-annotate-row-events |
| 180 |
--echo # No Annotates should appear in this output |
| 181 |
--echo ##################################################################################### |
| 182 |
|
| 183 |
--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /collation_server=[0-9]+/collation_server=X/ /character_set_client=[a-zA-Z0-9]+/character_set_client=X/ /collation_connection=[0-9]+/collation_connection=X/ /xid=\d*/xid=<xid>/ |
| 184 |
--exec $MYSQL_BINLOG --base64-output=decode-rows --skip-annotate-row-events -v -v --read-from-remote-server --user=root --host=localhost --port=$MASTER_MYPORT master-bin.000001 |
| 185 |
|
| 186 |
# Clean-up |
| 187 |
|
| 188 |
set global binlog_checksum=@old_binlog_checksum; |
| 189 |
DROP DATABASE test1; |
| 190 |
DROP DATABASE test2; |
| 191 |
DROP DATABASE test3; |
| 192 |
DROP DATABASE xtest1; |
| 193 |
DROP DATABASE xtest2; |