1
by brian
clean slate |
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. |
|
10 |
source include/not_embedded.inc; |
|
11 |
||
12 |
disable_warnings; |
|
13 |
DROP TABLE IF EXISTS t1; |
|
14 |
enable_warnings; |
|
15 |
||
16 |
# Test to show BUG#32407. This reads a binlog created with the |
|
17 |
# mysql-5.1-telco-6.1 tree, specifically at the tag |
|
18 |
# mysql-5.1.15-ndb-6.1.23, and applies it to the database. The test |
|
19 |
# should fail before BUG#32407 was fixed and succeed afterwards. |
|
20 |
--echo ==== Test BUG#32407 ====
|
|
21 |
||
22 |
# The binlog contains row events equivalent to: |
|
23 |
# CREATE TABLE t1 (a int) engine = myisam |
|
24 |
# INSERT INTO t1 VALUES (1), (1) |
|
25 |
exec $MYSQL_BINLOG suite/binlog/std_data/bug32407.001 | $MYSQL; |
|
26 |
# The above line should succeed and t1 should contain two ones |
|
27 |
select * from t1; |
|
28 |
||
29 |
||
30 |
# Test that a BINLOG statement encoding a row event fails unless a |
|
31 |
# Format_description_event as been supplied with an earlier BINLOG |
|
32 |
# statement. |
|
33 |
--echo ==== Test BINLOG statement w/o FD event ====
|
|
34 |
||
35 |
# This is a binlog statement consisting of one Table_map_log_event and |
|
36 |
# one Write_rows_log_event. Together, they correspond to the |
|
37 |
# following query: |
|
38 |
# INSERT INTO TABLE test.t1 VALUES (2) |
|
39 |
||
40 |
error ER_NO_FORMAT_DESCRIPTION_EVENT_BEFORE_BINLOG_STATEMENT; |
|
41 |
BINLOG ' |
|
42 |
SVtYRxMBAAAAKQAAADQBAAAAABAAAAAAAAAABHRlc3QAAnQxAAEDAAE=
|
|
43 |
SVtYRxcBAAAAIgAAAFYBAAAQABAAAAAAAAEAAf/+AgAAAA==
|
|
44 |
'; |
|
45 |
# The above line should fail and 2 should not be in the table |
|
46 |
select * from t1; |
|
47 |
||
48 |
||
49 |
# Test that it works to read a Format_description_log_event with a |
|
50 |
# BINLOG statement, followed by a row-event in base64 from the same |
|
51 |
# version. |
|
52 |
--echo ==== Test BINLOG statement with FD event ====
|
|
53 |
||
54 |
# This is a binlog statement containing a Format_description_log_event |
|
55 |
# from the same version as the Table_map and Write_rows_log_event. |
|
56 |
BINLOG ' |
|
57 |
ODdYRw8BAAAAZgAAAGoAAAABAAQANS4xLjIzLXJjLWRlYnVnLWxvZwAAAAAAAAAAAAAAAAAAAAAA
|
|
58 |
AAAAAAAAAAAAAAAAAAA4N1hHEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
|
|
59 |
'; |
|
60 |
||
61 |
# This is a Table_map_log_event+Write_rows_log_event corresponding to: |
|
62 |
# INSERT INTO TABLE test.t1 VALUES (3) |
|
63 |
BINLOG ' |
|
64 |
TFtYRxMBAAAAKQAAAH8BAAAAABAAAAAAAAAABHRlc3QAAnQxAAEDAAE=
|
|
65 |
TFtYRxcBAAAAIgAAAKEBAAAQABAAAAAAAAEAAf/+AwAAAA==
|
|
66 |
'; |
|
67 |
# The above line should succeed and 3 should be in the table |
|
68 |
select * from t1; |
|
69 |
||
70 |
||
71 |
# Test that mysqlbinlog stops with an error message when the |
|
72 |
# --base64-output=never flag is used on a binlog with base64 events. |
|
73 |
--echo ==== Test --base64-output=never on a binlog with row events ====
|
|
74 |
||
75 |
# mysqlbinlog should fail |
|
76 |
--replace_regex /#[0-9][0-9][0-9][0-9][0-9][0-9] .*/<#>/ /SET \@\@session.pseudo_thread_id.*/<#>/
|
|
77 |
error 1; |
|
78 |
exec $MYSQL_BINLOG --base64-output=never suite/binlog/std_data/bug32407.001; |
|
79 |
# the above line should output the query log event and then stop |
|
80 |
||
81 |
||
82 |
# Test that the following fails cleanly: "First, read a |
|
83 |
# Format_description event which has N event types. Then, read an
|
|
84 |
# event of type M>N"
|
|
85 |
--echo ==== Test non-matching FD event and Row event ====
|
|
86 |
||
87 |
# This is the Format_description_log_event from |
|
88 |
# bug32407.001, encoded in base64. It contains only the old |
|
89 |
# row events (number of event types is 22) |
|
90 |
BINLOG ' |
|
91 |
4CdYRw8BAAAAYgAAAGYAAAAAAAQANS4xLjE1LW5kYi02LjEuMjQtZGVidWctbG9nAAAAAAAAAAAA
|
|
92 |
AAAAAAAAAAAAAAAAAADgJ1hHEzgNAAgAEgAEBAQEEgAATwAEGggICAg=
|
|
93 |
'; |
|
94 |
||
95 |
# The following is a Write_rows_log_event with event type 23, i.e., |
|
96 |
# not supported by the Format_description_log_event above. It |
|
97 |
# corresponds to the following query: |
|
98 |
# INSERT INTO t1 VALUES (5) |
|
99 |
error 1149; |
|
100 |
BINLOG ' |
|
101 |
Dl1YRxMBAAAAKQAAADQBAAAAABAAAAAAAAAABHRlc3QAAnQxAAEDAAE=
|
|
102 |
Dl1YRxcBAAAAIgAAAFYBAAAQABAAAAAAAAEAAf/+BQAAAA==
|
|
103 |
'; |
|
104 |
# the above line should fail and 5 should not be in the binlog. |
|
105 |
select * from t1; |
|
106 |
||
107 |
||
108 |
# clean up |
|
109 |
drop table t1; |