summaryrefslogtreecommitdiff
path: root/mysql-test/suite/binlog/t/binlog_format_switch_in_tmp_table.test
blob: 6868506008c8b1a5f10fedf1b82bed24745ee4fa (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#
# Bug #45855 row events in binlog after switch from binlog_fmt=mix to stmt with open tmp tbl
# Bug #45856 can't switch from binlog_format=row to mix with open tmp tbl
# This test verfies if the program will generate ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR
# error and forbid switching @@SESSION.binlog_format from MIXED or ROW to
# STATEMENT when there are open temp tables and we are logging in row format.
# There is no error in any other case.
#

source include/have_binlog_format_mixed.inc;

SELECT @@SESSION.binlog_format;
CREATE TABLE t1 (a VARCHAR(100));
CREATE TEMPORARY TABLE t2 (a VARCHAR(100));

--echo # Test allow switching @@SESSION.binlog_format from MIXED to STATEMENT
--echo # when there are open temp tables and we are logging in statement based format.
SET SESSION binlog_format = STATEMENT;
SELECT @@SESSION.binlog_format;

--echo # Test allow switching @@SESSION.binlog_format from STATEMENT to
--echo # STATEMENT when there are open temp tables.
SET SESSION binlog_format = STATEMENT;
SELECT @@SESSION.binlog_format;

INSERT INTO t1 VALUES ('statement based');
SELECT @@SESSION.binlog_format;
--echo # Test allow switching @@SESSION.binlog_format from STATEMENT to
--echo # MIXED when there are open temp tables.
SET SESSION binlog_format = MIXED;
SELECT @@SESSION.binlog_format;

--echo # Test allow switching @@SESSION.binlog_format from MIXED to MIXED
--echo # when there are open temp tables.
SET SESSION binlog_format = MIXED;
SELECT @@SESSION.binlog_format;

INSERT INTO t2 VALUES (UUID());
SELECT @@SESSION.binlog_format;

--echo # Test forbit switching @@SESSION.binlog_format from MIXED to STATEMENT 
--echo # when there are open temp tables and we are logging in row based format.
--ERROR ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR
SET SESSION binlog_format = STATEMENT;
SELECT @@SESSION.binlog_format;

SET SESSION binlog_format = ROW;
SELECT @@SESSION.binlog_format;

INSERT INTO t1 VALUES ('row based');
--echo # Test allow switching @@SESSION.binlog_format from ROW to MIXED 
--echo # when there are open temp tables.
SET SESSION binlog_format = MIXED;
SELECT @@SESSION.binlog_format;

INSERT INTO t1 VALUES ('row based');
--echo # Test allow switching @@SESSION.binlog_format from MIXED to ROW
--echo # when there are open temp tables.
SET SESSION binlog_format = ROW;
SELECT @@SESSION.binlog_format;

--echo # Test allow switching @@SESSION.binlog_format from ROW to ROW
--echo # when there are open temp tables.
SET SESSION binlog_format = ROW;
SELECT @@SESSION.binlog_format;

INSERT INTO t1 VALUES ('row based');
--echo # Test forbit switching @@SESSION.binlog_format from ROW to STATEMENT
--echo # when there are open temp tables.
--ERROR ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR
SET SESSION binlog_format = STATEMENT;
SELECT @@SESSION.binlog_format;

DROP TEMPORARY TABLE t2;
DROP TABLE t1;