|
| 1 | +--source include/master-slave.inc |
| 2 | +--source include/have_innodb.inc |
| 3 | +--source include/have_binlog_format_row.inc |
| 4 | + |
| 5 | +connection master; |
| 6 | +use test; |
| 7 | +create table t( col varchar(200) default 'xpchild', |
| 8 | + col1 int, |
| 9 | + col2 char(100), |
| 10 | + col3 varchar(100), |
| 11 | + key ind(col), |
| 12 | + key ind_1(col1), |
| 13 | + key ind_2(col2), |
| 14 | + key ind_3(col3))engine=innodb row_format=comfort; |
| 15 | + |
| 16 | + |
| 17 | +insert into t(col, col1, col2, col3) values('xp1', 2, 'xp', 'xpchild'); |
| 18 | +insert into t(col, col1, col2, col3) values('xp2', 2, 'xp', 'xpchild'); |
| 19 | +commit; |
| 20 | + |
| 21 | +insert into t(col1, col2, col3) select col1, col2, col3 from t; |
| 22 | +insert into t(col1, col2, col3) select col1, col2, col3 from t; |
| 23 | +insert into t(col1, col2, col3) select col1, col2, col3 from t; |
| 24 | +insert into t(col1, col2, col3) select col1, col2, col3 from t; |
| 25 | +insert into t(col1, col2, col3) select col1, col2, col3 from t; |
| 26 | +insert into t(col1, col2, col3) select col1, col2, col3 from t; |
| 27 | +insert into t(col1, col2, col3) select col1, col2, col3 from t; |
| 28 | +insert into t(col1, col2, col3) select col1, col2, col3 from t; |
| 29 | + |
| 30 | +########################################################################### |
| 31 | + |
| 32 | +select count(*) from t; |
| 33 | +checksum table t; |
| 34 | + |
| 35 | +alter table t add col4 varchar(1000); |
| 36 | +select col4 from t limit 10; |
| 37 | +checksum table t; |
| 38 | + |
| 39 | +update t set col4=concat(col3, col1); |
| 40 | +commit; |
| 41 | +select col4 from t limit 10; |
| 42 | +checksum table t; |
| 43 | + |
| 44 | +########################################################################### |
| 45 | + |
| 46 | +--echo ########################################### |
| 47 | +--echo delete and insert same record |
| 48 | +--echo ########################################### |
| 49 | +delete from t where col='xp1'; |
| 50 | +insert into t values('xp1', 2, 'xp', 'xpchild', 'xp'); |
| 51 | +commit; |
| 52 | +select * from t where col='xp1'; |
| 53 | + |
| 54 | +--echo ########################################### |
| 55 | +--echo create index on added column |
| 56 | +--echo ########################################### |
| 57 | +create index t_ind_4 on t(col4); |
| 58 | +select * from t where col4='xp'; |
| 59 | + |
| 60 | +--echo ########################################### |
| 61 | +--echo alter table add more than one column |
| 62 | +--echo ########################################### |
| 63 | +alter table t add col5 int, add col6 int; |
| 64 | +select * from t where col='xp1'; |
| 65 | + |
| 66 | +--echo ########################################### |
| 67 | +--echo alter table add clob column |
| 68 | +--echo ########################################### |
| 69 | + |
| 70 | +alter table t add col7 text; |
| 71 | +select * from t where col='xp1'; |
| 72 | + |
| 73 | +update t set col7=repeat('xpchild', 10000) where col='xp1'; |
| 74 | +commit; |
| 75 | +select * from t where col='xp1' or col ='xp2'; |
| 76 | + |
| 77 | +--echo ########################################### |
| 78 | +--echo transport tablespace |
| 79 | +--echo ########################################### |
| 80 | +--let $MYSQLD_DATADIR= `SELECT @@datadir` |
| 81 | +connect (master_1,127.0.0.1,root,,test,$MASTER_MYPORT); |
| 82 | +connect (master_2,127.0.0.1,root,,test,$MASTER_MYPORT); |
| 83 | + |
| 84 | +connection master; |
| 85 | +show create table test.t; |
| 86 | +create database db_1; |
| 87 | + |
| 88 | + |
| 89 | +connection master_1; |
| 90 | +use test; |
| 91 | +flush table t for export; |
| 92 | + |
| 93 | +connection master_2; |
| 94 | +use db_1; |
| 95 | +create table t( col varchar(200) default 'xpchild', |
| 96 | +col1 int, |
| 97 | +col2 char(100), |
| 98 | +col3 varchar(100), |
| 99 | +col4 varchar(1000) DEFAULT NULL, |
| 100 | +col5 int(11) DEFAULT NULL, |
| 101 | +col6 int(11) DEFAULT NULL, |
| 102 | +col7 text, |
| 103 | +key ind(col), |
| 104 | +key ind_1(col1), |
| 105 | +key ind_2(col2), |
| 106 | +key ind_3(col3), |
| 107 | +KEY `t_ind_4` (`col4`(767)) |
| 108 | +)engine=innodb row_format=comfort; |
| 109 | + |
| 110 | +set sql_log_bin=off; |
| 111 | +alter table t discard tablespace; |
| 112 | + |
| 113 | +--exec cp -rf $MYSQLD_DATADIR/test/t.cfg $MYSQLD_DATADIR/db_1/ |
| 114 | +--exec cp -rf $MYSQLD_DATADIR/test/t.ibd $MYSQLD_DATADIR/db_1/ |
| 115 | + |
| 116 | +alter table t import tablespace; |
| 117 | +select count(*) from t; |
| 118 | +show create table t; |
| 119 | +checksum table t; |
| 120 | + |
| 121 | +connection master_1; |
| 122 | +use test; |
| 123 | +unlock tables; |
| 124 | + |
| 125 | + |
| 126 | +connection master; |
| 127 | +checksum table db_1.t; |
| 128 | +checksum table test.t; |
| 129 | +drop table db_1.t; |
| 130 | +drop database db_1; |
| 131 | + |
| 132 | + |
| 133 | +--echo ########################################### |
| 134 | +--echo online copy data operation |
| 135 | +--echo ########################################### |
| 136 | + |
| 137 | +alter table t drop index ind_1; |
| 138 | +alter table t drop index ind_2; |
| 139 | +alter table t drop index ind_3; |
| 140 | +alter table t drop index t_ind_4; |
| 141 | + |
| 142 | +alter table t drop column col3, drop column col4, drop column col5, drop column col6, drop column col7; |
| 143 | +alter table t add col3 int default 10; |
| 144 | +alter table t row_format=compact; |
| 145 | +alter table t row_format=comfort; |
| 146 | +alter table t add col4 int; |
| 147 | +show create table t; |
| 148 | +select count(*) from t; |
| 149 | +checksum table t; |
| 150 | + |
| 151 | + |
| 152 | +--echo ########################################### |
| 153 | +--echo online dml operation |
| 154 | +--echo ########################################### |
| 155 | + |
| 156 | +connection master_1; |
| 157 | +use test; |
| 158 | +SET GLOBAL DEBUG='d,alter_table_sleep_for_online'; |
| 159 | + |
| 160 | +--send alter table t add col5 int; |
| 161 | + |
| 162 | +connection master_2; |
| 163 | +use test; |
| 164 | +insert into t(col1, col2, col3, col4) select col1, col2, col3, col4 from t; |
| 165 | +update t set col2=concat(col2, col) where col= 'xp1'; |
| 166 | +update t set col3=concat(col3, col) where col= 'xp2'; |
| 167 | +update t set col='xp3' where col= 'xp1'; |
| 168 | +select * from t where col='xp3'; |
| 169 | +delete from t where col='xp2'; |
| 170 | +commit; |
| 171 | + |
| 172 | +connection master_1; |
| 173 | +--reap |
| 174 | + |
| 175 | + |
| 176 | +connection master_1; |
| 177 | +use test; |
| 178 | +SET GLOBAL DEBUG=''; |
| 179 | +show create table t; |
| 180 | +select count(*) from t; |
| 181 | +checksum table t; |
| 182 | + |
| 183 | +insert into t(col, col1, col2, col3) values('xp1', 2, 'xp', 'xpchild'); |
| 184 | +insert into t(col, col1, col2, col3) values('xp2', 2, 'xp', 'xpchild'); |
| 185 | +commit; |
| 186 | + |
| 187 | + |
| 188 | +--echo ########################################### |
| 189 | +--echo online copy data and dml operation |
| 190 | +--echo ########################################### |
| 191 | + |
| 192 | +connection master_1; |
| 193 | +use test; |
| 194 | +SET GLOBAL DEBUG='d,alter_table_sleep_for_online'; |
| 195 | + |
| 196 | +--send alter table t add col6 int default 100; |
| 197 | + |
| 198 | +connection master_2; |
| 199 | +use test; |
| 200 | +insert into t(col1, col2, col3, col4) select col1, col2, col3, col4 from t; |
| 201 | +update t set col2=concat(col2, col) where col ='xp1'; |
| 202 | +update t set col3=concat(col3, col) where col = 'xp2'; |
| 203 | +update t set col='xp3' where col='xp1'; |
| 204 | +select * from t where col='xp2'; |
| 205 | +delete from t where col='xp2'; |
| 206 | +commit; |
| 207 | + |
| 208 | +connection master_1; |
| 209 | +--reap |
| 210 | + |
| 211 | +connection master_1; |
| 212 | +use test; |
| 213 | +SET GLOBAL DEBUG=''; |
| 214 | +show create table t; |
| 215 | +select count(*) from t; |
| 216 | +checksum table t; |
| 217 | + |
| 218 | + |
| 219 | +insert into t(col, col1, col2, col3) values('xp1', 2, 'xp', 'xpchild'); |
| 220 | +insert into t(col, col1, col2, col3) values('xp2', 2, 'xp', 'xpchild'); |
| 221 | +commit; |
| 222 | + |
| 223 | + |
| 224 | +--echo ########################################### |
| 225 | +--echo online index data and dml operation |
| 226 | +--echo ########################################### |
| 227 | + |
| 228 | +connection master_1; |
| 229 | +use test; |
| 230 | +SET GLOBAL DEBUG='d,alter_table_sleep_for_online'; |
| 231 | + |
| 232 | +--send alter table t add index ind_col4(col4); |
| 233 | + |
| 234 | +connection master_2; |
| 235 | +use test; |
| 236 | +insert into t(col1, col2, col3, col4) select col1, col2, col3, col4 from t; |
| 237 | +update t set col2=concat(col2, col) where col= 'xp1'; |
| 238 | +update t set col3=concat(col3, col) where col= 'xp2'; |
| 239 | +update t set col4=100 where col='xp2'; |
| 240 | +delete from t where col='xp2'; |
| 241 | +commit; |
| 242 | + |
| 243 | +connection master_1; |
| 244 | +--reap |
| 245 | + |
| 246 | +connection master_1; |
| 247 | +use test; |
| 248 | +SET GLOBAL DEBUG=''; |
| 249 | +show create table t; |
| 250 | +select count(*) from t; |
| 251 | +checksum table t; |
| 252 | + |
| 253 | + |
| 254 | + |
| 255 | + |
| 256 | + |
| 257 | + |
| 258 | + |
| 259 | +connection master; |
| 260 | +use test; |
| 261 | +drop table t; |
| 262 | + |
| 263 | +--sync_slave_with_master |
| 264 | +--source include/rpl_end.inc |
0 commit comments