1
by brian
clean slate |
1 |
# Test that old binlog formats can be read.
|
2 |
||
3 |
# Some previous versions of MySQL use their own binlog format,
|
|
4 |
# especially in row-based replication. This test uses saved binlogs
|
|
5 |
# from those old versions to test that we can replicate from old
|
|
6 |
# versions to the present version.
|
|
7 |
||
8 |
# Replicating from old versions to new versions is necessary in an
|
|
9 |
# online upgrade scenario, where the .
|
|
10 |
||
11 |
# The previous versions we currently test are:
|
|
12 |
# - version 5.1.17 and earlier trees
|
|
13 |
# - mysql-5.1-wl2325-xxx trees (AKA alcatel trees)
|
|
14 |
# - mysql-5.1-telco-6.1 trees (AKA ndb trees)
|
|
15 |
# For completeness, we also test mysql-5.1-new_rpl, which is supposed
|
|
16 |
# to be the "correct" version.
|
|
17 |
||
18 |
# All binlogs were generated with the same commands (listed at the end
|
|
19 |
# of this test for reference). The binlogs contain the following
|
|
20 |
# events: Table_map, Write_rows, Update_rows, Delete_rows Query, Xid,
|
|
21 |
# User_var, Int_var, Rand, Begin_load, Append_file, Execute_load.
|
|
22 |
||
23 |
# Related bugs: BUG#27779, BUG#31581, BUG#31582, BUG#31583, BUG#32407
|
|
24 |
||
25 |
source include/not_embedded.inc; |
|
26 |
||
27 |
--disable_warnings |
|
28 |
DROP TABLE IF EXISTS t1, t2, t3; |
|
29 |
||
30 |
||
31 |
--echo ==== Read modern binlog (version 5.1.23) ==== |
|
32 |
||
33 |
# Read binlog.
|
|
34 |
--exec $MYSQL_BINLOG --local-load=$MYSQLTEST_VARDIR/tmp/ suite/binlog/std_data/ver_5_1_23.001 | $MYSQL --local-infile=1 |
|
35 |
# Show result.
|
|
36 |
SELECT * FROM t1 ORDER BY a; |
|
37 |
SELECT * FROM t2 ORDER BY a; |
|
38 |
SELECT COUNT(*) FROM t3; |
|
39 |
# Reset.
|
|
40 |
DROP TABLE t1, t2, t3; |
|
41 |
||
42 |
||
43 |
--echo ==== Read binlog from version 5.1.17 ==== |
|
44 |
||
45 |
# Read binlog.
|
|
46 |
--exec $MYSQL_BINLOG --local-load=$MYSQLTEST_VARDIR/tmp/ suite/binlog/std_data/ver_5_1_17.001 | $MYSQL --local-infile=1 |
|
47 |
# Show result.
|
|
48 |
SELECT * FROM t1 ORDER BY a; |
|
49 |
SELECT * FROM t2 ORDER BY a; |
|
50 |
SELECT COUNT(*) FROM t3; |
|
51 |
# Reset.
|
|
52 |
DROP TABLE t1, t2, t3; |
|
53 |
||
54 |
||
55 |
--echo ==== Read binlog from version 4.1 ==== |
|
56 |
||
57 |
# In this version, neither row-based binlogging nor Xid events
|
|
58 |
# existed, so the binlog was generated without the "row-based tests"
|
|
59 |
# part and the "get xid event" part, and it does not create table t2.
|
|
60 |
||
61 |
# Read binlog.
|
|
62 |
--exec $MYSQL_BINLOG --local-load=$MYSQLTEST_VARDIR/tmp/ suite/binlog/std_data/binlog_old_version_4_1.000001 | $MYSQL --local-infile=1 |
|
63 |
# Show result.
|
|
64 |
SELECT * FROM t1 ORDER BY a; |
|
65 |
SELECT COUNT(*) FROM t3; |
|
66 |
# Reset.
|
|
67 |
DROP TABLE t1, t3; |
|
68 |
||
69 |
||
70 |
--echo ==== Read binlog from alcatel tree (mysql-5.1-wl2325-5.0-drop6) ==== |
|
71 |
||
72 |
# In this version, it was not possible to switch between row-based and
|
|
73 |
# statement-based binlogging without restarting the server. So, we
|
|
74 |
# have two binlogs; one for row based and one for statement based
|
|
75 |
# replication.
|
|
76 |
||
77 |
# Read rbr binlog.
|
|
78 |
--exec $MYSQL_BINLOG --local-load=$MYSQLTEST_VARDIR/tmp/ suite/binlog/std_data/ver_5_1-wl2325_r.001 | $MYSQL --local-infile=1 |
|
79 |
# Read stm binlog.
|
|
80 |
--exec $MYSQL_BINLOG --local-load=$MYSQLTEST_VARDIR/tmp/ suite/binlog/std_data/ver_5_1-wl2325_s.001 | $MYSQL --local-infile=1 |
|
81 |
# Show result.
|
|
82 |
SELECT * FROM t1 ORDER BY a; |
|
83 |
SELECT * FROM t2 ORDER BY a; |
|
84 |
SELECT COUNT(*) FROM t3; |
|
85 |
# Reset.
|
|
86 |
DROP TABLE t1, t2, t3; |
|
87 |
||
88 |
||
89 |
--echo ==== Read binlog from ndb tree (mysql-5.1-telco-6.1) ==== |
|
90 |
||
91 |
# Read binlog.
|
|
92 |
--exec $MYSQL_BINLOG --local-load=$MYSQLTEST_VARDIR/tmp/ suite/binlog/std_data/ver_5_1-telco.001 | $MYSQL --local-infile=1 |
|
93 |
# Show resulting tablea.
|
|
94 |
SELECT * FROM t1 ORDER BY a; |
|
95 |
SELECT * FROM t2 ORDER BY a; |
|
96 |
SELECT COUNT(*) FROM t3; |
|
97 |
# Reset.
|
|
98 |
DROP TABLE t1, t2, t3; |
|
99 |
||
100 |
||
101 |
#### The following commands were used to generate the binlogs ####
|
|
102 |
#
|
|
103 |
#source include/master-slave.inc;
|
|
104 |
#
|
|
105 |
## ==== initialize ====
|
|
106 |
#USE test;
|
|
107 |
#CREATE TABLE t1 (a int, b char(50)) ENGINE = MyISAM;
|
|
108 |
#CREATE TABLE t2 (a int, b char(50)) ENGINE = InnoDB;
|
|
109 |
#CREATE TABLE t3 (a char(20));
|
|
110 |
#
|
|
111 |
#
|
|
112 |
## ==== row based tests ====
|
|
113 |
#SET BINLOG_FORMAT='row';
|
|
114 |
#
|
|
115 |
## ---- get write, update, and delete rows events ----
|
|
116 |
#INSERT INTO t1 VALUES (0, 'one'), (1, 'two');
|
|
117 |
#UPDATE t1 SET a=a+1;
|
|
118 |
#DELETE FROM t1 WHERE a=2;
|
|
119 |
#
|
|
120 |
#
|
|
121 |
## ==== statement based tests ====
|
|
122 |
#SET BINLOG_FORMAT = 'statement';
|
|
123 |
#
|
|
124 |
## ---- get xid events ----
|
|
125 |
#BEGIN;
|
|
126 |
#INSERT INTO t2 VALUES (3, 'first stm in trx');
|
|
127 |
#INSERT INTO t1 VALUES (3, 'last stm in trx: next event should be xid');
|
|
128 |
#COMMIT;
|
|
129 |
#
|
|
130 |
## ---- get user var events ----
|
|
131 |
#SET @x = 4;
|
|
132 |
#INSERT INTO t1 VALUES (@x, 'four');
|
|
133 |
#
|
|
134 |
## ---- get rand event ----
|
|
135 |
#INSERT INTO t1 VALUES (RAND() * 1000000, 'random');
|
|
136 |
#
|
|
137 |
## ---- get intvar event ----
|
|
138 |
#INSERT INTO t1 VALUES (LAST_INSERT_ID(), 'last_insert_id');
|
|
139 |
#
|
|
140 |
## ---- get begin, append and execute load events ----
|
|
141 |
## double the file until we have more than 2^17 bytes, so that the
|
|
142 |
## event has to be split and we can use Append_file_log_event.
|
|
143 |
#
|
|
144 |
#SET SQL_LOG_BIN=0;
|
|
145 |
#CREATE TABLE temp (a char(20));
|
|
146 |
#LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE temp;
|
|
147 |
#INSERT INTO temp SELECT * FROM temp;
|
|
148 |
#INSERT INTO temp SELECT * FROM temp;
|
|
149 |
#INSERT INTO temp SELECT * FROM temp;
|
|
150 |
#INSERT INTO temp SELECT * FROM temp;
|
|
151 |
#INSERT INTO temp SELECT * FROM temp;
|
|
152 |
#INSERT INTO temp SELECT * FROM temp;
|
|
153 |
#INSERT INTO temp SELECT * FROM temp;
|
|
154 |
#INSERT INTO temp SELECT * FROM temp;
|
|
155 |
#SELECT a FROM temp INTO OUTFILE 'big_file.dat';
|
|
156 |
#DROP TABLE temp;
|
|
157 |
#SET SQL_LOG_BIN=1;
|
|
158 |
#
|
|
159 |
#LOAD DATA INFILE 'big_file.dat' INTO TABLE t3;
|
|
160 |
#
|
|
161 |
#SELECT * FROM t1 ORDER BY a;
|
|
162 |
#SELECT * FROM t2 ORDER BY a;
|
|
163 |
#SELECT COUNT(*) FROM t3;
|