1# This test case verifies that the mysqlbinlog --base64-output=X flags 2# work as expected, and that BINLOG statements with row events fail if 3# they are not preceded by BINLOG statements with Format description 4# events. 5# 6# See also BUG#32407. 7 8 9# BINLOG statement does not work in embedded mode. 10source include/not_embedded.inc; 11 12call mtr.add_suppression("BINLOG_BASE64_EVENT: According to the master's version"); 13call mtr.add_suppression("BINLOG_BASE64_EVENT: Column 1 of table 'test.char128_utf8' cannot be converted"); 14 15disable_warnings; 16DROP TABLE IF EXISTS t1; 17enable_warnings; 18# Test to show BUG#32407. This reads a binlog created with the 19# mysql-5.1-telco-6.1 tree, specifically at the tag 20# mysql-5.1.15-ndb-6.1.23, and applies it to the database. The test 21# should fail before BUG#32407 was fixed and succeed afterwards. 22--echo ==== Test BUG#32407 ==== 23 24# The binlog contains row events equivalent to: 25# CREATE TABLE t1 (a int) engine = myisam 26# INSERT INTO t1 VALUES (1), (1) 27exec $MYSQL_BINLOG suite/binlog/std_data/bug32407.001 | $MYSQL; 28# The above line should succeed and t1 should contain two ones 29select * from t1; 30 31 32# Test that a BINLOG statement encoding a row event fails unless a 33# Format_description_event as been supplied with an earlier BINLOG 34# statement. 35--echo ==== Test BINLOG statement w/o FD event ==== 36 37# This is a binlog statement consisting of one Table_map_log_event and 38# one Write_rows_log_event. Together, they correspond to the 39# following query: 40# INSERT INTO TABLE test.t1 VALUES (2) 41 42error ER_NO_FORMAT_DESCRIPTION_EVENT_BEFORE_BINLOG_STATEMENT; 43BINLOG ' 44SVtYRxMBAAAAKQAAADQBAAAAABAAAAAAAAAABHRlc3QAAnQxAAEDAAE= 45SVtYRxcBAAAAIgAAAFYBAAAQABAAAAAAAAEAAf/+AgAAAA== 46'; 47# The above line should fail and 2 should not be in the table 48select * from t1; 49 50 51# Test that it works to read a Format_description_log_event with a 52# BINLOG statement, followed by a row-event in base64 from the same 53# version. 54--echo ==== Test BINLOG statement with FD event ==== 55 56# This is a binlog statement containing a Format_description_log_event 57# from the same version as the Table_map and Write_rows_log_event. 58BINLOG ' 59ODdYRw8BAAAAZgAAAGoAAAABAAQANS4xLjIzLXJjLWRlYnVnLWxvZwAAAAAAAAAAAAAAAAAAAAAA 60AAAAAAAAAAAAAAAAAAA4N1hHEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC 61'; 62 63# This is a Table_map_log_event+Write_rows_log_event corresponding to: 64# INSERT INTO TABLE test.t1 VALUES (3) 65BINLOG ' 66TFtYRxMBAAAAKQAAAH8BAAAAABAAAAAAAAAABHRlc3QAAnQxAAEDAAE= 67TFtYRxcBAAAAIgAAAKEBAAAQABAAAAAAAAEAAf/+AwAAAA== 68'; 69# The above line should succeed and 3 should be in the table 70select * from t1; 71 72# The same as above with one-fragment BINLOG to prove 73# equivalency with the fragmented BINLOG @frag_0, @frag_1. 74DELETE FROM t1 WHERE a=3; 75# This is a binlog statement containing a Format_description_log_event 76# from the same version as the Table_map and Write_rows_log_event. 77BINLOG ' 78ODdYRw8BAAAAZgAAAGoAAAABAAQANS4xLjIzLXJjLWRlYnVnLWxvZwAAAAAAAAAAAAAAAAAAAAAA 79AAAAAAAAAAAAAAAAAAA4N1hHEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC 80'; 81 82# This is a Table_map_log_event+Write_rows_log_event corresponding to: 83# INSERT INTO TABLE test.t1 VALUES (3) 84SET @binlog_fragment_0=' 85TFtYRxMBAAAAKQAAAH8BAAAAABAAAAAAAAAABHRlc3QAAnQxAAEDAAE= 86TFtYRxcBAAAAIgAAAKEBAAAQABAAAAAAAAEAAf/+AwAAAA== 87'; 88SET @binlog_fragment_1=''; 89BINLOG @binlog_fragment_0, @binlog_fragment_1; 90# The above line should succeed and 3 should be in the table: 91select * from t1; 92# show "one-shot" feature of binlog_fragment variables 93SELECT @binlog_fragment_0, @binlog_fragment_1 as 'NULL','NULL'; 94 95# New mysqlbinlog supports --base64-output=never 96--echo ==== Test --base64-output=never on a binlog with row events ==== 97 98# mysqlbinlog should fail 99--replace_regex /#[0-9][0-9][0-9][0-9][0-9][0-9] \N*/<#>/ /SET \@\@session.pseudo_thread_id.*/<#>/ 100exec $MYSQL_BINLOG --base64-output=never --print-row-count=0 --print-row-event-positions=0 suite/binlog/std_data/bug32407.001; 101 102 103# Test that the following fails cleanly: "First, read a 104# Format_description event which has N event types. Then, read an 105# event of type M>N" 106--echo ==== Test non-matching FD event and Row event ==== 107 108# This is the Format_description_log_event from 109# bug32407.001, encoded in base64. It contains only the old 110# row events (number of event types is 22) 111BINLOG ' 1124CdYRw8BAAAAYgAAAGYAAAAAAAQANS4xLjE1LW5kYi02LjEuMjQtZGVidWctbG9nAAAAAAAAAAAA 113AAAAAAAAAAAAAAAAAADgJ1hHEzgNAAgAEgAEBAQEEgAATwAEGggICAg= 114'; 115 116# The following is a Write_rows_log_event with event type 23, i.e., 117# not supported by the Format_description_log_event above. It 118# corresponds to the following query: 119# INSERT INTO t1 VALUES (5) 120error 1149; 121BINLOG ' 122Dl1YRxMBAAAAKQAAADQBAAAAABAAAAAAAAAABHRlc3QAAnQxAAEDAAE= 123Dl1YRxcBAAAAIgAAAFYBAAAQABAAAAAAAAEAAf/+BQAAAA== 124'; 125# the above line should fail and 5 should not be in the binlog. 126select * from t1; 127 128# Test that BUG#37426 is triggered. 129 130CREATE TABLE char128_utf8 ( 131 i1 INT NOT NULL, 132 c CHAR(128) CHARACTER SET utf8 NOT NULL, 133 i2 INT NOT NULL); 134CREATE TABLE char63_utf8 ( 135 i1 INT NOT NULL, 136 c CHAR(63) CHARACTER SET utf8 NOT NULL, 137 i2 INT NOT NULL); 138 139# 140# This is the format description log event 141# 142 143BINLOG ' 144MuNkSA8BAAAAZgAAAGoAAAAAAAQANS4xLjI1LXJjLWRlYnVnLWxvZwAAAAAAAAAAAAAAAAAAAAAA 145AAAAAAAAAAAAAAAAAAAy42RIEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC 146'; 147 148# ... this event corresponding to 149# 150# INSERT INTO char63_utf8 VALUES ( 1, "123", 1 ) 151# 152# The binlog event below shall not trigger the bug check 153 154BINLOG ' 1553u9kSBMBAAAANgAAAJYBAAAAABAAAAAAAAAABHRlc3QAC2NoYXI2M191dGY4AAMD/gMC/r0A 1563u9kSBcBAAAAKgAAAMABAAAQABAAAAAAAAEAA//4AQAAAAMxMjMBAAAA 157'; 158SELECT * FROM char63_utf8; 159 160# ... and this is an event corresponding to 161# 162# INSERT INTO char128_utf8 VALUES ( 1, "123", 1 ) 163# 164# The binlog event below shall trigger the bug check and produce an error 165# 166 167error ER_UNKNOWN_ERROR; 168BINLOG ' 169iONkSBMBAAAANwAAAJkBAAAAABAAAAAAAAAABHRlc3QADGNoYXIxMjhfdXRmOAADA/4DAv6AAA== 170iONkSBcBAAAAKwAAAMQBAAAQABAAAAAAAAEAA//4AQAAAAMAMTIzAQAAAA== 171'; 172 173drop table t1, char63_utf8, char128_utf8; 174 175call mtr.add_suppression("Slave SQL.*master suffers from this bug: http:..bugs.mysql.com.bug.php.id=37426.* error.* 1105"); 176call mtr.add_suppression("Slave SQL.*Table definition on master and slave does not match: Column 1 size mismatch.* error.* 1535"); 177call mtr.add_suppression("Slave SQL.*Column 1 of table .test.char128_utf8. cannot be converted.* error.* 1677"); 178 179--echo # 180--echo # Bug #54393: crash and/or valgrind errors in 181--echo # mysql_client_binlog_statement 182--echo # 183--error ER_SYNTAX_ERROR 184BINLOG ''; 185--error ER_BASE64_DECODE_ERROR 186BINLOG '123'; 187--error ER_BASE64_DECODE_ERROR 188BINLOG '-2079193929'; 189--error ER_BASE64_DECODE_ERROR 190BINLOG 'xç↓%~∙D╒ƒ╡'; 191