diff --git a/mysql-test/suite/innodb/r/innodb_bug115136.result b/mysql-test/suite/innodb/r/innodb_bug115136.result new file mode 100644 index 00000000000..c44d7f02f08 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_bug115136.result @@ -0,0 +1,36 @@ +set @ori_parallel_read_threads = @@innodb_parallel_read_threads; +set @ori_ddl_threads = @@innodb_ddl_threads; +set @ori_ddl_buffer_size = @@innodb_ddl_buffer_size; +create table a(a int, b int, primary key(a)); +set innodb_parallel_read_threads = 16; +set innodb_ddl_threads = 16; +CREATE PROCEDURE insert_into_tables(IN num INTEGER) +BEGIN +declare x INT; +set x = 1; +while x < num do +INSERT INTO `a` (`a`, `b`) VALUES (x, x); +set x = x + 1; +end while; +end$$ +call insert_into_tables(10000); +set innodb_ddl_buffer_size = 65536; +alter table a add column `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, ADD KEY (`id`); +select max(a), max(b), max(id) from a; +max(a) max(b) max(id) +9999 9999 9999 +select b from a where b not in (select id from a); +b +set innodb_ddl_buffer_size = 104857600; +alter table a drop column id, drop index id; +alter table a add column `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, ADD KEY (`id`); +select max(a), max(b), max(id) from a; +max(a) max(b) max(id) +9999 9999 9999 +select b from a where b not in (select id from a); +b +drop table a; +drop PROCEDURE insert_into_tables; +set innodb_parallel_read_threads = @ori_parallel_read_threads; +set innodb_ddl_threads = @ori_ddl_threads; +set innodb_ddl_buffer_size = @ori_ddl_buffer_size; diff --git a/mysql-test/suite/innodb/t/innodb_bug115136.test b/mysql-test/suite/innodb/t/innodb_bug115136.test new file mode 100644 index 00000000000..1ac2af1c659 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_bug115136.test @@ -0,0 +1,48 @@ +set @ori_parallel_read_threads = @@innodb_parallel_read_threads; +set @ori_ddl_threads = @@innodb_ddl_threads; +set @ori_ddl_buffer_size = @@innodb_ddl_buffer_size; + +create table a(a int, b int, primary key(a)); +set innodb_parallel_read_threads = 16; +set innodb_ddl_threads = 16; + +delimiter $$; +CREATE PROCEDURE insert_into_tables(IN num INTEGER) + BEGIN + declare x INT; + set x = 1; + while x < num do + INSERT INTO `a` (`a`, `b`) VALUES (x, x); + set x = x + 1; + end while; +end$$ +delimiter ;$$ + +call insert_into_tables(10000); + +# Mofidy ddl buffer size +set innodb_ddl_buffer_size = 65536; + +alter table a add column `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, ADD KEY (`id`); + +# Max(id) should be same with max(a) and max(b) +select max(a), max(b), max(id) from a; +select b from a where b not in (select id from a); + + +# Mofidy ddl buffer size +set innodb_ddl_buffer_size = 104857600; + +alter table a drop column id, drop index id; + +alter table a add column `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, ADD KEY (`id`); + +# Max(id) should be same with max(a) and max(b) +select max(a), max(b), max(id) from a; +select b from a where b not in (select id from a); + +drop table a; +drop PROCEDURE insert_into_tables; +set innodb_parallel_read_threads = @ori_parallel_read_threads; +set innodb_ddl_threads = @ori_ddl_threads; +set innodb_ddl_buffer_size = @ori_ddl_buffer_size; diff --git a/storage/innobase/ddl/ddl0ddl.cc b/storage/innobase/ddl/ddl0ddl.cc index d83102e67dd..5f7bd96f490 100644 --- a/storage/innobase/ddl/ddl0ddl.cc +++ b/storage/innobase/ddl/ddl0ddl.cc @@ -508,6 +508,11 @@ dberr_t Row::build(ddl::Context &ctx, dict_index_t *index, mem_heap_t *heap, return DB_INVALID_NULL; } + /* Autoinc and fts has been handled */ + if (type == ROW_COPY_DATA) { + return DB_SUCCESS; + } + auto &fts = ctx.m_fts; if (fts.m_doc_id != nullptr && fts.m_doc_id->is_generated()) {