summaryrefslogtreecommitdiff
path: root/mysql-test/suite/rpl/t/rpl_create_or_replace_fail.test
blob: 8624d3c9f1b6906a9f4255cd2a45652bc3dfc6fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# ==== Purpose ====
#
# Test verifies that failed CREATE OR REPLACE TEMPORARY TABLE statement which
# dropped the table but failed at a later stage of creation of temporary table
# is written to binarylog in row based replication.
#
# ==== Implementation ====
#
# Steps:
#    0 - Have mixed based replication mode.
#    1 - Create a temporary table. It will be replicated as mixed replication
#        mode is in use.
#    2 - Execute an unsafe statement which will switch current statement
#        binlog format to 'ROW'. i.e If binlog_format=MIXED, there are open
#        temporary tables, and an unsafe statement is executed, then subsequent
#        statements are logged in row format.
#    3 - Execute a CREATE OR REPLACE TEMPORARY TABLE statement which tries to
#        create partitions on temporary table. Since it is not supported it will
#        fail.
#    4 - Check the binary log output to ensure that the failed statement is
#        written to the binary log.
#    5 - Slave should be up and running and in sync with master.
#
# ==== References ====
#
# MDEV-18930: Failed CREATE OR REPLACE TEMPORARY not written into binary log
# makes data on master and slave diverge
#

--source include/have_partition.inc
--source include/have_binlog_format_mixed.inc
--source include/master-slave.inc

CREATE TEMPORARY TABLE t1 (a INT NOT NULL);

# Execute an unsafe statement which switches replication mode internally from
# "STATEMENT" to "ROW".
--error ER_NO_SUCH_TABLE
LOAD DATA INFILE 'x' INTO TABLE x;

--error ER_FEATURE_NOT_SUPPORTED_WITH_PARTITIONING
CREATE OR REPLACE TEMPORARY TABLE t1 (x INT) PARTITION BY HASH(x);

--echo "************** DROP TEMPORARY TABLE Should be present in Binary log **************"
--source include/show_binlog_events.inc

CREATE TABLE t1 (b INT);
INSERT INTO t1 VALUES (NULL);
--sync_slave_with_master

# Cleanup
--connection master
DROP TABLE t1;

--source include/rpl_end.inc