1 #########################################
2 # Purpose: testing the replication in mixed mode
3 # Requirements: define binlog format for mysqld as in example below:
4 # ./mysql-test-run.pl --mysqld=--binlog-format=mixed
5 #########################################
7 --source include/master-slave.inc
9 # Check MIXED on both master and slave
11 --echo ==========MASTER==========
12 --source suite/rpl/include/rpl_mixed_show_binlog_format.inc
14 --echo ==========SLAVE===========
15 --source suite/rpl/include/rpl_mixed_show_binlog_format.inc
19 CREATE DATABASE test_rpl;
22 --echo ******************** PREPARE TESTING ********************
24 eval CREATE
TABLE t1 (a
int auto_increment not null, b
char(254), PRIMARY
KEY(a)) ENGINE=$engine_type;
25 eval CREATE
TABLE t2 (a
int auto_increment not null, b
char(254), PRIMARY
KEY(a)) ENGINE=$engine_type;
28 INSERT INTO t1 VALUES(1,
't1, text 1');
29 INSERT INTO t1 VALUES(2,
't1, text 2');
30 INSERT INTO t2 VALUES(1,
't2, text 1');
32 --echo ******************** DELETE ********************
33 DELETE FROM t1 WHERE a = 1;
34 DELETE FROM t2 WHERE b <> UUID();
35 --source suite/rpl/include/rpl_mixed_check_select.inc
36 --source suite/rpl/include/rpl_mixed_clear_tables.inc
40 --echo ******************** INSERT ********************
41 INSERT INTO t1 VALUES(1,
't1, text 1');
42 INSERT INTO t1 VALUES(2, UUID());
43 INSERT INTO t2 SELECT * FROM t1;
44 INSERT INTO t2 VALUES (1,
't1, text 1') ON DUPLICATE
KEY UPDATE b = 't2, text 1';
45 DELETE FROM t1 WHERE a = 2;
46 DELETE FROM t2 WHERE a = 2;
47 --source suite/rpl/include/rpl_mixed_check_select.inc
48 --source suite/rpl/include/rpl_mixed_clear_tables.inc
51 --echo ******************** LOAD DATA INFILE ********************
52 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
53 eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/std_data/rpl_mixed.dat' INTO
TABLE t1 FIELDS TERMINATED BY '|' ;
54 SELECT * FROM t1
ORDER BY a;
55 --source suite/rpl/include/rpl_mixed_check_select.inc
56 --source suite/rpl/include/rpl_mixed_clear_tables.inc
60 --echo ********************
REPLACE ********************
61 INSERT INTO t1 VALUES(1,
't1, text 1');
62 INSERT INTO t1 VALUES(2,
't1, text 2');
63 INSERT INTO t1 VALUES(3,
't1, text 3');
64 REPLACE INTO t1 VALUES(1,
't1, text 11');
65 REPLACE INTO t1 VALUES(2, UUID());
66 REPLACE INTO t1 SET a=3, b=
't1, text 33';
67 DELETE FROM t1 WHERE a = 2;
68 --source suite/rpl/include/rpl_mixed_check_select.inc
69 --source suite/rpl/include/rpl_mixed_clear_tables.inc
73 --echo ******************** SELECT ********************
74 INSERT INTO t1 VALUES(1,
't1, text 1');
75 SELECT * FROM t1 WHERE b <> UUID()
ORDER BY a;
76 --source suite/rpl/include/rpl_mixed_clear_tables.inc
80 --echo ********************
JOIN ********************
81 INSERT INTO t1 VALUES(1,
'CCC');
82 INSERT INTO t1 VALUES(2,
'DDD');
83 INSERT INTO t2 VALUES(1,
'DDD');
84 INSERT INTO t2 VALUES(2,
'CCC');
85 SELECT * FROM t1 LEFT
JOIN t2 ON t1.a = t2.a
ORDER BY t1.a,t2.a;
86 SELECT * FROM t1 INNER
JOIN t2 ON t1.b = t2.b
ORDER BY t1.a,t2.a;
87 --source suite/rpl/include/rpl_mixed_clear_tables.inc
91 --echo ******************** UNION ********************
92 INSERT INTO t1 VALUES(1,
't1, text 1');
93 INSERT INTO t2 VALUES(1,
't2, text 1');
94 SELECT * FROM t1 UNION SELECT * FROM t2 WHERE t2.b <> UUID();
95 --source suite/rpl/include/rpl_mixed_clear_tables.inc
99 --echo ******************** TRUNCATE ********************
100 INSERT INTO t1 VALUES(1,
't1, text 1');
101 --source suite/rpl/include/rpl_mixed_check_select.inc
103 --source suite/rpl/include/rpl_mixed_check_select.inc
104 --source suite/rpl/include/rpl_mixed_clear_tables.inc
108 --echo ******************** UPDATE ********************
109 INSERT INTO t1 VALUES(1,
't1, text 1');
110 INSERT INTO t2 VALUES(1,
't2, text 1');
111 UPDATE t1 SET b =
't1, text 1 updated' WHERE a = 1;
112 --source suite/rpl/include/rpl_mixed_check_select.inc
113 UPDATE t1, t2 SET t1.b =
'test', t2.b =
'test';
114 --source suite/rpl/include/rpl_mixed_check_select.inc
115 --source suite/rpl/include/rpl_mixed_clear_tables.inc
119 --echo ******************** DESCRIBE ********************
125 --echo ******************** USE ********************
130 --echo ******************** TRANSACTION ********************
132 INSERT INTO t1 VALUES (1,
'start');
134 --source suite/rpl/include/rpl_mixed_check_select.inc
136 INSERT INTO t1 VALUES (2,
'rollback');
138 --source suite/rpl/include/rpl_mixed_check_select.inc
140 INSERT INTO t1 VALUES (3,
'before savepoint s1');
142 INSERT INTO t1 VALUES (4,
'after savepoint s1');
143 ROLLBACK TO SAVEPOINT s1;
144 --source suite/rpl/include/rpl_mixed_check_select.inc
146 INSERT INTO t1 VALUES (5,
'before savepoint s2');
148 INSERT INTO t1 VALUES (6,
'after savepoint s2');
149 INSERT INTO t1 VALUES (7, CONCAT(
'with UUID() ',UUID()));
150 RELEASE SAVEPOINT s2;
152 DELETE FROM t1 WHERE a = 7;
153 --source suite/rpl/include/rpl_mixed_check_select.inc
154 --source suite/rpl/include/rpl_mixed_clear_tables.inc
158 --echo ******************** LOCK TABLES ********************
159 LOCK TABLES t1 READ , t2 READ;
162 # TRANSACTION ISOLATION LEVEL
164 --echo ******************** TRANSACTION ISOLATION LEVEL ********************
165 SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
166 SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
167 SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
168 SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
175 --echo ******************** CREATE USER ********************
176 CREATE USER
'user_test_rpl'@
'localhost' IDENTIFIED BY PASSWORD
'*1111111111111111111111111111111111111111';
177 --source suite/rpl/include/rpl_mixed_check_user.inc
181 --echo ******************** GRANT ********************
182 GRANT SELECT ON *.* TO
'user_test_rpl'@
'localhost';
183 --source suite/rpl/include/rpl_mixed_check_user.inc
187 --echo ******************** REVOKE ********************
188 REVOKE SELECT ON *.* FROM
'user_test_rpl'@
'localhost';
189 --source suite/rpl/include/rpl_mixed_check_user.inc
193 --echo ******************** SET PASSWORD ********************
194 SET PASSWORD FOR
'user_test_rpl'@
'localhost' =
'*0000000000000000000000000000000000000000';
195 --source suite/rpl/include/rpl_mixed_check_user.inc
199 --echo ******************** RENAME USER ********************
200 RENAME USER
'user_test_rpl'@
'localhost' TO
'user_test_rpl_2'@
'localhost';
201 --source suite/rpl/include/rpl_mixed_check_user.inc
205 --echo ******************** DROP USER ********************
206 DROP USER
'user_test_rpl_2'@
'localhost';
207 --source suite/rpl/include/rpl_mixed_check_user.inc
209 # Prepring for some following operations
210 INSERT INTO t1 VALUES(100,
'test');
214 --echo ******************** ANALYZE ********************
218 # skipped because deprecated
222 --echo ******************** CHECK
TABLE ********************
227 --echo ******************** CHECKSUM
TABLE ********************
232 --echo ******************** OPTIMIZE
TABLE ********************
237 --echo ******************** REPAIR
TABLE ********************
242 --echo ******************** SET VARIABLE ********************
243 SET @test_rpl_var = 1;
244 SHOW VARIABLES LIKE
'test_rpl_var';
248 --echo ******************** SHOW ********************
249 --source suite/rpl/include/rpl_mixed_check_db.inc
254 --echo ******************** PROCEDURE ********************
256 CREATE PROCEDURE p1 ()
258 UPDATE t1 SET b = '
test' WHERE a = 201;
260 CREATE PROCEDURE p2 ()
262 UPDATE t1 SET b = UUID() WHERE a = 202;
265 INSERT INTO t1 VALUES(201, '
test 201');
267 INSERT INTO t1 VALUES(202, 'test 202');
269 DELETE FROM t1 WHERE a = 202;
270 --source suite/rpl/include/rpl_mixed_check_select.inc
271 ALTER PROCEDURE p1 COMMENT 'p1';
274 --source suite/rpl/include/rpl_mixed_clear_tables.inc
278 --echo ******************** TRIGGER ********************
280 CREATE TRIGGER tr1 BEFORE INSERT ON t1
282 INSERT INTO t2 SET a =
NEW.a, b =
NEW.b;
285 INSERT INTO t1 VALUES (1,
'test');
286 --source suite/rpl/include/rpl_mixed_check_select.inc
287 --source suite/rpl/include/rpl_mixed_clear_tables.inc
293 --echo ******************** EVENTS ********************
294 GRANT EVENT ON *.* TO
'root'@
'localhost';
295 INSERT INTO t1 VALUES(1,
'test1');
296 CREATE EVENT e1 ON SCHEDULE EVERY
'1' SECOND COMMENT
'e_second_comment' DO DELETE FROM t1;
297 --source suite/rpl/include/rpl_mixed_check_event.inc
298 --source suite/rpl/include/rpl_mixed_check_select.inc
300 --source suite/rpl/include/rpl_mixed_check_select.inc
301 ALTER EVENT e1 RENAME TO e2;
303 --source suite/rpl/include/rpl_mixed_check_event.inc
304 --source suite/rpl/include/rpl_mixed_check_select.inc
306 --source suite/rpl/include/rpl_mixed_check_event.inc
307 --source suite/rpl/include/rpl_mixed_clear_tables.inc
311 --echo ******************** VIEWS ********************
312 INSERT INTO t1 VALUES(1,
'test1');
313 INSERT INTO t1 VALUES(2,
'test2');
314 CREATE VIEW v1 AS SELECT * FROM t1 WHERE a = 1;
315 CREATE VIEW v2 AS SELECT * FROM t1 WHERE b <> UUID();
316 --source suite/rpl/include/rpl_mixed_check_view.inc
317 ALTER VIEW v1 AS SELECT * FROM t1 WHERE a = 2;
318 --source suite/rpl/include/rpl_mixed_check_view.inc
321 --source suite/rpl/include/rpl_mixed_clear_tables.inc
326 --echo ******************** SHOW BINLOG EVENTS ********************
327 --source include/show_binlog_events.inc
328 sync_slave_with_master;
329 # as we're using UUID we don't SELECT but use "diff" like in rpl_row_UUID
330 --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
331 --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
334 drop database test_rpl;
335 sync_slave_with_master;
337 # Let's compare. Note: If they match test will pass, if they do not match
338 # the test will show that the diff statement failed and not reject file
339 # will be created. You will need to go to the mysql-test dir and diff
340 # the files your self to see what is not matching
342 --diff_files $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_master.sql $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_slave.sql
343 --source include/rpl_end.inc