Debian Codegraph @

mysql-test/suite/rpl/t/rpl_temp_table.test

raw
1 # drop table t1 t2 t3 are included int master-slave.inc
2 # meaningful only in statement-based:
3
4 -- source include/have_binlog_format_mixed_or_statement.inc
5 -- source include/master-slave.inc
6
7 --disable_query_log
8 CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
9 --enable_query_log
10
11 create table t2 (n int, PRIMARY KEY(n));
12 create temporary table t1 (n int);
13 create temporary table t3 (n int not null);
14
15 insert into t1 values(1),(2),(3),(100),(25),(26),(200),(300);
16 --disable_warnings
17 insert into t2 select * from t1;
18 --enable_warnings
19 alter table t3 add primary key(n);
20
21 flush logs;
22 insert into t3 values (1010);
23 --disable_warnings
24 insert into t2 select * from t3;
25 --enable_warnings
26
27 drop table if exists t3;
28 insert into t2 values (1012);
29
30 connection master1;
31 create temporary table t1 (n int);
32 insert into t1 values (4),(5);
33 --disable_warnings
34 insert into t2 select * from t1;
35 --enable_warnings
36
37 save_master_pos;
38 disconnect master;
39
40 connection slave;
41 #add 1 to the saved position, so we will catch drop table on disconnect
42 #for sure
43 sync_with_master 1;
44
45 connection master1;
46 insert into t2 values(61);
47
48 save_master_pos;
49 disconnect master1;
50
51 connection slave;
52 #same trick - make sure we catch drop of temporary table on disconnect
53 sync_with_master 1;
54
55 select * from t2;
56 select count(*) from t2;
57 select sum(n) from t2;
58 show status like 'Slave_open_temp_tables';
59
60 --echo *** MDEV-8016: Replication aborts on DROP /*!40005 TEMPORARY */ TABLE IF EXISTS ***
61 connect (master2,localhost,root,,);
62 INSERT INTO t2 VALUES (2000), (2001);
63 CREATE FUNCTION f() RETURNS INTEGER RETURN 1;
64 CREATE TEMPORARY TABLE t3 AS SELECT f() AS col FROM t2;
65 --let $gtid=`SELECT @@gtid_binlog_pos`
66 --disconnect master2
67 --connection default
68 # Wait for implicit DROP TEMPORARY TABLE tmp to be binlogged.
69 --let $wait_condition= SELECT @@gtid_binlog_pos != '$gtid'
70 --source include/wait_condition.inc
71
72 --sync_slave_with_master
73
74
75 #
76 # Clean up
77 #
78 connect (master2,localhost,root,,);
79 connection master2;
80 drop table if exists t1,t2;
81 drop function f;
82 sync_slave_with_master;
83
84
85 --source include/rpl_end.inc