Skip to content

Commit

Permalink
MDEV-20479 assertion failure in dict_table_get_nth_col() after INSTAN…
Browse files Browse the repository at this point in the history
…T 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
  • Loading branch information
kevgs committed Sep 3, 2019
1 parent 4f10d09 commit 7bccd29
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
8 changes: 8 additions & 0 deletions mysql-test/suite/innodb/r/instant_alter_bugs.result
Expand Up @@ -261,3 +261,11 @@ a
1
3
DROP TABLE t1;
#
# MDEV-20479: assertion failure in dict_table_get_nth_col() after INSTANT DROP COLUMN
#
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
ALTER TABLE t1 ADD COLUMN (b INT, c INT, d INT, e INT NOT NULL DEFAULT 0);
ALTER TABLE t1 ADD UNIQUE INDEX(e);
ALTER TABLE t1 DROP b, DROP c, DROP d, DROP e;
DROP TABLE t1;
11 changes: 11 additions & 0 deletions mysql-test/suite/innodb/t/instant_alter_bugs.test
Expand Up @@ -266,3 +266,14 @@ ROLLBACK;

SELECT * FROM t1;
DROP TABLE t1;


--echo #
--echo # MDEV-20479: assertion failure in dict_table_get_nth_col() after INSTANT DROP COLUMN
--echo #

CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
ALTER TABLE t1 ADD COLUMN (b INT, c INT, d INT, e INT NOT NULL DEFAULT 0);
ALTER TABLE t1 ADD UNIQUE INDEX(e);
ALTER TABLE t1 DROP b, DROP c, DROP d, DROP e;
DROP TABLE t1;
13 changes: 9 additions & 4 deletions storage/innobase/handler/handler0alter.cc
Expand Up @@ -9935,8 +9935,7 @@ commit_cache_rebuild(
/** Set of column numbers */
typedef std::set<ulint, std::less<ulint>, ut_allocator<ulint> > col_set;

/** Store the column number of the columns in a list belonging
to indexes which are not being dropped.
/** Collect (not instantly dropped) columns from dropped indexes
@param[in] ctx In-place ALTER TABLE context
@param[in, out] drop_col_list list which will be set, containing columns
which is part of index being dropped
Expand All @@ -9945,7 +9944,7 @@ to indexes which are not being dropped.
being dropped */
static
void
get_col_list_to_be_dropped(
collect_columns_from_dropped_indexes(
const ha_innobase_inplace_ctx* ctx,
col_set& drop_col_list,
col_set& drop_v_col_list)
Expand All @@ -9966,6 +9965,12 @@ get_col_list_to_be_dropped(

} else {
ulint col_no = dict_col_get_no(idx_col);
if (ctx->col_map
&& ctx->col_map[col_no]
== ULINT_UNDEFINED) {
// this column was instantly dropped
continue;
}
drop_col_list.insert(col_no);
}
}
Expand Down Expand Up @@ -10287,7 +10292,7 @@ commit_cache_norebuild(
/* Check if the column, part of an index to be dropped is part of any
other index which is not being dropped. If it so, then set the ord_part
of the column to 0. */
get_col_list_to_be_dropped(ctx, drop_list, v_drop_list);
collect_columns_from_dropped_indexes(ctx, drop_list, v_drop_list);

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

0 comments on commit 7bccd29

Please sign in to comment.