Skip to content

Commit 7bccd29

Browse files
committed
MDEV-20479 assertion failure in dict_table_get_nth_col() after INSTANT DROP COLUMN
get_col_list_to_be_dropped() incorrectly returned uninteresting instantly dropped column which was missing in a new dict_index_t get_col_list_to_be_dropped(): rename to collect_columns_from_dropped_indexes and stop return dropped columns
1 parent 4f10d09 commit 7bccd29

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,11 @@ a
261261
1
262262
3
263263
DROP TABLE t1;
264+
#
265+
# MDEV-20479: assertion failure in dict_table_get_nth_col() after INSTANT DROP COLUMN
266+
#
267+
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
268+
ALTER TABLE t1 ADD COLUMN (b INT, c INT, d INT, e INT NOT NULL DEFAULT 0);
269+
ALTER TABLE t1 ADD UNIQUE INDEX(e);
270+
ALTER TABLE t1 DROP b, DROP c, DROP d, DROP e;
271+
DROP TABLE t1;

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,3 +266,14 @@ ROLLBACK;
266266

267267
SELECT * FROM t1;
268268
DROP TABLE t1;
269+
270+
271+
--echo #
272+
--echo # MDEV-20479: assertion failure in dict_table_get_nth_col() after INSTANT DROP COLUMN
273+
--echo #
274+
275+
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
276+
ALTER TABLE t1 ADD COLUMN (b INT, c INT, d INT, e INT NOT NULL DEFAULT 0);
277+
ALTER TABLE t1 ADD UNIQUE INDEX(e);
278+
ALTER TABLE t1 DROP b, DROP c, DROP d, DROP e;
279+
DROP TABLE t1;

storage/innobase/handler/handler0alter.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9935,8 +9935,7 @@ commit_cache_rebuild(
99359935
/** Set of column numbers */
99369936
typedef std::set<ulint, std::less<ulint>, ut_allocator<ulint> > col_set;
99379937

9938-
/** Store the column number of the columns in a list belonging
9939-
to indexes which are not being dropped.
9938+
/** Collect (not instantly dropped) columns from dropped indexes
99409939
@param[in] ctx In-place ALTER TABLE context
99419940
@param[in, out] drop_col_list list which will be set, containing columns
99429941
which is part of index being dropped
@@ -9945,7 +9944,7 @@ to indexes which are not being dropped.
99459944
being dropped */
99469945
static
99479946
void
9948-
get_col_list_to_be_dropped(
9947+
collect_columns_from_dropped_indexes(
99499948
const ha_innobase_inplace_ctx* ctx,
99509949
col_set& drop_col_list,
99519950
col_set& drop_v_col_list)
@@ -9966,6 +9965,12 @@ get_col_list_to_be_dropped(
99669965

99679966
} else {
99689967
ulint col_no = dict_col_get_no(idx_col);
9968+
if (ctx->col_map
9969+
&& ctx->col_map[col_no]
9970+
== ULINT_UNDEFINED) {
9971+
// this column was instantly dropped
9972+
continue;
9973+
}
99699974
drop_col_list.insert(col_no);
99709975
}
99719976
}
@@ -10287,7 +10292,7 @@ commit_cache_norebuild(
1028710292
/* Check if the column, part of an index to be dropped is part of any
1028810293
other index which is not being dropped. If it so, then set the ord_part
1028910294
of the column to 0. */
10290-
get_col_list_to_be_dropped(ctx, drop_list, v_drop_list);
10295+
collect_columns_from_dropped_indexes(ctx, drop_list, v_drop_list);
1029110296

1029210297
for (col_it = drop_list.begin(); col_it != drop_list.end(); ++col_it) {
1029310298
if (!check_col_exists_in_indexes(ctx->new_table,

0 commit comments

Comments
 (0)