Debian Codegraph @

mysql-test/suite/binlog/t/binlog_base64_flag.test

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