diff options
author | Eugene Kosov <claprix@yandex.ru> | 2019-09-03 16:28:30 +0300 |
---|---|---|
committer | Eugene Kosov <claprix@yandex.ru> | 2019-09-03 22:08:30 +0300 |
commit | 7bccd2910f6cd02a49d62a739dfe64c25c6a8462 (patch) | |
tree | b42ed04955163c5079c94587c944c39c0be7f5ea | |
parent | 4f10d0918d91a98ba46e095fbe775409d3ce0d41 (diff) | |
download | mariadb-git-7bccd2910f6cd02a49d62a739dfe64c25c6a8462.tar.gz |
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
-rw-r--r-- | mysql-test/suite/innodb/r/instant_alter_bugs.result | 8 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/instant_alter_bugs.test | 11 | ||||
-rw-r--r-- | storage/innobase/handler/handler0alter.cc | 13 |
3 files changed, 28 insertions, 4 deletions
diff --git a/mysql-test/suite/innodb/r/instant_alter_bugs.result b/mysql-test/suite/innodb/r/instant_alter_bugs.result index 5e3c2f87bf1..109cbffe871 100644 --- a/mysql-test/suite/innodb/r/instant_alter_bugs.result +++ b/mysql-test/suite/innodb/r/instant_alter_bugs.result @@ -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; diff --git a/mysql-test/suite/innodb/t/instant_alter_bugs.test b/mysql-test/suite/innodb/t/instant_alter_bugs.test index 3cf3de54ba5..fc5e3ca56e4 100644 --- a/mysql-test/suite/innodb/t/instant_alter_bugs.test +++ b/mysql-test/suite/innodb/t/instant_alter_bugs.test @@ -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; diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 722d75960bb..14d6527b764 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -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 @@ -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) @@ -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); } } @@ -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, |