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 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584
|
#
# ALLOW IN-PLACE DDL OPERATIONS ON MISSING AND/OR DISCARDED TABLESPACES
#
SET GLOBAL innodb_file_per_table=1;
CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT, INDEX(c2));
INSERT INTO t1 VALUES (1, 1, 'one'), (2, 2, 'two'), (3, 3, 'three');
CREATE TABLE t2 (c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT, INDEX(c2));
INSERT INTO t2 VALUES (1, 1, 'one'), (2, 2, 'two'), (3, 3, 'three');
CREATE TABLE t3 (c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT, INDEX(c2));
INSERT INTO t3 VALUES (1, 1, 'one'), (2, 2, 'two'), (3, 3, 'three');
CREATE TABLE t4 (c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT, INDEX(c2));
INSERT INTO t4 VALUES (1, 1, 'one'), (2, 2, 'two'), (3, 3, 'three');
# Check also with tables having special characters
CREATE TABLE `t_.._a` (c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT, INDEX(c2));
INSERT INTO `t_.._a` VALUES (1, 1, 'one'), (2, 2, 'two'), (3, 3, 'three');
CREATE TABLE `t_.._b` (c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT, INDEX(c2));
INSERT INTO `t_.._b` VALUES (1, 1, 'one'), (2, 2, 'two'), (3, 3, 'three');
#
# Remove and Discard tablespaces
#
# restart
ALTER TABLE t3 DISCARD TABLESPACE;
ALTER TABLE t4 DISCARD TABLESPACE;
ALTER TABLE `t_.._b` DISCARD TABLESPACE;
#
# SELECT * FROM __
#
SELECT * FROM t1;
ERROR HY000: Tablespace is missing for table `test`.`t1`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t1.
Error 1812 Tablespace is missing for table `test`.`t1`.
SELECT * FROM t2;
ERROR HY000: Tablespace is missing for table `test`.`t2`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t2.
Error 1812 Tablespace is missing for table `test`.`t2`.
SELECT * FROM t3;
ERROR HY000: Tablespace has been discarded for table 't3'
SHOW WARNINGS;
Level Code Message
Error 1814 Tablespace has been discarded for table 't3'
Error 1146 Table 'test.t3' doesn't exist
SELECT * FROM t4;
ERROR HY000: Tablespace has been discarded for table 't4'
SHOW WARNINGS;
Level Code Message
Error 1814 Tablespace has been discarded for table 't4'
Error 1146 Table 'test.t4' doesn't exist
SELECT * FROM `t_.._a`;
ERROR HY000: Tablespace is missing for table `test`.`t_.._a`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t_@002e@002e_a.
Error 1812 Tablespace is missing for table `test`.`t_.._a`.
SELECT * FROM `t_.._b`;
ERROR HY000: Tablespace has been discarded for table 't_.._b'
SHOW WARNINGS;
Level Code Message
Error 1814 Tablespace has been discarded for table 't_.._b'
Error 1146 Table 'test.t_.._b' doesn't exist
#
# ALTER TABLE __ TABLESPACE innodb_system
#
ALTER TABLE t1 TABLESPACE innodb_system, ALGORITHM=INPLACE;
ERROR HY000: Tablespace is missing for table `test`.`t1`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t1.
Error 1812 Tablespace is missing for table `test`.`t1`.
ALTER TABLE t2 TABLESPACE innodb_system, ALGORITHM=COPY;
ERROR HY000: Tablespace is missing for table `test`.`t2`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t2.
Error 1812 Tablespace is missing for table `test`.`t2`.
ALTER TABLE t3 TABLESPACE innodb_system, ALGORITHM=INPLACE;
ERROR HY000: Tablespace has been discarded for table 'test/t3'
SHOW WARNINGS;
Level Code Message
Error 1814 Tablespace has been discarded for table 'test/t3'
ALTER TABLE t4 TABLESPACE innodb_system, ALGORITHM=COPY;
ERROR HY000: Tablespace has been discarded for table 't4'
SHOW WARNINGS;
Level Code Message
Error 1814 Tablespace has been discarded for table 't4'
Error 1146 Table 'test.t4' doesn't exist
#
# ALTER TABLE __ TABLESPACE ts1
#
CREATE TABLESPACE ts1 ADD DATAFILE 'ts1.ibd';
ALTER TABLE t1 TABLESPACE ts1, ALGORITHM=INPLACE;
ERROR HY000: Tablespace is missing for table `test`.`t1`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t1.
Error 1812 Tablespace is missing for table `test`.`t1`.
ALTER TABLE t2 TABLESPACE ts1, ALGORITHM=COPY;
ERROR HY000: Tablespace is missing for table `test`.`t2`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t2.
Error 1812 Tablespace is missing for table `test`.`t2`.
ALTER TABLE t3 TABLESPACE ts1, ALGORITHM=INPLACE;
ERROR HY000: Tablespace has been discarded for table 'test/t3'
SHOW WARNINGS;
Level Code Message
Error 1814 Tablespace has been discarded for table 'test/t3'
ALTER TABLE t4 TABLESPACE ts1, ALGORITHM=COPY;
ERROR HY000: Tablespace has been discarded for table 't4'
SHOW WARNINGS;
Level Code Message
Error 1814 Tablespace has been discarded for table 't4'
Error 1146 Table 'test.t4' doesn't exist
#
# ALTER TABLE __ ADD INDEX
#
ALTER TABLE t1 ADD INDEX (a), ALGORITHM=INPLACE;
ERROR HY000: Tablespace is missing for table `test`.`t1`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t1.
Error 1812 Tablespace is missing for table `test`.`t1`.
ALTER TABLE t2 ADD INDEX (a), ALGORITHM=COPY;
ERROR HY000: Tablespace is missing for table `test`.`t2`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t2.
Error 1812 Tablespace is missing for table `test`.`t2`.
ALTER TABLE t3 ADD INDEX (a), ALGORITHM=INPLACE;
ERROR 42000: Key column 'a' doesn't exist in table
SHOW WARNINGS;
Level Code Message
Error 1072 Key column 'a' doesn't exist in table
ALTER TABLE t4 ADD INDEX (a), ALGORITHM=COPY;
ERROR 42000: Key column 'a' doesn't exist in table
SHOW WARNINGS;
Level Code Message
Error 1072 Key column 'a' doesn't exist in table
#
# ALTER TABLE __ DROP INDEX
#
ALTER TABLE t1 DROP INDEX c2, ALGORITHM=INPLACE;
ERROR HY000: Tablespace is missing for table `test`.`t1`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t1.
Error 1812 Tablespace is missing for table `test`.`t1`.
ALTER TABLE t2 DROP INDEX c2, ALGORITHM=COPY;
ERROR HY000: Tablespace is missing for table `test`.`t2`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t2.
Error 1812 Tablespace is missing for table `test`.`t2`.
ALTER TABLE t3 DROP INDEX c2, ALGORITHM=INPLACE;
Warnings:
Warning 1814 InnoDB: Tablespace has been discarded for table 't3'
ALTER TABLE t4 DROP INDEX c2, ALGORITHM=COPY;
ERROR HY000: Tablespace has been discarded for table 't4'
SHOW WARNINGS;
Level Code Message
Error 1814 Tablespace has been discarded for table 't4'
Error 1146 Table 'test.t4' doesn't exist
#
# ALTER TABLE __ ADD COLUMN
#
ALTER TABLE t1 ADD COLUMN c3 INT, ALGORITHM=INPLACE;
ERROR HY000: Tablespace is missing for table `test`.`t1`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t1.
Error 1812 Tablespace is missing for table `test`.`t1`.
ALTER TABLE t2 ADD COLUMN c3 INT, ALGORITHM=COPY;
ERROR HY000: Tablespace is missing for table `test`.`t2`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t2.
Error 1812 Tablespace is missing for table `test`.`t2`.
ALTER TABLE t3 ADD COLUMN c3 INT, ALGORITHM=INPLACE;
ERROR HY000: Tablespace has been discarded for table 'test/t3'
SHOW WARNINGS;
Level Code Message
Error 1814 Tablespace has been discarded for table 'test/t3'
ALTER TABLE t4 ADD COLUMN c3 INT, ALGORITHM=COPY;
ERROR HY000: Tablespace has been discarded for table 't4'
SHOW WARNINGS;
Level Code Message
Error 1814 Tablespace has been discarded for table 't4'
Error 1146 Table 'test.t4' doesn't exist
#
# ALTER TABLE __ DROP COLUMN
#
ALTER TABLE t1 DROP COLUMN ct, ALGORITHM=INPLACE;
ERROR HY000: Tablespace is missing for table `test`.`t1`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t1.
Error 1812 Tablespace is missing for table `test`.`t1`.
ALTER TABLE t2 DROP COLUMN ct, ALGORITHM=COPY;
ERROR HY000: Tablespace is missing for table `test`.`t2`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t2.
Error 1812 Tablespace is missing for table `test`.`t2`.
ALTER TABLE t3 DROP COLUMN ct, ALGORITHM=INPLACE;
ERROR HY000: Tablespace has been discarded for table 'test/t3'
SHOW WARNINGS;
Level Code Message
Error 1814 Tablespace has been discarded for table 'test/t3'
ALTER TABLE t4 DROP COLUMN ct, ALGORITHM=COPY;
ERROR HY000: Tablespace has been discarded for table 't4'
SHOW WARNINGS;
Level Code Message
Error 1814 Tablespace has been discarded for table 't4'
Error 1146 Table 'test.t4' doesn't exist
#
# ALTER TABLE __ ALTER c2 DROP DEFAULT
#
ALTER TABLE t1 ALTER c2 DROP DEFAULT, ALGORITHM=INPLACE;
ERROR HY000: Tablespace is missing for table `test`.`t1`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t1.
Error 1812 Tablespace is missing for table `test`.`t1`.
ALTER TABLE t2 ALTER c2 DROP DEFAULT, ALGORITHM=COPY;
ERROR HY000: Tablespace is missing for table `test`.`t2`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t2.
Error 1812 Tablespace is missing for table `test`.`t2`.
ALTER TABLE t3 ALTER c2 DROP DEFAULT, ALGORITHM=INPLACE;
Warnings:
Warning 1814 InnoDB: Tablespace has been discarded for table 't3'
ALTER TABLE t4 ALTER c2 DROP DEFAULT, ALGORITHM=COPY;
ERROR HY000: Tablespace has been discarded for table 't4'
SHOW WARNINGS;
Level Code Message
Error 1814 Tablespace has been discarded for table 't4'
Error 1146 Table 'test.t4' doesn't exist
#
# ALTER TABLE __ ALTER c2 SET DEFAULT 42
#
ALTER TABLE t1 ALTER c2 SET DEFAULT 42, ALGORITHM=INPLACE;
ERROR HY000: Tablespace is missing for table `test`.`t1`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t1.
Error 1812 Tablespace is missing for table `test`.`t1`.
ALTER TABLE t2 ALTER c2 SET DEFAULT 42, ALGORITHM=COPY;
ERROR HY000: Tablespace is missing for table `test`.`t2`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t2.
Error 1812 Tablespace is missing for table `test`.`t2`.
ALTER TABLE t3 ALTER c2 SET DEFAULT 42, ALGORITHM=INPLACE;
Warnings:
Warning 1814 InnoDB: Tablespace has been discarded for table 't3'
ALTER TABLE t4 ALTER c2 SET DEFAULT 42, ALGORITHM=COPY;
ERROR HY000: Tablespace has been discarded for table 't4'
SHOW WARNINGS;
Level Code Message
Error 1814 Tablespace has been discarded for table 't4'
Error 1146 Table 'test.t4' doesn't exist
#
# ALTER TABLE __ ADD FULLTEXT INDEX
#
ALTER TABLE t1 ADD FULLTEXT INDEX (ct), ALGORITHM=INPLACE;
ERROR HY000: Tablespace is missing for table `test`.`t1`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t1.
Error 1812 Tablespace is missing for table `test`.`t1`.
ALTER TABLE t2 ADD FULLTEXT INDEX (ct), ALGORITHM=COPY;
ERROR HY000: Tablespace is missing for table `test`.`t2`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t2.
Error 1812 Tablespace is missing for table `test`.`t2`.
ALTER TABLE t3 ADD FULLTEXT INDEX (ct), ALGORITHM=INPLACE;
Warnings:
Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID
Warning 1814 InnoDB: Tablespace has been discarded for table 't3'
ALTER TABLE t4 ADD FULLTEXT INDEX (ct), ALGORITHM=COPY;
ERROR HY000: Tablespace has been discarded for table 't4'
SHOW WARNINGS;
Level Code Message
Error 1814 Tablespace has been discarded for table 't4'
Error 1146 Table 'test.t4' doesn't exist
#
# ALTER TABLE __ CHANGE c2 c2 INT AFTER c1
#
ALTER TABLE t1 CHANGE c2 c2 INT AFTER c1, ALGORITHM=INPLACE;
ERROR HY000: Tablespace is missing for table `test`.`t1`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t1.
Error 1812 Tablespace is missing for table `test`.`t1`.
ALTER TABLE t2 CHANGE c2 c2 INT AFTER c1, ALGORITHM=COPY;
ERROR HY000: Tablespace is missing for table `test`.`t2`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t2.
Error 1812 Tablespace is missing for table `test`.`t2`.
ALTER TABLE t3 CHANGE c2 c2 INT AFTER c1, ALGORITHM=INPLACE;
Warnings:
Warning 1814 InnoDB: Tablespace has been discarded for table 't3'
ALTER TABLE t4 CHANGE c2 c2 INT AFTER c1, ALGORITHM=COPY;
ERROR HY000: Tablespace has been discarded for table 't4'
SHOW WARNINGS;
Level Code Message
Error 1814 Tablespace has been discarded for table 't4'
Error 1146 Table 'test.t4' doesn't exist
#
# ALTER TABLE __ CHANGE c1 c1 INT FIRST
#
ALTER TABLE t1 CHANGE c1 c1 INT FIRST, ALGORITHM=INPLACE;
ERROR HY000: Tablespace is missing for table `test`.`t1`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t1.
Error 1812 Tablespace is missing for table `test`.`t1`.
ALTER TABLE t2 CHANGE c1 c1 INT FIRST, ALGORITHM=COPY;
ERROR HY000: Tablespace is missing for table `test`.`t2`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t2.
Error 1812 Tablespace is missing for table `test`.`t2`.
ALTER TABLE t3 CHANGE c1 c1 INT FIRST, ALGORITHM=INPLACE;
Warnings:
Warning 1814 InnoDB: Tablespace has been discarded for table 't3'
ALTER TABLE t4 CHANGE c1 c1 INT FIRST, ALGORITHM=COPY;
ERROR HY000: Tablespace has been discarded for table 't4'
SHOW WARNINGS;
Level Code Message
Error 1814 Tablespace has been discarded for table 't4'
Error 1146 Table 'test.t4' doesn't exist
#
# ALTER TABLE __ CHANGE c2 c3 INT
#
ALTER TABLE t1 CHANGE c2 c3 INT, ALGORITHM=INPLACE;
ERROR HY000: Tablespace is missing for table `test`.`t1`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t1.
Error 1812 Tablespace is missing for table `test`.`t1`.
ALTER TABLE t2 CHANGE c2 c3 INT, ALGORITHM=COPY;
ERROR HY000: Tablespace is missing for table `test`.`t2`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t2.
Error 1812 Tablespace is missing for table `test`.`t2`.
ALTER TABLE t3 CHANGE c2 c3 INT, ALGORITHM=INPLACE;
Warnings:
Warning 1814 InnoDB: Tablespace has been discarded for table 't3'
ALTER TABLE t4 CHANGE c2 c3 INT, ALGORITHM=COPY;
ERROR HY000: Tablespace has been discarded for table 't4'
SHOW WARNINGS;
Level Code Message
Error 1814 Tablespace has been discarded for table 't4'
Error 1146 Table 'test.t4' doesn't exist
#
# ALTER TABLE __ ROW_FORMAT=REDUNDANT
#
ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE;
ERROR HY000: Tablespace is missing for table `test`.`t1`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t1.
Error 1812 Tablespace is missing for table `test`.`t1`.
ALTER TABLE t2 ROW_FORMAT=REDUNDANT, ALGORITHM=COPY;
ERROR HY000: Tablespace is missing for table `test`.`t2`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t2.
Error 1812 Tablespace is missing for table `test`.`t2`.
ALTER TABLE t3 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY.
SHOW WARNINGS;
Level Code Message
Error 1846 ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY.
ALTER TABLE t4 ROW_FORMAT=REDUNDANT, ALGORITHM=COPY;
ERROR HY000: Tablespace has been discarded for table 't4'
SHOW WARNINGS;
Level Code Message
Error 1814 Tablespace has been discarded for table 't4'
Error 1146 Table 'test.t4' doesn't exist
#
# ALTER TABLE __ RENAME TO __
#
ALTER TABLE t1 RENAME TO t11, ALGORITHM=INPLACE;
ERROR HY000: Tablespace is missing for table `test`.`t1`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t1.
Error 1812 Tablespace is missing for table `test`.`t1`.
ALTER TABLE t2 RENAME TO t22, ALGORITHM=COPY;
ERROR HY000: Tablespace is missing for table `test`.`t2`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t2.
Error 1812 Tablespace is missing for table `test`.`t2`.
ALTER TABLE t3 RENAME TO t33, ALGORITHM=INPLACE;
ALTER TABLE t33 RENAME TO t3, ALGORITHM=INPLACE;
Warnings:
Warning 1814 InnoDB: Tablespace has been discarded for table 't33'
ALTER TABLE t4 RENAME TO t44, ALGORITHM=COPY;
ERROR HY000: Tablespace has been discarded for table 't4'
SHOW WARNINGS;
Level Code Message
Error 1814 Tablespace has been discarded for table 't4'
Error 1146 Table 'test.t4' doesn't exist
#
# DISCARD an already missing tablespace;
#
ALTER TABLE t1 DISCARD TABLESPACE;
Warnings:
Warning 1812 InnoDB: Tablespace is missing for table test/t1.
Warning 1812 InnoDB: Tablespace is missing for table test/t1.
#
# Show the resultant tables before dropping them
#
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int NOT NULL,
`c2` int DEFAULT '1',
`ct` text,
PRIMARY KEY (`c1`),
KEY `c2` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
SHOW CREATE TABLE t2;
ERROR HY000: Tablespace is missing for table `test`.`t2`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t2.
Error 1812 Tablespace is missing for table `test`.`t2`.
SHOW CREATE TABLE t3;
Table Create Table
t3 CREATE TABLE `t3` (
`c1` int NOT NULL,
`c3` int DEFAULT NULL,
`ct` text,
PRIMARY KEY (`c1`),
FULLTEXT KEY `ct` (`ct`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
Warnings:
Warning 1814 InnoDB: Tablespace has been discarded for table 't3'
SHOW CREATE TABLE t4;
Table Create Table
t4 CREATE TABLE `t4` (
`c1` int NOT NULL,
`c2` int DEFAULT '1',
`ct` text,
PRIMARY KEY (`c1`),
KEY `c2` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
SHOW CREATE TABLE `t_.._a`;
ERROR HY000: Tablespace is missing for table `test`.`t_.._a`.
SHOW WARNINGS;
Level Code Message
Warning 1812 InnoDB: Tablespace is missing for table test/t_@002e@002e_a.
Error 1812 Tablespace is missing for table `test`.`t_.._a`.
SHOW CREATE TABLE `t_.._b`;
Table Create Table
t_.._b CREATE TABLE `t_.._b` (
`c1` int NOT NULL,
`c2` int DEFAULT '1',
`ct` text,
PRIMARY KEY (`c1`),
KEY `c2` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
#
# DROP TABLE __ while mising or discarded
#
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
DROP TABLE t4;
DROP TABLE `t_.._a`;
DROP TABLE `t_.._b`;
#
# Recreate the 6 tables; 1 & 2 missing, 3 & 4 discarded, 5 & 6 normal
#
CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT, INDEX(c2));
CREATE TABLE t2 (c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT, INDEX(c2));
CREATE TABLE t3 (c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT, INDEX(c2));
CREATE TABLE t4 (c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT, INDEX(c2));
CREATE TABLE t5 (c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT, INDEX(c2));
CREATE TABLE t6 (c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT, INDEX(c2));
INSERT INTO t1 VALUES (1, 1, 'one'), (2, 2, 'two'), (3, 3, 'three');
INSERT INTO t2 VALUES (1, 1, 'one'), (2, 2, 'two'), (3, 3, 'three');
INSERT INTO t3 VALUES (1, 1, 'one'), (2, 2, 'two'), (3, 3, 'three');
INSERT INTO t4 VALUES (1, 1, 'one'), (2, 2, 'two'), (3, 3, 'three');
INSERT INTO t5 VALUES (1, 1, 'one'), (2, 2, 'two'), (3, 3, 'three');
INSERT INTO t6 VALUES (1, 1, 'one'), (2, 2, 'two'), (3, 3, 'three');
CREATE TABLE t1p LIKE t1;
CREATE TABLE t2p LIKE t1;
CREATE TABLE t3p LIKE t1;
CREATE TABLE t4p LIKE t1;
CREATE TABLE t5p LIKE t1;
CREATE TABLE t6p LIKE t1;
#
# Remove t1 and Discard t3 & t4
#
# restart
ALTER TABLE t3 DISCARD TABLESPACE;
ALTER TABLE t4 DISCARD TABLESPACE;
#
# Add some foreign key constraints
#
CREATE TABLE t1c (c1 INT PRIMARY KEY, c2 INT, c3 INT, INDEX(c2), INDEX(c3),
CONSTRAINT t1c2 FOREIGN KEY (c2) REFERENCES t1(c2),
CONSTRAINT t1c3 FOREIGN KEY (c3) REFERENCES t1p(c2));
CREATE TABLE t2c (c1 INT PRIMARY KEY, c2 INT, c3 INT, INDEX(c2), INDEX(c3),
CONSTRAINT t2c2 FOREIGN KEY (c2) REFERENCES t2(c2),
CONSTRAINT t2c3 FOREIGN KEY (c3) REFERENCES t2p(c2));
CREATE TABLE t3c (c1 INT PRIMARY KEY, c2 INT, c3 INT, INDEX(c2), INDEX(c3),
CONSTRAINT t3c2 FOREIGN KEY (c2) REFERENCES t3(c2),
CONSTRAINT t3c3 FOREIGN KEY (c3) REFERENCES t3p(c2));
CREATE TABLE t4c (c1 INT PRIMARY KEY, c2 INT, c3 INT, INDEX(c2), INDEX(c3),
CONSTRAINT t4c2 FOREIGN KEY (c2) REFERENCES t4(c2),
CONSTRAINT t4c3 FOREIGN KEY (c3) REFERENCES t4p(c2));
CREATE TABLE t5c (c1 INT PRIMARY KEY, c2 INT, c3 INT, INDEX(c2), INDEX(c3),
CONSTRAINT t5c2 FOREIGN KEY (c2) REFERENCES t5(c2),
CONSTRAINT t5c3 FOREIGN KEY (c3) REFERENCES t5p(c2));
CREATE TABLE t6c (c1 INT PRIMARY KEY, c2 INT, c3 INT, INDEX(c2), INDEX(c3),
CONSTRAINT t6c2 FOREIGN KEY (c2) REFERENCES t6(c2),
CONSTRAINT t6c3 FOREIGN KEY (c3) REFERENCES t6p(c2));
#
# Remove t2, try to discard t3 & t4 already discarded
#
# restart
ALTER TABLE t3 DISCARD TABLESPACE;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails ()
SHOW WARNINGS;
Level Code Message
Warning 1814 InnoDB: Tablespace has been discarded for table 't3'
Warning 1812 InnoDB: Tablespace is missing for table test/t3.
Error 1451 Cannot delete or update a parent row: a foreign key constraint fails ()
ALTER TABLE t4 DISCARD TABLESPACE;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails ()
SHOW WARNINGS;
Level Code Message
Warning 1814 InnoDB: Tablespace has been discarded for table 't4'
Warning 1812 InnoDB: Tablespace is missing for table test/t4.
Error 1451 Cannot delete or update a parent row: a foreign key constraint fails ()
ALTER TABLE t5 DISCARD TABLESPACE;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails ()
SHOW WARNINGS;
Level Code Message
Error 1451 Cannot delete or update a parent row: a foreign key constraint fails ()
#
# ALTER TABLE __ DROP FOREIGN KEY
#
ALTER TABLE t1c DROP FOREIGN KEY t1c2, ALGORITHM=INPLACE;
ALTER TABLE t2c DROP FOREIGN KEY t2c2, ALGORITHM=COPY;
ALTER TABLE t3c DROP FOREIGN KEY t3c2, ALGORITHM=INPLACE;
ALTER TABLE t4c DROP FOREIGN KEY t4c2, ALGORITHM=COPY;
ALTER TABLE t5c DROP FOREIGN KEY t5c2, ALGORITHM=INPLACE;
ALTER TABLE t6c DROP FOREIGN KEY t6c2, ALGORITHM=COPY;
#
# Cleanup
#
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
DROP TABLE t4;
DROP TABLE t5;
DROP TABLE t6;
DROP TABLE t1c;
DROP TABLE t2c;
DROP TABLE t3c;
DROP TABLE t4c;
DROP TABLE t5c;
DROP TABLE t6c;
DROP TABLE t1p;
DROP TABLE t2p;
DROP TABLE t3p;
DROP TABLE t4p;
DROP TABLE t5p;
DROP TABLE t6p;
DROP TABLESPACE ts1;
|