| 1 |
# create table t1 |
| 2 |
CREATE TABLE t1( |
| 3 |
a INT PRIMARY KEY, |
| 4 |
b INT UNIQUE KEY |
| 5 |
)ENGINE = NDB; |
| 6 |
# create table t2 with fks referring columns from t1 |
| 7 |
CREATE TABLE t2( |
| 8 |
a INT, |
| 9 |
b INT, |
| 10 |
c INT UNIQUE KEY, |
| 11 |
CONSTRAINT fk1 FOREIGN KEY (a) REFERENCES t1(a), |
| 12 |
CONSTRAINT fk2 FOREIGN KEY (b) REFERENCES t1(b) |
| 13 |
)ENGINE = NDB; |
| 14 |
INSERT INTO t1 VALUES (1,10), (2,20), (3,30), (4,40); |
| 15 |
INSERT INTO t2 VALUES (1,10,100), (2,20,200); |
| 16 |
# mysqld will crash during alter table and leave temporary named table behind |
| 17 |
SET debug='+d,ndb_simulate_crash_during_alter_table_rename1'; |
| 18 |
ALTER TABLE t1 ALGORITHM=COPY; |
| 19 |
Got one of the listed errors |
| 20 |
# mysqld will restart after crash and remove the temporary named table during connecting to the cluster |
| 21 |
include/assert_grep.inc [require temporary table warning message] |
| 22 |
# verify that no temporary table left |
| 23 |
SELECT count(*) FROM ndbinfo.dict_obj_info WHERE REGEXP_LIKE(fq_name, '#sql'); |
| 24 |
count(*) |
| 25 |
0 |
| 26 |
# verify that original data has not been affected by temporary table cleanup |
| 27 |
SELECT a, b FROM t1 ORDER BY a; |
| 28 |
a b |
| 29 |
1 10 |
| 30 |
2 20 |
| 31 |
3 30 |
| 32 |
4 40 |
| 33 |
SELECT a, b, c FROM t2 ORDER BY a; |
| 34 |
a b c |
| 35 |
1 10 100 |
| 36 |
2 20 200 |
| 37 |
# cleanup |
| 38 |
DROP TABLE t2, t1; |