1--source include/have_s3.inc
2--source include/have_partition.inc
3--source include/have_binlog_format_mixed.inc
4--source include/have_innodb.inc
5--source include/have_sequence.inc
6--source include/master-slave.inc
7--source create_database.inc
8
9sync_slave_with_master;
10
11if (`select @@s3_slave_ignore_updates <> 1`)
12{
13  die "Slave is not configured with s3-slave-ignore-updates=1";
14}
15
16let $MYSQLD_DATADIR= `select @@datadir`;
17--replace_result $database database
18--eval use $database
19connection master;
20
21--echo #
22--echo # Check replication of parititioned S3 tables
23--echo #
24
25CREATE TABLE t1 (
26  c1 INT DEFAULT NULL
27) ENGINE=Aria
28  PARTITION BY HASH (c1)
29  PARTITIONS 3;
30INSERT INTO t1 VALUE (1), (2), (101), (102), (201), (202);
31ALTER TABLE t1 ENGINE=S3;
32sync_slave_with_master;
33connection master;
34ALTER TABLE t1 ADD PARTITION PARTITIONS 6;
35select sum(c1) from t1;
36sync_slave_with_master;
37connection master;
38ALTER TABLE t1 ADD COLUMN c INT;
39select sum(c1) from t1;
40sync_slave_with_master;
41show create table t1;
42select sum(c1) from t1;
43connection master;
44drop table t1;
45
46--echo #
47--echo # Checking that the slave is keeping in sync with changed partitions
48--echo #
49
50CREATE TABLE t1 (
51  c1 int primary key,
52  c2 int DEFAULT NULL
53) ENGINE=InnoDB
54  PARTITION BY RANGE (c1)
55 (PARTITION p1 VALUES LESS THAN (200),
56 PARTITION p2 VALUES LESS THAN (300),
57 PARTITION p3 VALUES LESS THAN (400));
58insert into t1 select seq*100,seq*100 from seq_1_to_3;
59alter table t1 engine=S3;
60show create table t1;
61
62sync_slave_with_master;
63select sum(c1) from t1;
64--file_exists $MYSQLD_DATADIR/$database/t1.frm
65--file_exists $MYSQLD_DATADIR/$database/t1.par
66stop slave;
67connection master;
68ALTER TABLE t1 ADD PARTITION (PARTITION p4 VALUES LESS THAN (500));
69connection slave;
70show create table t1;
71select sum(c1) from t1;
72start slave;
73connection master;
74sync_slave_with_master;
75select sum(c1)+0 from t1;
76stop slave;
77
78# Ensure the slave is using the new table
79show create table t1;
80
81connection master;
82drop table t1;
83connection slave;
84--file_exists $MYSQLD_DATADIR/$database/t1.par
85--replace_result $database database
86--error ER_NO_SUCH_TABLE
87select sum(c1) from t1;
88--error 1
89--file_exists $MYSQLD_DATADIR/$database/t1.par
90start slave;
91connection master;
92sync_slave_with_master;
93connection master;
94
95--echo #
96--echo # Check altering partitioned table to S3 and back
97--echo # Checks also rename partitoned table and drop partition
98--echo #
99
100CREATE TABLE t2 (
101  c1 int primary key,
102  c2 int DEFAULT NULL
103) ENGINE=InnoDB
104  PARTITION BY RANGE (c1)
105 (PARTITION p1 VALUES LESS THAN (200),
106 PARTITION p2 VALUES LESS THAN (300),
107 PARTITION p3 VALUES LESS THAN (400));
108insert into t2 select seq*100,seq*100 from seq_1_to_3;
109alter table t2 engine=S3;
110rename table t2 to t1;
111alter table t1 drop partition p1;
112sync_slave_with_master;
113select sum(c1) from t1;
114connection master;
115alter table t1 engine=innodb;
116sync_slave_with_master;
117select sum(c1) from t1;
118connection master;
119drop table t1;
120
121--echo #
122--echo # Check that slaves ignores changes to S3 tables.
123--echo #
124
125connection master;
126CREATE TABLE t1 (
127  c1 int primary key,
128  c2 int DEFAULT NULL
129) ENGINE=InnoDB
130  PARTITION BY RANGE (c1)
131 (PARTITION p1 VALUES LESS THAN (200),
132 PARTITION p2 VALUES LESS THAN (300),
133 PARTITION p3 VALUES LESS THAN (400));
134insert into t1 select seq*100,seq*100 from seq_1_to_3;
135create table t2 like t1;
136alter table t2 remove partitioning;
137insert into t2 values (450,450);
138sync_slave_with_master;
139stop slave;
140connection master;
141alter table t1 engine=s3;
142alter table t2 engine=s3;
143ALTER TABLE t1 ADD PARTITION (PARTITION p4 VALUES LESS THAN (500));
144alter table t1 exchange partition p4 with table t2;
145select count(*) from t1;
146drop table t1,t2;
147connection slave;
148start slave;
149connection master;
150sync_slave_with_master;
151--replace_result $database database
152--error ER_NO_SUCH_TABLE
153select sum(c1) from t1;
154connection master;
155
156--echo #
157--echo # Check slave binary log
158--echo #
159
160sync_slave_with_master;
161--let $binlog_database=$database
162--source include/show_binlog_events.inc
163connection master;
164
165--echo #
166--echo # clean up
167--echo #
168--source drop_database.inc
169sync_slave_with_master;
170--source include/rpl_end.inc
171