1
#########################################
2
# Author: Serge Kozlov skozlov@mysql.com
4
# Purpose: testing the replication in mixed mode
5
# Requirements: define binlog format for mysqld as in example below:
6
# ./mysql-test-run.pl --mysqld=--binlog-format=mixed
7
#########################################
9
--source include/master-slave.inc
11
# Check MIXED on both master and slave
13
--echo ==========MASTER==========
14
--source suite/rpl/include/rpl_mixed_show_binlog_format.inc
16
--echo ==========SLAVE===========
17
--source suite/rpl/include/rpl_mixed_show_binlog_format.inc
21
CREATE DATABASE test_rpl;
24
--echo ******************** PREPARE TESTING ********************
26
eval CREATE TABLE t1 (a int auto_increment not null, b char(254), PRIMARY KEY(a)) ENGINE=$engine_type;
27
eval CREATE TABLE t2 (a int auto_increment not null, b char(254), PRIMARY KEY(a)) ENGINE=$engine_type;
30
INSERT INTO t1 VALUES(1, 't1, text 1');
31
INSERT INTO t1 VALUES(2, 't1, text 2');
32
INSERT INTO t2 VALUES(1, 't2, text 1');
34
--echo ******************** DELETE ********************
35
DELETE FROM t1 WHERE a = 1;
36
DELETE FROM t2 WHERE b <> UUID();
37
--source suite/rpl/include/rpl_mixed_check_select.inc
38
--source suite/rpl/include/rpl_mixed_clear_tables.inc
42
--echo ******************** INSERT ********************
43
INSERT INTO t1 VALUES(1, 't1, text 1');
44
INSERT INTO t1 VALUES(2, UUID());
45
INSERT INTO t2 SELECT * FROM t1;
46
INSERT INTO t2 VALUES (1, 't1, text 1') ON DUPLICATE KEY UPDATE b = 't2, text 1';
47
DELETE FROM t1 WHERE a = 2;
48
DELETE FROM t2 WHERE a = 2;
49
--source suite/rpl/include/rpl_mixed_check_select.inc
50
--source suite/rpl/include/rpl_mixed_clear_tables.inc
53
--echo ******************** LOAD DATA INFILE ********************
54
--copy_file ./suite/rpl/data/rpl_mixed.dat $MYSQLTEST_VARDIR/tmp/rpl_mixed.dat
55
LOAD DATA INFILE '../tmp/rpl_mixed.dat' INTO TABLE t1 FIELDS TERMINATED BY '|' ;
56
--remove_file $MYSQLTEST_VARDIR/tmp/rpl_mixed.dat
57
SELECT * FROM t1 ORDER BY a;
58
--source suite/rpl/include/rpl_mixed_check_select.inc
59
--source suite/rpl/include/rpl_mixed_clear_tables.inc
63
--echo ******************** REPLACE ********************
64
INSERT INTO t1 VALUES(1, 't1, text 1');
65
INSERT INTO t1 VALUES(2, 't1, text 2');
66
INSERT INTO t1 VALUES(3, 't1, text 3');
67
REPLACE INTO t1 VALUES(1, 't1, text 11');
68
REPLACE INTO t1 VALUES(2, UUID());
69
REPLACE INTO t1 SET a=3, b='t1, text 33';
70
DELETE FROM t1 WHERE a = 2;
71
--source suite/rpl/include/rpl_mixed_check_select.inc
72
--source suite/rpl/include/rpl_mixed_clear_tables.inc
76
--echo ******************** SELECT ********************
77
INSERT INTO t1 VALUES(1, 't1, text 1');
78
SELECT * FROM t1 WHERE b <> UUID() ORDER BY a;
79
--source suite/rpl/include/rpl_mixed_clear_tables.inc
83
--echo ******************** JOIN ********************
84
INSERT INTO t1 VALUES(1, 'CCC');
85
INSERT INTO t1 VALUES(2, 'DDD');
86
INSERT INTO t2 VALUES(1, 'DDD');
87
INSERT INTO t2 VALUES(2, 'CCC');
88
SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a ORDER BY t1.a,t2.a;
89
SELECT * FROM t1 INNER JOIN t2 ON t1.b = t2.b ORDER BY t1.a,t2.a;
90
--source suite/rpl/include/rpl_mixed_clear_tables.inc
94
--echo ******************** UNION ********************
95
INSERT INTO t1 VALUES(1, 't1, text 1');
96
INSERT INTO t2 VALUES(1, 't2, text 1');
97
SELECT * FROM t1 UNION SELECT * FROM t2 WHERE t2.b <> UUID();
98
--source suite/rpl/include/rpl_mixed_clear_tables.inc
102
--echo ******************** TRUNCATE ********************
103
INSERT INTO t1 VALUES(1, 't1, text 1');
104
--source suite/rpl/include/rpl_mixed_check_select.inc
106
--source suite/rpl/include/rpl_mixed_check_select.inc
107
--source suite/rpl/include/rpl_mixed_clear_tables.inc
111
--echo ******************** UPDATE ********************
112
INSERT INTO t1 VALUES(1, 't1, text 1');
113
INSERT INTO t2 VALUES(1, 't2, text 1');
114
UPDATE t1 SET b = 't1, text 1 updated' WHERE a = 1;
115
--source suite/rpl/include/rpl_mixed_check_select.inc
116
UPDATE t1, t2 SET t1.b = 'test', t2.b = 'test';
117
--source suite/rpl/include/rpl_mixed_check_select.inc
118
--source suite/rpl/include/rpl_mixed_clear_tables.inc
122
--echo ******************** DESCRIBE ********************
128
--echo ******************** USE ********************
133
--echo ******************** TRANSACTION ********************
135
INSERT INTO t1 VALUES (1, 'start');
137
--source suite/rpl/include/rpl_mixed_check_select.inc
139
INSERT INTO t1 VALUES (2, 'rollback');
141
--source suite/rpl/include/rpl_mixed_check_select.inc
143
INSERT INTO t1 VALUES (3, 'before savepoint s1');
145
INSERT INTO t1 VALUES (4, 'after savepoint s1');
146
ROLLBACK TO SAVEPOINT s1;
147
--source suite/rpl/include/rpl_mixed_check_select.inc
149
INSERT INTO t1 VALUES (5, 'before savepoint s2');
151
INSERT INTO t1 VALUES (6, 'after savepoint s2');
152
INSERT INTO t1 VALUES (7, CONCAT('with UUID() ',UUID()));
153
RELEASE SAVEPOINT s2;
155
DELETE FROM t1 WHERE a = 7;
156
--source suite/rpl/include/rpl_mixed_check_select.inc
157
--source suite/rpl/include/rpl_mixed_clear_tables.inc
161
--echo ******************** LOCK TABLES ********************
162
LOCK TABLES t1 READ , t2 READ;
165
# TRANSACTION ISOLATION LEVEL
167
--echo ******************** TRANSACTION ISOLATION LEVEL ********************
168
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
169
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
170
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
171
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
178
--echo ******************** CREATE USER ********************
179
CREATE USER 'user_test_rpl'@'localhost' IDENTIFIED BY PASSWORD '*1111111111111111111111111111111111111111';
180
--source suite/rpl/include/rpl_mixed_check_user.inc
184
--echo ******************** GRANT ********************
185
GRANT SELECT ON *.* TO 'user_test_rpl'@'localhost';
186
--source suite/rpl/include/rpl_mixed_check_user.inc
190
--echo ******************** REVOKE ********************
191
REVOKE SELECT ON *.* FROM 'user_test_rpl'@'localhost';
192
--source suite/rpl/include/rpl_mixed_check_user.inc
196
--echo ******************** SET PASSWORD ********************
197
SET PASSWORD FOR 'user_test_rpl'@'localhost' = '*0000000000000000000000000000000000000000';
198
--source suite/rpl/include/rpl_mixed_check_user.inc
202
--echo ******************** RENAME USER ********************
203
RENAME USER 'user_test_rpl'@'localhost' TO 'user_test_rpl_2'@'localhost';
204
--source suite/rpl/include/rpl_mixed_check_user.inc
208
--echo ******************** DROP USER ********************
209
DROP USER 'user_test_rpl_2'@'localhost';
210
--source suite/rpl/include/rpl_mixed_check_user.inc
212
# Prepring for some following operations
213
INSERT INTO t1 VALUES(100, 'test');
217
--echo ******************** ANALYZE ********************
221
# skipped because deprecated
225
--echo ******************** CHECK TABLE ********************
230
--echo ******************** CHECKSUM TABLE ********************
235
--echo ******************** OPTIMIZE TABLE ********************
240
--echo ******************** REPAIR TABLE ********************
245
--echo ******************** SET VARIABLE ********************
246
SET @test_rpl_var = 1;
247
SHOW VARIABLES LIKE 'test_rpl_var';
251
--echo ******************** SHOW ********************
252
--source suite/rpl/include/rpl_mixed_check_db.inc
257
--echo ******************** PROCEDURE ********************
259
CREATE PROCEDURE p1 ()
261
UPDATE t1 SET b = 'test' WHERE a = 201;
263
CREATE PROCEDURE p2 ()
265
UPDATE t1 SET b = UUID() WHERE a = 202;
268
INSERT INTO t1 VALUES(201, 'test 201');
270
INSERT INTO t1 VALUES(202, 'test 202');
272
DELETE FROM t1 WHERE a = 202;
273
--source suite/rpl/include/rpl_mixed_check_select.inc
274
ALTER PROCEDURE p1 COMMENT 'p1';
277
--source suite/rpl/include/rpl_mixed_clear_tables.inc
281
--echo ******************** TRIGGER ********************
283
CREATE TRIGGER tr1 BEFORE INSERT ON t1
285
INSERT INTO t2 SET a = NEW.a, b = NEW.b;
288
INSERT INTO t1 VALUES (1, 'test');
289
--source suite/rpl/include/rpl_mixed_check_select.inc
290
--source suite/rpl/include/rpl_mixed_clear_tables.inc
296
--echo ******************** EVENTS ********************
297
GRANT EVENT ON *.* TO 'root'@'localhost';
298
INSERT INTO t1 VALUES(1, 'test1');
299
CREATE EVENT e1 ON SCHEDULE EVERY '1' SECOND COMMENT 'e_second_comment' DO DELETE FROM t1;
300
--source suite/rpl/include/rpl_mixed_check_event.inc
301
--source suite/rpl/include/rpl_mixed_check_select.inc
303
--source suite/rpl/include/rpl_mixed_check_select.inc
304
ALTER EVENT e1 RENAME TO e2;
306
--source suite/rpl/include/rpl_mixed_check_event.inc
307
--source suite/rpl/include/rpl_mixed_check_select.inc
309
--source suite/rpl/include/rpl_mixed_check_event.inc
310
--source suite/rpl/include/rpl_mixed_clear_tables.inc
314
--echo ******************** VIEWS ********************
315
INSERT INTO t1 VALUES(1, 'test1');
316
INSERT INTO t1 VALUES(2, 'test2');
317
CREATE VIEW v1 AS SELECT * FROM t1 WHERE a = 1;
318
CREATE VIEW v2 AS SELECT * FROM t1 WHERE b <> UUID();
319
--source suite/rpl/include/rpl_mixed_check_view.inc
320
ALTER VIEW v1 AS SELECT * FROM t1 WHERE a = 2;
321
--source suite/rpl/include/rpl_mixed_check_view.inc
324
--source suite/rpl/include/rpl_mixed_clear_tables.inc
329
--echo ******************** SHOW BINLOG EVENTS ********************
330
--replace_column 2 # 5 #
331
--replace_regex /Server ver: .+/Server ver: #/ /table_id: [0-9]+/table_id: #/ /COMMIT.+xid=[0-9]+.+/#/ /file_id=[0-9]+/file_id=#/ /block_len=[0-9]+/block_len=#/
332
show binlog events from 1;
333
sync_slave_with_master;
334
# as we're using UUID we don't SELECT but use "diff" like in rpl_row_UUID
335
--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test_rpl > $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_master.sql
336
--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test_rpl > $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_slave.sql
339
drop database test_rpl;
340
sync_slave_with_master;
342
# Let's compare. Note: If they match test will pass, if they do not match
343
# the test will show that the diff statement failed and not reject file
344
# will be created. You will need to go to the mysql-test dir and diff
345
# the files your self to see what is not matching
347
--exec diff $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_master.sql $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_slave.sql