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 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544
|
--echo #
--echo # Bug#30128418: IMPORT TABLESPACE MUST CHECK DESCENDING INDEX DEFINITION
--echo #
--source include/have_debug.inc
# Test the implementation of InnoDB export CFG version 4 (IB_EXPORT_CFG_VERSION_V4).
# It shows what happens when a sort order of a key on a secondary index
# may or may not differ from the file being imported and what happens when the
# imported CFG file is using an old version which does not know about sort order.
--let $MYSQLD_DATADIR=`select @@datadir`
--let $DB = `SELECT DATABASE()`
--echo ###
--echo ### EXPORT #1: Backup Ascending key IBD and v3 CFG
--echo ###
--echo # Create a table with a normal ascending secondary key and export it.
CREATE TABLE t1 (a int, b int, PRIMARY KEY (a), KEY (b));
INSERT INTO t1 VALUES (1, 1);
INSERT INTO t1 VALUES (2, 2);
--sorted_result
SELECT * FROM t1;
SELECT * FROM t1 order by a;
SELECT * FROM t1 order by b;
SHOW CREATE TABLE t1;
--echo # Export the table using IB_EXPORT_CFG_VERSION_V3,
--echo # which does not export the DESC flag.
SET GLOBAL DEBUG='+d,ib_export_use_cfg_version_3';
FLUSH TABLES t1 FOR EXPORT;
SET GLOBAL DEBUG='-d,ib_export_use_cfg_version_3';
--echo # Back-up the IBD and the v3 CFG file
--copy_file $MYSQLD_DATADIR/$DB/t1.ibd $MYSQLD_DATADIR/$DB/t1.ibd.ascend
--copy_file $MYSQLD_DATADIR/$DB/t1.cfg $MYSQLD_DATADIR/$DB/t1.cfg.ascend.v3
--echo # Unlock the table, which deletes the CFG file.
UNLOCK TABLES;
--echo ###
--echo ### EXPORT #2: Backup v4 CFG for Ascending key IBD
--echo ###
--echo # Export the table using IB_EXPORT_CFG_VERSION_V4,
--echo # which will export the DESC flag on the secondary index.
FLUSH TABLES t1 FOR EXPORT;
--echo # Back-up the v4 CFG file
--copy_file $MYSQLD_DATADIR/$DB/t1.cfg $MYSQLD_DATADIR/$DB/t1.cfg.ascend.v4
UNLOCK TABLES;
DROP TABLE t1;
--echo ###
--echo ### EXPORT #3: Backup Descending key IBD and v3 CFG
--echo ###
--echo # Create a table with a descending secondary key and export it.
CREATE TABLE t1 (a int, b int, PRIMARY KEY (a), KEY (b DESC));
INSERT INTO t1 VALUES (1, 1);
INSERT INTO t1 VALUES (2, 2);
--sorted_result
SELECT * FROM t1;
SELECT * FROM t1 order by a;
SELECT * FROM t1 order by b;
SHOW CREATE TABLE t1;
--echo # Export the table using IB_EXPORT_CFG_VERSION_V3,
--echo # which does not export the DESC flag.
SET GLOBAL DEBUG='+d,ib_export_use_cfg_version_3';
FLUSH TABLES t1 FOR EXPORT;
SET GLOBAL DEBUG='-d,ib_export_use_cfg_version_3';
--echo # Back-up the IBD and the v3 CFG file
--copy_file $MYSQLD_DATADIR/$DB/t1.ibd $MYSQLD_DATADIR/$DB/t1.ibd.descend
--copy_file $MYSQLD_DATADIR/$DB/t1.cfg $MYSQLD_DATADIR/$DB/t1.cfg.descend.v3
--echo # Unlock the table, which deletes the CFG file.
UNLOCK TABLES;
--echo ###
--echo ### EXPORT #4: Backup v4 CFG for Descending key IBD
--echo ###
--echo # Export the table using IB_EXPORT_CFG_VERSION_V4,
--echo # which will export the DESC flag on the secondary index.
FLUSH TABLES t1 FOR EXPORT;
--echo # Back-up the v4 CFG with the descending key.
--copy_file $MYSQLD_DATADIR/$DB/t1.cfg $MYSQLD_DATADIR/$DB/t1.cfg.descend.v4
--echo # Unlock the table, which deletes the cfg file.
UNLOCK TABLES;
--echo ###
--echo ### EXPORT #5: Backup with a future version 99 CFG
--echo ###
--echo # Export the table using a future version IB_EXPORT_CFG_VERSION_V99,
SET GLOBAL DEBUG='+d,ib_export_use_cfg_version_99';
FLUSH TABLES t1 FOR EXPORT;
SET GLOBAL DEBUG='-d,ib_export_use_cfg_version_99';
--echo # Back-up the v99 CFG with the descending key.
--copy_file $MYSQLD_DATADIR/$DB/t1.cfg $MYSQLD_DATADIR/$DB/t1.cfg.descend.v99
--echo # Unlock the table, which deletes the cfg file.
UNLOCK TABLES;
--echo ###
--echo ### IMPORT TEST #1: Ascending key IBD and v3 CFG to Discarded Ascending Key IBD
--echo ###
--echo # Recreate the table without the DESC attribute on the secondary key.
DROP TABLE t1;
CREATE TABLE t1 (a int, b int, PRIMARY KEY (a), KEY (b));
SHOW CREATE TABLE t1;
--echo # Discard the table which deletes the IBD file.
ALTER TABLE t1 DISCARD TABLESPACE;
--echo # Restore the ascending key IBD and the v3 version of the CFG.
--copy_file $MYSQLD_DATADIR/$DB/t1.ibd.ascend $MYSQLD_DATADIR/$DB/t1.ibd
--copy_file $MYSQLD_DATADIR/$DB/t1.cfg.ascend.v3 $MYSQLD_DATADIR/$DB/t1.cfg
--echo # Import the table. Since both the discarded IBD and the imported
--echo # IBD match, the import succeeds.
ALTER TABLE t1 IMPORT TABLESPACE;
--echo # Show that column b is sorted correctly.
--sorted_result
SELECT * FROM t1;
SELECT * FROM t1 order by a;
SELECT * FROM t1 order by b;
INSERT INTO t1 VALUES (3, 3);
INSERT INTO t1 VALUES (4, 4);
--sorted_result
SELECT * FROM t1;
SELECT * FROM t1 order by a;
SELECT * FROM t1 order by b;
DROP TABLE t1;
--echo ###
--echo ### IMPORT TEST #2: Ascending key IBD and v4 CFG to Discarded Ascending Key IBD
--echo ###
--echo # Recreate the table without the DESC attribute on the secondary key.
CREATE TABLE t1 (a int, b int, PRIMARY KEY (a), KEY (b));
SHOW CREATE TABLE t1;
--echo # Discard the table which deletes the IBD file.
ALTER TABLE t1 DISCARD TABLESPACE;
--echo # Restore the ascending key IBD and the v4 version of the CFG.
--copy_file $MYSQLD_DATADIR/$DB/t1.ibd.ascend $MYSQLD_DATADIR/$DB/t1.ibd
--copy_file $MYSQLD_DATADIR/$DB/t1.cfg.ascend.v4 $MYSQLD_DATADIR/$DB/t1.cfg
--echo # Import the table. Since both the discarded IBD and the imported
--echo # IBD match, the import succeeds.
ALTER TABLE t1 IMPORT TABLESPACE;
--echo # Show that column b is sorted correctly.
--sorted_result
SELECT * FROM t1;
SELECT * FROM t1 order by a;
SELECT * FROM t1 order by b;
INSERT INTO t1 VALUES (3, 3);
INSERT INTO t1 VALUES (4, 4);
--sorted_result
SELECT * FROM t1;
SELECT * FROM t1 order by a;
SELECT * FROM t1 order by b;
DROP TABLE t1;
--echo ###
--echo ### IMPORT TEST #3: Ascending key IBD and v3 CFG to Discarded Descending Key IBD
--echo ###
--echo # Recreate the table with the DESC attribute on the secondary key.
CREATE TABLE t1 (a int, b int, PRIMARY KEY (a), KEY (b DESC));
SHOW CREATE TABLE t1;
--echo # Discard the table which deletes the IBD file.
ALTER TABLE t1 DISCARD TABLESPACE;
--echo # Restore the ascending key IBD and the v3 version of the CFG.
--copy_file $MYSQLD_DATADIR/$DB/t1.ibd.ascend $MYSQLD_DATADIR/$DB/t1.ibd
--copy_file $MYSQLD_DATADIR/$DB/t1.cfg.ascend.v3 $MYSQLD_DATADIR/$DB/t1.cfg
--echo # Attempt to import the table. Since the DESC flag is not available in the
--echo # CFG file, we assume it is ascending, which is different from the exported
--echo # table. The error message will complain about Index b field b.
--echo # The import will abort and delete the cfg file.
--error ER_TABLE_SCHEMA_MISMATCH
ALTER TABLE t1 IMPORT TABLESPACE;
DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/$DB/t1.ibd
--echo ###
--echo ### IMPORT TEST #4 Ascending key IBD and v4 CFG to Discarded Descending Key IBD
--echo ###
--echo # Recreate the table with the DESC attribute on the secondary key.
CREATE TABLE t1 (a int, b int, PRIMARY KEY (a), KEY (b DESC));
SHOW CREATE TABLE t1;
--echo # Discard the table which deletes the IBD file.
ALTER TABLE t1 DISCARD TABLESPACE;
--echo # Restore the ascending key IBD and the v4 version of the CFG.
--copy_file $MYSQLD_DATADIR/$DB/t1.ibd.ascend $MYSQLD_DATADIR/$DB/t1.ibd
--copy_file $MYSQLD_DATADIR/$DB/t1.cfg.ascend.v4 $MYSQLD_DATADIR/$DB/t1.cfg
--echo # Attempt to import the table. Since the DESC flag if the discarded table
--echo # is different from the exported table, the error message will complain about
--echo # Index b field b. The import will abort and delete the cfg file.
--error ER_TABLE_SCHEMA_MISMATCH
ALTER TABLE t1 IMPORT TABLESPACE;
DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/$DB/t1.ibd
--echo ###
--echo ### IMPORT TEST #5: Descending key IBD and v3 CFG to Discarded Ascending Key IBD
--echo ###
--echo # Recreate the table without the DESC attribute on the secondary key.
CREATE TABLE t1 (a int, b int, PRIMARY KEY (a), KEY (b));
SHOW CREATE TABLE t1;
--echo # Discard the table which deletes the IBD file.
ALTER TABLE t1 DISCARD TABLESPACE;
--echo # Restore the descending key IBD and the v3 version of the CFG.
--copy_file $MYSQLD_DATADIR/$DB/t1.ibd.descend $MYSQLD_DATADIR/$DB/t1.ibd
--copy_file $MYSQLD_DATADIR/$DB/t1.cfg.descend.v3 $MYSQLD_DATADIR/$DB/t1.cfg
--disable_query_log
call mtr.add_suppression("\\[InnoDB\\] Records in wrong order on space [0-9]*");
call mtr.add_suppression("\\[InnoDB\\] Apparent corruption in space [0-9]*");
call mtr.add_suppression("\\[InnoDB\\] In page [0-9]* of index `b` of table");
--enable_query_log
--echo # Attempt to import the table. Since the DESC flag is not available in the
--echo # CFG file, we assume it is ascending, which matches the exported table.
--echo # So the import succeeds, but the sort order of the keys in the imported
--echo # file is descending and all new keys will be ascending.
ALTER TABLE t1 IMPORT TABLESPACE;
--echo # Show that the index is corrupt
SHOW WARNINGS;
CHECK TABLE t1 EXTENDED;
--echo # Fix the corruption
OPTIMIZE TABLE t1;
--echo # Show that the index is no longer corrupt
CHECK TABLE t1 EXTENDED;
--echo # Show that column b is sorted consistently.
--sorted_result
SELECT * FROM t1;
SELECT * FROM t1 order by a;
--skip_if_hypergraph # Does not use the index leading to the error.
SELECT * FROM t1 order by b;
INSERT INTO t1 VALUES (3, 3);
INSERT INTO t1 VALUES (4, 4);
--sorted_result
SELECT * FROM t1;
SELECT * FROM t1 order by a;
--skip_if_hypergraph # Does not use the index leading to the error.
SELECT * FROM t1 order by b;
DROP TABLE t1;
--echo ###
--echo ### IMPORT TEST #6: Descending key IBD and v4 CFG to Discarded Ascending Key IBD
--echo ###
--echo # Recreate the table without the DESC attribute on the secondary key.
CREATE TABLE t1 (a int, b int, PRIMARY KEY (a), KEY (b));
SHOW CREATE TABLE t1;
--echo # Discard the table which deletes the IBD file.
ALTER TABLE t1 DISCARD TABLESPACE;
--echo # Restore the descending key IBD and the v4 version of the CFG.
--copy_file $MYSQLD_DATADIR/$DB/t1.ibd.descend $MYSQLD_DATADIR/$DB/t1.ibd
--copy_file $MYSQLD_DATADIR/$DB/t1.cfg.descend.v4 $MYSQLD_DATADIR/$DB/t1.cfg
--echo # Attempt to import the table. Since the DESC flag if the discarded table
--echo # is different from the exported table, the error message will complain about
--echo # column b in index b. The import will abort and delete the cfg file.
--error ER_TABLE_SCHEMA_MISMATCH
ALTER TABLE t1 IMPORT TABLESPACE;
DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/$DB/t1.ibd
--echo ###
--echo ### IMPORT TEST #7: Descending key IBD and v3 CFG to Discarded Descending Key IBD
--echo ###
--echo # Recreate the table with the DESC attribute on the secondary key.
CREATE TABLE t1 (a int, b int, PRIMARY KEY (a), KEY (b DESC));
SHOW CREATE TABLE t1;
--echo # Discard the table which deletes the IBD file.
ALTER TABLE t1 DISCARD TABLESPACE;
--echo # Restore the descending key IBD and the v3 version of the CFG.
--copy_file $MYSQLD_DATADIR/$DB/t1.ibd.descend $MYSQLD_DATADIR/$DB/t1.ibd
--copy_file $MYSQLD_DATADIR/$DB/t1.cfg.descend.v3 $MYSQLD_DATADIR/$DB/t1.cfg
--echo # Attempt to import the table. Since the DESC flag is not available in the
--echo # CFG file, we wrongly assume it is ascending. Since this is different from
--echo # the exported table, the error message will complain about column b in index b.
--error ER_TABLE_SCHEMA_MISMATCH
ALTER TABLE t1 IMPORT TABLESPACE;
DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/$DB/t1.ibd
--echo ###
--echo ### IMPORT TEST #8: Descending key IBD and v4 CFG to Discarded Descending Key IBD
--echo ###
--echo # Recreate the table with the DESC attribute on the secondary key.
CREATE TABLE t1 (a int, b int, PRIMARY KEY (a), KEY (b DESC));
SHOW CREATE TABLE t1;
--echo # Discard the table which deletes the IBD file.
ALTER TABLE t1 DISCARD TABLESPACE;
--echo # Restore the descending key IBD and the v4 version of the CFG.
--copy_file $MYSQLD_DATADIR/$DB/t1.ibd.descend $MYSQLD_DATADIR/$DB/t1.ibd
--copy_file $MYSQLD_DATADIR/$DB/t1.cfg.descend.v4 $MYSQLD_DATADIR/$DB/t1.cfg
--echo # Import the table successfuly.
ALTER TABLE t1 IMPORT TABLESPACE;
--echo # Show that column b is descending.
--sorted_result
SELECT * FROM t1;
SELECT * FROM t1 order by a;
SELECT * FROM t1 order by b;
INSERT INTO t1 VALUES (3, 3);
INSERT INTO t1 VALUES (4, 4);
--sorted_result
SELECT * FROM t1;
SELECT * FROM t1 order by a;
SELECT * FROM t1 order by b;
--echo ###
--echo ### IMPORT TEST #9: Any unknown version will be rejected with a clear error message.
--echo ###
--echo # Discard the table which deletes the IBD file.
ALTER TABLE t1 DISCARD TABLESPACE;
--echo # Restore the descending key IBD and the v99 version of the CFG.
--copy_file $MYSQLD_DATADIR/$DB/t1.ibd.descend $MYSQLD_DATADIR/$DB/t1.ibd
--copy_file $MYSQLD_DATADIR/$DB/t1.cfg.descend.v99 $MYSQLD_DATADIR/$DB/t1.cfg
--echo # Attempt to import the table.
--error ER_IMP_INCOMPATIBLE_CFG_VERSION
ALTER TABLE t1 IMPORT TABLESPACE;
SHOW WARNINGS;
--remove_file $MYSQLD_DATADIR/$DB/t1.ibd
--remove_file $MYSQLD_DATADIR/$DB/t1.cfg
--echo # Cleanup
DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/$DB/t1.ibd.ascend
--remove_file $MYSQLD_DATADIR/$DB/t1.ibd.descend
--remove_file $MYSQLD_DATADIR/$DB/t1.cfg.ascend.v3
--remove_file $MYSQLD_DATADIR/$DB/t1.cfg.ascend.v4
--remove_file $MYSQLD_DATADIR/$DB/t1.cfg.descend.v3
--remove_file $MYSQLD_DATADIR/$DB/t1.cfg.descend.v4
--remove_file $MYSQLD_DATADIR/$DB/t1.cfg.descend.v99
--echo #
--echo # Bug#30191523 : FLUSH TABLE T FOR EXPORT OR ALTER TABLE T2 IMPORT
--echo # TABLESPACE BROKEN IN 8.0.17.
--echo #
--echo # ---------------------- Test 1 ----------------------------------
--echo # Source table has INSTANT columns but target table doesn't
--echo # ----------------------------------------------------------------
--echo # Create source table t1 and add a column INSTANTly
CREATE TABLE t1(id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY);
ALTER TABLE t1 ADD COLUMN v1 VARCHAR(255), ALGORITHM=INSTANT;
ALTER TABLE t1 ADD COLUMN v2 VARCHAR(255), ALGORITHM=INSTANT;
--echo # Insert some data into t1
--disable_query_log
let $i=1000;
while ($i)
{
INSERT INTO t1(v1, v2) VALUES ("aaaaaaaaaaaaa", "bbbbbbbbbbbbbb");
dec $i;
}
--enable_query_log
SELECT * from t1 limit 10;
SELECT COUNT(*) from t1;
SELECT NAME, N_COLS, INSTANT_COLS FROM INFORMATION_SCHEMA.INNODB_TABLES WHERE NAME="test/t1";
SELECT NAME, POS, HAS_DEFAULT from information_Schema.innodb_columns WHERE NAME='v1' OR NAME='v2';
--echo # Flush the table and store CFG/IBD files to temp
FLUSH TABLE t1 FOR EXPORT;
--copy_file $MYSQLD_DATADIR/test/t1.cfg $MYSQLD_DATADIR/t1.cfg_back
--copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_DATADIR/t1.ibd_back
UNLOCK TABLES;
--echo # Create table t2 without INSTANTly added columns
CREATE TABLE t2 LIKE t1;
ALTER TABLE t2 DISCARD TABLESPACE;
--echo # Copy CFG/IBD file from temp
--copy_file $MYSQLD_DATADIR/t1.cfg_back $MYSQLD_DATADIR/test/t2.cfg
--copy_file $MYSQLD_DATADIR/t1.ibd_back $MYSQLD_DATADIR/test/t2.ibd
--echo # IMPORT should succeed. Target table metadata should have been updated.
ALTER TABLE t2 IMPORT TABLESPACE;
SELECT * from t2 limit 10;
SELECT COUNT(*) from t2;
SELECT NAME, N_COLS, INSTANT_COLS FROM INFORMATION_SCHEMA.INNODB_TABLES WHERE NAME="test/t1" OR NAME="test/t2";
SELECT NAME, POS, HAS_DEFAULT from information_Schema.innodb_columns WHERE NAME='v1' OR NAME='v2';
DROP TABLE t2;
--echo # Create table t2 with one column added INSTANTly
CREATE TABLE t2(id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, v1 VARCHAR(255));
ALTER TABLE t2 ADD COLUMN v2 VARCHAR(255), ALGORITHM=INSTANT;
ALTER TABLE t2 DISCARD TABLESPACE;
--echo # Copy CFG/IBD file from temp
--copy_file $MYSQLD_DATADIR/t1.cfg_back $MYSQLD_DATADIR/test/t2.cfg
--copy_file $MYSQLD_DATADIR/t1.ibd_back $MYSQLD_DATADIR/test/t2.ibd
--echo # IMPORT should fail as INSTANT METADATA doesn't match.
--error ER_TABLE_SCHEMA_MISMATCH
ALTER TABLE t2 IMPORT TABLESPACE;
DROP TABLE t2;
--remove_file $MYSQLD_DATADIR/test/t2.cfg
--remove_file $MYSQLD_DATADIR/test/t2.ibd
--echo # Create table t2 with two column added INSTANTly
CREATE TABLE t2(id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY);
ALTER TABLE t2 ADD COLUMN v1 VARCHAR(255), ALGORITHM=INSTANT;
ALTER TABLE t2 ADD COLUMN v2 VARCHAR(255), ALGORITHM=INSTANT;
ALTER TABLE t2 DISCARD TABLESPACE;
--echo # Copy CFG/IBD file from temp
--copy_file $MYSQLD_DATADIR/t1.cfg_back $MYSQLD_DATADIR/test/t2.cfg
--copy_file $MYSQLD_DATADIR/t1.ibd_back $MYSQLD_DATADIR/test/t2.ibd
--echo # IMPORT should succeed.
ALTER TABLE t2 IMPORT TABLESPACE;
SELECT * from t2 limit 10;
SELECT COUNT(*) from t2;
SELECT NAME, N_COLS, INSTANT_COLS FROM INFORMATION_SCHEMA.INNODB_TABLES WHERE NAME="test/t1" OR NAME="test/t2";
SELECT NAME, POS, HAS_DEFAULT from information_Schema.innodb_columns WHERE NAME='v1' OR NAME='v2';
DROP TABLE t2;
DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/t1.cfg_back
--remove_file $MYSQLD_DATADIR/t1.ibd_back
--echo # ---------------------- Test 2 ----------------------------------
--echo # Source table doesn't have INSTANT columns but target table does
--echo # ----------------------------------------------------------------
--echo # Create source table t1 and add a column INSTANTly
CREATE TABLE t1(id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, v1 VARCHAR(255), v2 VARCHAR(255));
--echo # Insert some data into t1
--disable_query_log
let $i=1000;
while ($i)
{
INSERT INTO t1(v1, v2) VALUES ("aaaaaaaaaaaaa", "bbbbbbbbbbbbbb");
dec $i;
}
--enable_query_log
SELECT * from t1 limit 10;
SELECT COUNT(*) from t1;
SELECT NAME, N_COLS, INSTANT_COLS FROM INFORMATION_SCHEMA.INNODB_TABLES WHERE NAME="test/t1";
SELECT NAME, POS, HAS_DEFAULT from information_Schema.innodb_columns WHERE NAME='v1' OR NAME='v2';
--echo # Flush the table and store CFG/IBD files to temp
FLUSH TABLE t1 FOR EXPORT;
--copy_file $MYSQLD_DATADIR/test/t1.cfg $MYSQLD_DATADIR/t1.cfg_back
--copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_DATADIR/t1.ibd_back
UNLOCK TABLES;
--echo # Create table t2 with no INSTANTly added columns
CREATE TABLE t2(id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, v1 VARCHAR(255), v2 VARCHAR(255));
ALTER TABLE t2 DISCARD TABLESPACE;
--echo # Copy CFG/IBD file from temp
--copy_file $MYSQLD_DATADIR/t1.cfg_back $MYSQLD_DATADIR/test/t2.cfg
--copy_file $MYSQLD_DATADIR/t1.ibd_back $MYSQLD_DATADIR/test/t2.ibd
--echo # IMPORT should succeed.
ALTER TABLE t2 IMPORT TABLESPACE;
DROP TABLE t2;
--echo # Create table t2 with 1 INSTANTly added columns
CREATE TABLE t2(id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, v1 VARCHAR(255));
ALTER TABLE t2 ADD COLUMN v2 VARCHAR(255), ALGORITHM=INSTANT;
ALTER TABLE t2 DISCARD TABLESPACE;
--echo # Copy CFG/IBD file from temp
--copy_file $MYSQLD_DATADIR/t1.cfg_back $MYSQLD_DATADIR/test/t2.cfg
--copy_file $MYSQLD_DATADIR/t1.ibd_back $MYSQLD_DATADIR/test/t2.ibd
--echo # IMPORT should fail.
--error ER_TABLE_SCHEMA_MISMATCH
ALTER TABLE t2 IMPORT TABLESPACE;
DROP TABLE t2;
--remove_file $MYSQLD_DATADIR/test/t2.cfg
--remove_file $MYSQLD_DATADIR/test/t2.ibd
--echo # Create table t2 with 2 INSTANTly added columns
CREATE TABLE t2(id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY);
ALTER TABLE t2 ADD COLUMN v1 VARCHAR(255), ALGORITHM=INSTANT;
ALTER TABLE t2 ADD COLUMN v2 VARCHAR(255), ALGORITHM=INSTANT;
ALTER TABLE t2 DISCARD TABLESPACE;
--echo # Copy CFG/IBD file from temp
--copy_file $MYSQLD_DATADIR/t1.cfg_back $MYSQLD_DATADIR/test/t2.cfg
--copy_file $MYSQLD_DATADIR/t1.ibd_back $MYSQLD_DATADIR/test/t2.ibd
--echo # IMPORT should fail.
--error ER_TABLE_SCHEMA_MISMATCH
ALTER TABLE t2 IMPORT TABLESPACE;
DROP TABLE t2;
--remove_file $MYSQLD_DATADIR/test/t2.cfg
--remove_file $MYSQLD_DATADIR/test/t2.ibd
--echo # Cleanup
DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/t1.cfg_back
--remove_file $MYSQLD_DATADIR/t1.ibd_back
|