1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
|
##########################################################################
# Test script to test UPDATE on table having INSTANT ADD/DROP columns.
#
# $row_format is to be set to the row_format on which test is to be run.
##########################################################################
--eval CREATE TABLE t1 (c1 char(20), c2 char(20)) ROW_FORMAT=$row_format
INSERT INTO t1 values ("row1_c1", "row1_c2");
SHOW CREATE TABLE t1;
--let $table_name=t1
--source suite/innodb/include/print_instant_metadata.inc
--echo # ------------------------------------------------------------
--echo # ADD AN INSTANT COLUMN At the end [c1, c2, +c3]
--echo # ------------------------------------------------------------
ALTER TABLE t1 ADD COLUMN c3 char(20) default "c3_def", ALGORITHM=INSTANT;
--let $table_name=t1
--source suite/innodb/include/print_instant_metadata.inc
SELECT * FROM t1 ORDER BY c1;
INSERT INTO t1 values ("row2_c1", "row2_c2", "row2_c3");
SELECT * FROM t1 ORDER BY c1;
--echo # INPLACE UPDATE
UPDATE t1 SET c1="r1_c1" where c1="row1_c1";
SELECT * FROM t1 ORDER BY c1;
--echo # NOT INPLACE UPDATE
UPDATE t1 SET c3="row1_c3" where c1="r1_c1";
SELECT * FROM t1 ORDER BY c1;
--echo # ------------------------------------------------------------
--echo # ADD AN INSTANT COLUMN At the first [+c0, c1, c2, c3]
--echo # ------------------------------------------------------------
ALTER TABLE t1 ADD COLUMN c0 char(20) default "c0_def" FIRST, ALGORITHM=INSTANT;
--let $table_name=t1
--source suite/innodb/include/print_instant_metadata.inc
SELECT * FROM t1 ORDER BY c1;
INSERT INTO t1 values ("row3_c0", "row3_c1", "row3_c2", "row3_c3");
SELECT * FROM t1 ORDER BY c1;
--echo # INPLACE UPDATE
UPDATE t1 SET c1="r2_c1" where c1="row2_c1";
SELECT * FROM t1 ORDER BY c1;
--echo # NOT INPLACE UPDATE
UPDATE t1 SET c0="row2_c0" where c1="r2_c1";
SELECT * FROM t1 ORDER BY c1;
--echo # ------------------------------------------------------------
--echo # ADD AN INSTANT COLUMN in between [c0, c1, +c4, c2, c3]
--echo # ------------------------------------------------------------
ALTER TABLE t1 ADD COLUMN c4 char(20) default "c4_def" AFTER c1, ALGORITHM=INSTANT;
--let $table_name=t1
--source suite/innodb/include/print_instant_metadata.inc
SELECT * FROM t1 ORDER BY c1;
INSERT INTO t1 values ("row4_c0", "row4_c1", "row4_c4", "row4_c2", "row4_c3");
SELECT * FROM t1 ORDER BY c1;
--echo # INPLACE UPDATE
UPDATE t1 SET c1="r3_c1" where c1="row3_c1";
SELECT * FROM t1 ORDER BY c1;
--echo # NOT INPLACE UPDATE
UPDATE t1 SET c4="row3_c4" where c1="r3_c1";
SELECT * FROM t1 ORDER BY c1;
--echo # ------------------------------------------------------------
--echo # DROP A COLUMN in between [c0, c1, c4, -c2, c3]
--echo # ------------------------------------------------------------
ALTER TABLE t1 DROP COLUMN c2, ALGORITHM=INSTANT;
--let $table_name=t1
--source suite/innodb/include/print_instant_metadata.inc
SELECT * FROM t1 ORDER BY c1;
INSERT INTO t1 values ("row5_c0", "row5_c1", "row5_c4", "row5_c3");
SELECT * FROM t1 ORDER BY c1;
--echo # INPLACE UPDATE
UPDATE t1 SET c1="r4_c1" where c1="row4_c1";
SELECT * FROM t1 ORDER BY c1;
--echo # NOT INPLACE UPDATE
UPDATE t1 SET c4="row1_c4" where c1="r1_c1";
SELECT * FROM t1 ORDER BY c1;
--echo # ------------------------------------------------------------
--echo # DROP A COLUMN at the end [c0, c1, c4, ~c2, -c3]
--echo # ------------------------------------------------------------
ALTER TABLE t1 DROP COLUMN c3, ALGORITHM=INSTANT;
--let $table_name=t1
--source suite/innodb/include/print_instant_metadata.inc
SELECT * FROM t1 ORDER BY c1;
INSERT INTO t1 values ("row6_c0", "row6_c1", "row6_c4");
SELECT * FROM t1 ORDER BY c1;
--echo # INPLACE UPDATE
UPDATE t1 SET c1="r5_c1" where c1="row5_c1";
SELECT * FROM t1 ORDER BY c1;
--echo # NOT INPLACE UPDATE
UPDATE t1 SET c0="row1_c0" where c1="r1_c1";
SELECT * FROM t1 ORDER BY c1;
--echo # ------------------------------------------------------------
--echo # DROP A COLUMN at the beginning [-c0, c1, c4, ~c2, ~c3]
--echo # ------------------------------------------------------------
ALTER TABLE t1 DROP COLUMN c0, ALGORITHM=INSTANT;
--let $table_name=t1
--source suite/innodb/include/print_instant_metadata.inc
SELECT * FROM t1 ORDER BY c1;
INSERT INTO t1 values ("row7_c1", "row7_c4");
SELECT * FROM t1 ORDER BY c1;
--echo # INPLACE UPDATE
UPDATE t1 SET c1="r6_c1" where c1="row6_c1";
SELECT * FROM t1 ORDER BY c1;
--echo # NOT INPLACE UPDATE
UPDATE t1 SET c4="row2_c4" where c1="r2_c1";
SELECT * FROM t1 ORDER BY c1;
--echo # ------------------------------------------------------------
--echo # Rebuild table [c1, c4]
--echo # ------------------------------------------------------------
ALTER TABLE t1 FORCE;
--let $table_name=t1
--source suite/innodb/include/print_instant_metadata.inc
SELECT * FROM t1 ORDER BY c1;
INSERT INTO t1 values ("row8_c1", "row8_c4");
SELECT * FROM t1 ORDER BY c1;
if ($is_debug)
{
DROP TABLE t1;
--echo # ------------------------------------------------------------
--echo # ONLINE DDL on table having INSTANT ADD/DROP Column
--echo # ------------------------------------------------------------
--echo
--echo # ---------------------------
--echo # ONLINE DDL 1 : NO PK CHANGE
--echo # ---------------------------
--source include/count_sessions.inc
--eval CREATE TABLE t1 (c1 CHAR(10), c2 CHAR(10)) ROW_FORMAT=$row_format
INSERT INTO t1 VALUES ("r1c1", "r1c2");
SELECT * FROM t1;
ALTER TABLE t1 ADD COLUMN c0 CHAR(10) DEFAULT "def_c0" FIRST, ALGORITHM=INSTANT;
INSERT INTO t1 VALUES ("r2c0", "r2c1", "r2c2");
SELECT * FROM t1;
ALTER TABLE t1 DROP COLUMN c1, ALGORITHM=INSTANT;
INSERT INTO t1 VALUES ("r3c0", "r3c2");
SELECT * FROM t1;
--echo # Make alter table wait
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL s1 WAIT_FOR s2';
--echo # Rebuild the table
--send ALTER TABLE t1 FORCE, ALGORITHM=INPLACE
connect (con1,localhost,root,,);
--echo # connection con1
connection con1;
SET DEBUG_SYNC = 'now WAIT_FOR s1';
--echo # Insert query
INSERT INTO t1 VALUES ("r4c0", "r4c2");
--echo # Update query
--echo # (NOT INPLACE update for row1, IN-PLACE update for row2 an row3)
UPDATE t1 SET c0="c0_upd";
--echo # Let Alter table continue
SET DEBUG_SYNC = 'now SIGNAL s2';
--echo # connection default
connection default;
--reap
SELECT * FROM t1;
DISCONNECT con1;
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
DROP TABLE t1;
--echo # ---------------------------
--echo # ONLINE DDL 2 : PK CHANGE
--echo # ---------------------------
--source include/count_sessions.inc
--eval CREATE TABLE t1 (c1 CHAR(10), c2 CHAR(10)) ROW_FORMAT=$row_format
INSERT INTO t1 VALUES ("r1c1", "r1c2");
SELECT * FROM t1;
ALTER TABLE t1 ADD COLUMN c0 CHAR(10) DEFAULT "def_c0" FIRST, ALGORITHM=INSTANT;
INSERT INTO t1 VALUES ("r2c0", "r2c1", "r2c2");
SELECT * FROM t1;
ALTER TABLE t1 DROP COLUMN c1, ALGORITHM=INSTANT;
INSERT INTO t1 VALUES ("r3c0", "r3c2");
SELECT * FROM t1;
--echo # Make alter table wait
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL s1 WAIT_FOR s2';
--echo # Rebuild the table
--send ALTER TABLE t1 ADD PRIMARY KEY (c2), ALGORITHM=INPLACE
connect (con1,localhost,root,,);
--echo # connection con1
connection con1;
SET DEBUG_SYNC = 'now WAIT_FOR s1';
--echo # Insert query
INSERT INTO t1 VALUES ("r4c0", "r4c2");
--echo # Update query
--echo # (NOT INPLACE update for row1, IN-PLACE update for row2 an row3)
UPDATE t1 SET c0="c0_upd";
--echo # Let Alter table continue
SET DEBUG_SYNC = 'now SIGNAL s2';
--echo # connection default
connection default;
--reap
SELECT * FROM t1;
DISCONNECT con1;
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
DROP TABLE t1;
--echo # -----------------------
--echo # ONLINE DDL 3 :
--echo # -----------------------
--eval create table t1 (c1 char(10), c2 char(10)) ROW_FORMAT=$row_format
Insert into t1 values ("r1c1", "r1c2");
Select * from t1;
alter table t1 add column c3 char(10) default "c3_def", algorithm=instant;
Select * from t1;
Insert into t1 values ("r2c1", "r2c2", "r2c3");
Select * from t1;
Alter table t1 add column c4 char(10) default "c4_def" first, algorithm=INSTANT;
Select * from t1;
Insert into t1 values ("r3c4", "r3c1", "r3c2", "r3c3");
Select * from t1;
--echo # Make alter table wait
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL s1 WAIT_FOR s2';
--echo # Rebuild the table
--send_eval ALTER TABLE t1 force, algorithm=inplace;
connect (con1,localhost,root,,);
--echo # connection con1
connection con1;
SET DEBUG_SYNC = 'now WAIT_FOR s1';
--echo # Update query
eval UPDATE t1 SET c1="c1_upd";
--echo # Let Alter table continue
SET DEBUG_SYNC = 'now SIGNAL s2';
--echo # connection default
connection default;
--reap
SELECT * FROM t1;
DISCONNECT con1;
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
}
--echo ###########
--echo # CLEANUP #
--echo ###########
DROP TABLE t1;
|