1
# Testing table creations for row-based replication.
3
--source include/have_binlog_format_row.inc
4
--source include/master-slave.inc
5
--source include/have_innodb.inc
7
--source include/have_innodb.inc
10
# Bug#18326: Do not lock table for writing during prepare of statement
11
# The use of the ps protocol causes extra table maps in the binlog, so
12
# we disable the ps-protocol for this statement.
17
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9;
21
# Set the default storage engine to different values on master and
22
# slave. We need to stop the slave for the server variable to take
23
# effect, since the variable is only read on start-up.
24
sync_slave_with_master;
26
set @storage_engine = @@global.storage_engine;
28
SET GLOBAL storage_engine=memory;
33
CREATE TABLE t1 (a INT, b INT);
34
CREATE TABLE t2 (a INT, b INT) ENGINE=Merge;
35
CREATE TABLE t3 (a INT, b INT) CHARSET=utf8;
36
CREATE TABLE t4 (a INT, b INT) ENGINE=Merge CHARSET=utf8;
37
--replace_column 1 # 4 #
38
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
39
--query_vertical SHOW BINLOG EVENTS FROM 217
40
--echo **** On Master ****
41
--query_vertical SHOW CREATE TABLE t1
42
--query_vertical SHOW CREATE TABLE t2
43
--query_vertical SHOW CREATE TABLE t3
44
sync_slave_with_master;
45
--echo **** On Slave ****
46
--query_vertical SHOW CREATE TABLE t1
47
--query_vertical SHOW CREATE TABLE t2
48
--query_vertical SHOW CREATE TABLE t3
51
CREATE TABLE t5 (b INT, c INT) SELECT * FROM t3;
53
CREATE TEMPORARY TABLE tt3 (a INT, b INT);
54
INSERT INTO tt3 VALUES (1,2), (2,4), (3,6), (4,2), (5,10), (6,12);
55
CREATE TABLE t6 (b INT, c INT) SELECT * FROM tt3;
56
--echo **** On Master ****
57
--query_vertical SHOW CREATE TABLE t5
58
SELECT * FROM t5 ORDER BY a,b,c;
59
--query_vertical SHOW CREATE TABLE t6
60
SELECT * FROM t6 ORDER BY a,b,c;
61
sync_slave_with_master;
62
--echo **** On Slave ****
63
--query_vertical SHOW CREATE TABLE t5
64
SELECT * FROM t5 ORDER BY a,b,c;
65
--query_vertical SHOW CREATE TABLE t6
66
SELECT * FROM t6 ORDER BY a,b,c;
69
# Test for erroneous constructions
71
CREATE TABLE t7 (UNIQUE(b)) SELECT a,b FROM tt3;
72
# Shouldn't be written to the binary log
73
--replace_column 1 # 4 #
74
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
75
SHOW BINLOG EVENTS FROM 1375;
77
# Test that INSERT-SELECT works the same way as for SBR.
78
CREATE TABLE t7 (a INT, b INT UNIQUE);
80
INSERT INTO t7 SELECT a,b FROM tt3;
81
SELECT * FROM t7 ORDER BY a,b;
82
# Should be written to the binary log
83
--replace_column 1 # 4 #
84
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
85
SHOW BINLOG EVENTS FROM 1375;
86
sync_slave_with_master;
87
SELECT * FROM t7 ORDER BY a,b;
90
CREATE TEMPORARY TABLE tt4 (a INT, b INT);
91
INSERT INTO tt4 VALUES (4,8), (5,10), (6,12);
93
INSERT INTO t7 SELECT a,b FROM tt4;
95
--replace_column 1 # 4 #
96
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
97
SHOW BINLOG EVENTS FROM 1712;
98
SELECT * FROM t7 ORDER BY a,b;
99
sync_slave_with_master;
100
SELECT * FROM t7 ORDER BY a,b;
103
CREATE TABLE t8 LIKE t4;
104
CREATE TABLE t9 LIKE tt4;
105
CREATE TEMPORARY TABLE tt5 LIKE t4;
106
CREATE TEMPORARY TABLE tt6 LIKE tt4;
107
CREATE TEMPORARY TABLE tt7 SELECT 1;
108
--echo **** On Master ****
109
--query_vertical SHOW CREATE TABLE t8
110
--query_vertical SHOW CREATE TABLE t9
111
--replace_column 1 # 4 #
112
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
113
SHOW BINLOG EVENTS FROM 1947;
114
sync_slave_with_master;
115
--echo **** On Slave ****
116
--query_vertical SHOW CREATE TABLE t8
117
--query_vertical SHOW CREATE TABLE t9
120
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9;
121
sync_slave_with_master;
122
# Here we reset the value of the default storage engine
124
SET GLOBAL storage_engine=@storage_engine;
128
# BUG#22864 (Rollback following CREATE ... SELECT discards 'CREATE
130
--echo ================ BUG#22864 ================
140
CREATE TABLE t1 (a INT);
141
INSERT INTO t1 VALUES (1),(2),(3);
143
CREATE TABLE t2 ENGINE=INNODB SELECT * FROM t1;
146
CREATE TABLE t3 ENGINE=INNODB SELECT * FROM t1;
147
INSERT INTO t3 VALUES (4),(5),(6);
150
CREATE TABLE t4 ENGINE=INNODB SELECT * FROM t1;
151
INSERT INTO t1 VALUES (4),(5),(6);
155
SELECT TABLE_NAME,ENGINE
156
FROM INFORMATION_SCHEMA.TABLES
157
WHERE TABLE_NAME LIKE 't_'
159
SELECT * FROM t1 ORDER BY a;
160
SELECT * FROM t2 ORDER BY a;
161
SELECT * FROM t3 ORDER BY a;
162
SELECT * FROM t4 ORDER BY a;
163
--replace_column 1 # 4 #
164
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/
166
sync_slave_with_master;
168
SELECT TABLE_NAME,ENGINE
169
FROM INFORMATION_SCHEMA.TABLES
170
WHERE TABLE_NAME LIKE 't_'
172
SELECT * FROM t1 ORDER BY a;
173
SELECT * FROM t2 ORDER BY a;
174
SELECT * FROM t3 ORDER BY a;
175
SELECT * FROM t4 ORDER BY a;
178
DROP TABLE IF EXISTS t1,t2,t3,t4;
180
sync_slave_with_master;
182
# Some tests with temporary tables
194
CREATE TABLE t1 (a INT);
195
INSERT INTO t1 VALUES (1),(2),(3);
197
CREATE TABLE t2 (a INT) ENGINE=INNODB;
200
INSERT INTO t2 SELECT a*a FROM t1;
201
CREATE TEMPORARY TABLE tt1
205
INSERT INTO t2 SELECT a+2 FROM tt1;
208
SELECT * FROM t2 ORDER BY a;
209
--replace_column 1 # 4 #
210
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/
212
sync_slave_with_master;
213
SELECT * FROM t2 ORDER BY a;
219
INSERT INTO t2 SELECT a*a FROM t1;
220
CREATE TEMPORARY TABLE tt2
224
INSERT INTO t2 SELECT a+2 FROM tt2;
227
SELECT * FROM t2 ORDER BY a;
228
--replace_column 1 # 4 #
229
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/
230
SHOW BINLOG EVENTS FROM 950;
231
sync_slave_with_master;
232
SELECT * FROM t2 ORDER BY a;
236
sync_slave_with_master;