Skip to content

Commit 9fdb8c5

Browse files
committed
MDEV-17721: Corrupted data dictionary after instant DROP COLUMN
dict_index_t::clear_instant_alter(): Remove a loop that became redundant in commit ae2004c and caused corruption of n_nullable when dropping the last column which was not declared NOT NULL.
1 parent 1ee0144 commit 9fdb8c5

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

mysql-test/suite/innodb/r/instant_alter.result

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,11 @@ ALTER TABLE t1 DROP f1, DROP f2, ADD f4 INT, ADD f5 INT;
553553
DELETE FROM t1;
554554
ALTER TABLE t1 DROP COLUMN f4;
555555
DROP TABLE t1;
556+
CREATE TABLE t1 (f1 INT, f2 INT, f3 INT) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
557+
ALTER TABLE t1 DROP f2, ADD COLUMN f4 INT;
558+
ALTER TABLE t1 DROP f4;
559+
ALTER TABLE t1 DROP f1;
560+
DROP TABLE t1;
556561
CREATE TABLE t1
557562
(id INT PRIMARY KEY, c2 INT UNIQUE,
558563
c3 POINT NOT NULL DEFAULT ST_GeomFromText('POINT(3 4)'),
@@ -1052,6 +1057,11 @@ ALTER TABLE t1 DROP f1, DROP f2, ADD f4 INT, ADD f5 INT;
10521057
DELETE FROM t1;
10531058
ALTER TABLE t1 DROP COLUMN f4;
10541059
DROP TABLE t1;
1060+
CREATE TABLE t1 (f1 INT, f2 INT, f3 INT) ENGINE=InnoDB ROW_FORMAT=COMPACT;
1061+
ALTER TABLE t1 DROP f2, ADD COLUMN f4 INT;
1062+
ALTER TABLE t1 DROP f4;
1063+
ALTER TABLE t1 DROP f1;
1064+
DROP TABLE t1;
10551065
CREATE TABLE t1
10561066
(id INT PRIMARY KEY, c2 INT UNIQUE,
10571067
c3 POINT NOT NULL DEFAULT ST_GeomFromText('POINT(3 4)'),
@@ -1551,10 +1561,15 @@ ALTER TABLE t1 DROP f1, DROP f2, ADD f4 INT, ADD f5 INT;
15511561
DELETE FROM t1;
15521562
ALTER TABLE t1 DROP COLUMN f4;
15531563
DROP TABLE t1;
1564+
CREATE TABLE t1 (f1 INT, f2 INT, f3 INT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
1565+
ALTER TABLE t1 DROP f2, ADD COLUMN f4 INT;
1566+
ALTER TABLE t1 DROP f4;
1567+
ALTER TABLE t1 DROP f1;
1568+
DROP TABLE t1;
15541569
disconnect analyze;
15551570
SELECT variable_value-@old_instant instants
15561571
FROM information_schema.global_status
15571572
WHERE variable_name = 'innodb_instant_alter_column';
15581573
instants
1559-
102
1574+
111
15601575
SET GLOBAL innodb_purge_rseg_truncate_frequency= @saved_frequency;

mysql-test/suite/innodb/t/instant_alter.test

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,12 @@ DELETE FROM t1;
431431
ALTER TABLE t1 DROP COLUMN f4;
432432
DROP TABLE t1;
433433

434+
eval CREATE TABLE t1 (f1 INT, f2 INT, f3 INT) $engine;
435+
ALTER TABLE t1 DROP f2, ADD COLUMN f4 INT;
436+
ALTER TABLE t1 DROP f4;
437+
ALTER TABLE t1 DROP f1;
438+
DROP TABLE t1;
439+
434440
dec $format;
435441
}
436442
disconnect analyze;

storage/innobase/include/dict0mem.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2151,7 +2151,6 @@ inline void dict_index_t::clear_instant_alter()
21512151
#endif
21522152
dict_field_t* const begin = &fields[first_user_field()];
21532153
dict_field_t* end = &fields[n_fields];
2154-
while (end[-1].col->is_dropped()) end--;
21552154

21562155
for (dict_field_t* d = begin; d < end; ) {
21572156
/* Move fields for dropped columns to the end. */

0 commit comments

Comments
 (0)