| 1 |
--source include/have_s3.inc |
| 2 |
--source include/have_sequence.inc |
| 3 |
|
| 4 |
# |
| 5 |
# Tests for S3 replication |
| 6 |
# |
| 7 |
|
| 8 |
sync_slave_with_master; |
| 9 |
let $SLAVE_DATADIR= `select @@datadir`; |
| 10 |
connection master; |
| 11 |
|
| 12 |
# |
| 13 |
# Create unique database for running the tests |
| 14 |
# |
| 15 |
--source create_database.inc |
| 16 |
|
| 17 |
--echo # |
| 18 |
--echo # Test ALTER TABLE ENGINE S3 |
| 19 |
--echo # |
| 20 |
|
| 21 |
create table t1 (a int, b int) engine=aria; |
| 22 |
insert into t1 select seq,seq+10 from seq_1_to_10; |
| 23 |
sync_slave_with_master; |
| 24 |
connection master; |
| 25 |
alter table t1 engine=s3; |
| 26 |
show create table t1; |
| 27 |
|
| 28 |
sync_slave_with_master; |
| 29 |
--replace_result $database database |
| 30 |
--eval use $database |
| 31 |
select * from t1 limit 2; |
| 32 |
--file_exists $SLAVE_DATADIR/$database/t1.frm |
| 33 |
|
| 34 |
connection master; |
| 35 |
alter table t1 add column c int; |
| 36 |
|
| 37 |
sync_slave_with_master; |
| 38 |
--error 1 |
| 39 |
--file_exists $SLAVE_DATADIR/$database/t1.frm |
| 40 |
--replace_result $database database |
| 41 |
select * from t1,t1 as t1_tmp limit 2; |
| 42 |
|
| 43 |
--echo # Now test when the .frm table is out of date on the slave |
| 44 |
stop slave; |
| 45 |
|
| 46 |
connection master; |
| 47 |
alter table t1 add column d int, engine=s3; |
| 48 |
connection slave; |
| 49 |
select * from t1 limit 2; |
| 50 |
start slave; |
| 51 |
connection master; |
| 52 |
sync_slave_with_master; |
| 53 |
select * from t1 limit 2; |
| 54 |
|
| 55 |
--echo # Same without tables in the table cache; |
| 56 |
stop slave; |
| 57 |
flush tables; |
| 58 |
connection master; |
| 59 |
alter table t1 add column e int, engine=s3; |
| 60 |
connection slave; |
| 61 |
select * from t1 limit 2; |
| 62 |
start slave; |
| 63 |
connection master; |
| 64 |
sync_slave_with_master; |
| 65 |
select * from t1 limit 2; |
| 66 |
connection master; |
| 67 |
|
| 68 |
--echo # Convert S3 table to Aria. Rows should be binary logged |
| 69 |
alter table t1 engine=aria; |
| 70 |
sync_slave_with_master; |
| 71 |
select * from t1 limit 2; |
| 72 |
show create table t1; |
| 73 |
|
| 74 |
--echo # Convert S3 table to Aria with rename. Rows should be binary logged |
| 75 |
connection master; |
| 76 |
alter table t1 engine=s3; |
| 77 |
alter table t1 rename t2, engine=aria; |
| 78 |
sync_slave_with_master; |
| 79 |
select * from t2 limit 2; |
| 80 |
show create table t2; |
| 81 |
|
| 82 |
connection master; |
| 83 |
drop table t2; |
| 84 |
sync_slave_with_master; |
| 85 |
connection master; |
| 86 |
|
| 87 |
--echo # |
| 88 |
--echo # Test RENAME |
| 89 |
--echo # |
| 90 |
|
| 91 |
create table t1 (a int, b int) engine=aria; |
| 92 |
insert into t1 select seq,seq+10 from seq_1_to_10; |
| 93 |
alter table t1 engine=s3; |
| 94 |
|
| 95 |
rename table t1 to t2; |
| 96 |
sync_slave_with_master; |
| 97 |
--replace_result $database database |
| 98 |
--error 1 |
| 99 |
--file_exists $SLAVE_DATADIR/$database/t2.frm |
| 100 |
--error ER_NO_SUCH_TABLE |
| 101 |
select * from t1 limit 2; |
| 102 |
select * from t2 limit 2; |
| 103 |
connection master; |
| 104 |
|
| 105 |
alter table t2 add column f int, rename t1; |
| 106 |
select * from t1 limit 2; |
| 107 |
sync_slave_with_master; |
| 108 |
--error 1 |
| 109 |
--file_exists $SLAVE_DATADIR/$database/t1.frm |
| 110 |
--error 1 |
| 111 |
--file_exists $SLAVE_DATADIR/$database/t2.frm |
| 112 |
select * from t1 limit 2; |
| 113 |
--replace_result $database database |
| 114 |
--error ER_NO_SUCH_TABLE |
| 115 |
select * from t2 limit 2; |
| 116 |
|
| 117 |
# Check rename of table when a new table has replaced the original one |
| 118 |
|
| 119 |
connection slave; |
| 120 |
stop slave; |
| 121 |
connection master; |
| 122 |
rename table t1 to t2; |
| 123 |
# Check the different create options with the table |
| 124 |
create table t1 (a int) engine=aria; |
| 125 |
drop table t1; |
| 126 |
create table if not exists t1 (a int, b int) engine=aria; |
| 127 |
drop table t1; |
| 128 |
create or replace table t1 (a int, b int, c int) engine=aria; |
| 129 |
alter table t1 engine=s3; |
| 130 |
connection slave; |
| 131 |
start slave; |
| 132 |
connection master; |
| 133 |
sync_slave_with_master; |
| 134 |
show create table t1; |
| 135 |
select * from t1 limit 2; |
| 136 |
select * from t2 limit 2; |
| 137 |
connection master; |
| 138 |
|
| 139 |
--echo # |
| 140 |
--echo # Test DROP |
| 141 |
--echo # |
| 142 |
drop table t1,t2; |
| 143 |
|
| 144 |
sync_slave_with_master; |
| 145 |
--error 1 |
| 146 |
--file_exists $SLAVE_DATADIR/$database/t1.frm |
| 147 |
--error 1 |
| 148 |
--file_exists $SLAVE_DATADIR/$database/t2.frm |
| 149 |
--replace_result $database database |
| 150 |
--error ER_NO_SUCH_TABLE |
| 151 |
select * from t1 limit 2; |
| 152 |
--replace_result $database database |
| 153 |
--error ER_NO_SUCH_TABLE |
| 154 |
select * from t2 limit 2; |
| 155 |
|
| 156 |
connection master; |
| 157 |
|
| 158 |
--echo # |
| 159 |
--echo # Test LIKE |
| 160 |
--echo # |
| 161 |
|
| 162 |
create table t1 (a int,b int); |
| 163 |
alter table t1 engine=s3; |
| 164 |
--replace_result $database database |
| 165 |
--error ER_CANT_CREATE_TABLE |
| 166 |
create table t2 like t1; |
| 167 |
sync_slave_with_master; |
| 168 |
--replace_result $database database |
| 169 |
--error ER_NO_SUCH_TABLE |
| 170 |
show create table t2; |
| 171 |
connection master; |
| 172 |
--replace_result $database database |
| 173 |
drop table if exists t1,t2; |
| 174 |
|
| 175 |
--echo # |
| 176 |
--echo # Check slave binary log |
| 177 |
--echo # |
| 178 |
|
| 179 |
sync_slave_with_master; |
| 180 |
--let $binlog_database=$database |
| 181 |
--source include/show_binlog_events.inc |
| 182 |
connection master; |
| 183 |
|
| 184 |
--echo # |
| 185 |
--echo # MDEV-24351: S3, same-backend replication: Dropping a table on master |
| 186 |
--echo # causes error on slave |
| 187 |
--echo # |
| 188 |
show variables like 's3_replicate_alter_as_create_select'; |
| 189 |
|
| 190 |
connection slave; |
| 191 |
create table t3 (a int, b int) engine=aria; |
| 192 |
insert into t3 values (1,1),(2,2),(3,3); |
| 193 |
alter table t3 engine=s3; |
| 194 |
|
| 195 |
connection master; |
| 196 |
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1); |
| 197 |
drop table t3; |
| 198 |
--echo # Must show "DROP TABLE IF EXISTS t3", not just "DROP TABLE t3" |
| 199 |
--source include/show_binlog_events.inc |
| 200 |
|
| 201 |
sync_slave_with_master; |
| 202 |
connection master; |
| 203 |
|
| 204 |
--echo # |
| 205 |
--echo # clean up |
| 206 |
--echo # |
| 207 |
--source drop_database.inc |
| 208 |
sync_slave_with_master; |
| 209 |
--source include/rpl_end.inc |