Debian Codegraph @

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

raw
1 --source include/have_log_bin.inc
2 # Test sets its own binlog_format, so we restrict it to run only once
3 --source include/have_binlog_format_row.inc
4
5 CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
6
7 # Get rid of previous tests binlog
8 --disable_query_log
9 reset master;
10 --enable_query_log
11
12 #
13 # Bug#34306: Can't make copy of log tables when server binary log is enabled
14 #
15 # This is an additional test for Bug#34306 in order to ensure that INSERT INTO
16 # .. SELECT FROM is properly replicated under SBR and RBR and that the proper
17 # read lock type are acquired.
18 #
19
20 --disable_warnings
21 DROP TABLE IF EXISTS t1;
22 DROP TABLE IF EXISTS t2;
23 --enable_warnings
24
25 set @saved_global_binlog_format = @@global.binlog_format;
26 set @saved_local_binlog_format = @@session.binlog_format;
27 SET GLOBAL BINLOG_FORMAT = STATEMENT;
28 SET SESSION BINLOG_FORMAT = STATEMENT;
29
30 CREATE TABLE t1 (a INT);
31 CREATE TABLE t2 LIKE t1;
32 select @@SESSION.BINLOG_FORMAT;
33 INSERT INTO t1 VALUES(1);
34 INSERT INTO t2 VALUES(2);
35
36 --connect(con1,localhost,root,,)
37 --connect(con2,localhost,root,,)
38
39 --echo #
40 --echo # Ensure that INSERT INTO .. SELECT FROM under SBR takes a read
41 --echo # lock that will prevent the source table from being modified.
42 --echo #
43
44 --disable_ps2_protocol
45 --connection con1
46 SELECT GET_LOCK('Bug#34306', 120);
47 --connection con2
48 PREPARE stmt FROM "INSERT INTO t1 SELECT * FROM t2 WHERE GET_LOCK('Bug#34306', 120)";
49 --send EXECUTE stmt;
50 --connection default
51 let $wait_condition=
52 SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE
53 state = "User lock" AND
54 info = "INSERT INTO t1 SELECT * FROM t2 WHERE GET_LOCK('Bug#34306', 120)";
55 --source include/wait_condition.inc
56 --send INSERT INTO t2 VALUES (3);
57 --connection con1
58 let $wait_condition=
59 SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE
60 state = "Waiting for table level lock" and info = "INSERT INTO t2 VALUES (3)";
61 --source include/wait_condition.inc
62 SELECT RELEASE_LOCK('Bug#34306');
63 --connection con2
64 --reap
65 SELECT RELEASE_LOCK('Bug#34306');
66 --connection default
67 --reap
68
69 --echo #
70 --echo # Ensure that INSERT INTO .. SELECT FROM prepared under SBR does
71 --echo # not prevent the source table from being modified if under RBR.
72 --echo #
73
74 --connection con2
75 SET SESSION BINLOG_FORMAT = ROW;
76 --connection con1
77 SELECT GET_LOCK('Bug#34306', 120);
78 --connection con2
79 --send EXECUTE stmt;
80 --connection default
81 let $wait_condition=
82 SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE
83 state = "User lock" AND
84 info = "INSERT INTO t1 SELECT * FROM t2 WHERE GET_LOCK('Bug#34306', 120)";
85 --source include/wait_condition.inc
86 --connection con1
87 INSERT INTO t2 VALUES (4);
88 SELECT RELEASE_LOCK('Bug#34306');
89 --connection con2
90 --reap
91 --enable_ps2_protocol
92
93 --disconnect con1
94 --disconnect con2
95 --connection default
96
97 --echo # Show binlog events
98 source include/show_binlog_events.inc;
99
100 DROP TABLE t1;
101 DROP TABLE t2;
102 SET GLOBAL BINLOG_FORMAT = @saved_global_binlog_format;
103 SET SESSION BINLOG_FORMAT = @saved_local_binlog_format;