1stop slave;
2drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
3reset master;
4reset slave;
5drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
6start slave;
7CREATE TABLE t4 (
8id INT(5) unsigned NOT NULL auto_increment,
9name varchar(15) NOT NULL default '',
10number varchar(35) NOT NULL default 'default',
11PRIMARY KEY  (id),
12UNIQUE KEY unique_rec (name,number)
13) ENGINE=TokuDB;
14LOAD DATA
15INFILE '../../std_data/loaddata_pair.dat'
16REPLACE INTO TABLE t4
17(name,number);
18SELECT * FROM t4;
19id	name	number
201	XXX	12345
212	XXY	12345
22SELECT * FROM t4;
23id	name	number
241	XXX	12345
252	XXY	12345
26LOAD DATA
27INFILE '../../std_data/loaddata_pair.dat'
28REPLACE INTO TABLE t4
29(name,number);
30SELECT * FROM t4;
31id	name	number
324	XXX	12345
335	XXY	12345
34SELECT * FROM t4;
35id	name	number
364	XXX	12345
375	XXY	12345
38FLUSH LOGS;
39FLUSH LOGS;
40DROP DATABASE IF EXISTS mysqltest1;
41CREATE DATABASE mysqltest1;
42CREATE TEMPORARY TABLE mysqltest1.tmp (f1 BIGINT);
43CREATE TABLE mysqltest1.t1 (f1 BIGINT) ENGINE="TokuDB";
44SET AUTOCOMMIT = 0;
45-------- switch to slave --------
46ALTER TABLE mysqltest1.t1 ENGINE = MyISAM;
47SHOW CREATE TABLE mysqltest1.t1;
48Table	Create Table
49t1	CREATE TABLE `t1` (
50  `f1` bigint(20) DEFAULT NULL
51) ENGINE=MyISAM DEFAULT CHARSET=latin1
52-------- switch to master --------
53INSERT INTO mysqltest1.t1 SET f1= 1;
54DROP TEMPORARY TABLE mysqltest1.tmp;
55ROLLBACK;
56SHOW CREATE TABLE mysqltest1.tmp;
57ERROR 42S02: Table 'mysqltest1.tmp' doesn't exist
58######### Must return no rows here #########
59SELECT COUNT(*) FROM mysqltest1.t1;
60COUNT(*)
610
62INSERT INTO mysqltest1.t1 SET f1= 2;
63CREATE TEMPORARY TABLE mysqltest1.tmp2(a INT);
64ROLLBACK;
65SHOW CREATE TABLE mysqltest1.tmp2;
66Table	Create Table
67tmp2	CREATE TEMPORARY TABLE `tmp2` (
68  `a` int(11) DEFAULT NULL
69) ENGINE=MyISAM DEFAULT CHARSET=latin1
70######### Must return no rows here #########
71SELECT COUNT(*) FROM mysqltest1.t1;
72COUNT(*)
730
74-------- switch to slave --------
75SHOW CREATE TABLE mysqltest1.tmp;
76ERROR 42S02: Table 'mysqltest1.tmp' doesn't exist
77SHOW CREATE TABLE mysqltest1.tmp2;
78ERROR 42S02: Table 'mysqltest1.tmp2' doesn't exist
79######### t1 has two rows here: the transaction not rolled back since t1 uses MyISAM  #########
80SELECT COUNT(*) FROM mysqltest1.t1;
81COUNT(*)
822
83FLUSH LOGS;
84-------- switch to master --------
85FLUSH LOGS;
86DROP DATABASE mysqltest1;
87End of 5.1 tests
88#
89# Bug#39675 rename tables on innodb tables with pending
90# transactions causes slave data issue.
91#
92DROP TABLE IF EXISTS t1;
93DROP TABLE IF EXISTS t2;
94DROP TABLE IF EXISTS t3;
95CREATE TABLE t1 (
96id INT PRIMARY KEY auto_increment,
97b INT DEFAULT NULL
98) ENGINE=TokuDB;
99CREATE TABLE t2 (
100id INT PRIMARY KEY auto_increment,
101b INT DEFAULT NULL
102) ENGINE=TokuDB;
103INSERT INTO t1 (b) VALUES (1),(2),(3);
104BEGIN;
105INSERT INTO t1(b) VALUES (4);
106-------- switch to master1 --------
107RENAME TABLE t1 TO t3, t2 TO t1;;
108-------- switch to master --------
109COMMIT;
110-------- switch to master1 --------
111-------- switch to master --------
112SELECT * FROM t1;
113id	b
114SELECT * FROM t3;
115id	b
1161	1
1172	2
1183	3
1194	4
120-------- switch to slave --------
121SELECT * FROM t1;
122id	b
123SELECT * FROM t3;
124id	b
1251	1
1262	2
1273	3
1284	4
129-------- switch to master --------
130DROP TABLE t1;
131DROP TABLE t3;
132End of 6.0 tests
133