Debian Codegraph @

mysql-test/suite/ndb/t/ndb_alter_table_temp_files_cleanup2.test

raw
1 --source include/have_ndb.inc
2 --source include/have_debug.inc
3
4 #
5 # BUG#29892252 TEMP TABLE IS NOT CLEANING UP AFTER ALTER TABLE OPS FAILED
6 # To reproduce the bug this test:
7 # - simulates table create rollback failure to prevent copy alter table from
8 # dropping the temporary named table
9 # - simulates failure during copy alter table to force attempt to rollback
10 # This should lead to situation where:
11 # - temporary named table has not been removed from ndb
12 # - with the next execution of copy alter table mysql may reuse the previously
13 # chosen temporary name
14 # - regarding to the bug description, mysql will fail during statement execution
15 # To fix the bug left behind temporary named table will be dropped if mysql tries
16 # to reuse the name, the warning will be produced
17 #
18
19 --echo # create table t1
20 CREATE TABLE t1(
21 a INT PRIMARY KEY,
22 b INT UNIQUE KEY
23 )ENGINE = NDB;
24
25 INSERT INTO t1 VALUES (1,10), (2,20), (3,30), (4,40);
26
27 --echo # verify that no temporary named table exists
28 SELECT count(*) FROM ndbinfo.dict_obj_info WHERE REGEXP_LIKE(fq_name, '#sql');
29
30 SET debug='+d,ndb_simulate_alter_failure_rename1,ndb_simulate_failure_during_rollback';
31 --echo # simulated failure during copy alter table
32 --error ER_INTERNAL_ERROR
33 ALTER TABLE t1 ALGORITHM=COPY;
34
35 --echo # verify that the temporary named table has been left behind - required to reproduce the bug
36 SELECT count(*) FROM ndbinfo.dict_obj_info WHERE REGEXP_LIKE(fq_name, '#sql');
37
38 --replace_regex /sql-.*\./sql-XXXX_X\./
39 ALTER TABLE t1 ALGORITHM=COPY;
40
41 --echo # verify that original data has not been affected
42 SELECT a, b FROM t1 ORDER BY a;
43
44 --echo # cleanup
45 DROP TABLE t1;