Commit e374755b authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.1 into 10.2

parents 69abd437 32de60bb
...@@ -87,6 +87,19 @@ drop table t3; ...@@ -87,6 +87,19 @@ drop table t3;
drop table t2; drop table t2;
drop table t1; drop table t1;
set debug_sync='reset'; set debug_sync='reset';
#
# MDEV-17595 - Server crashes in copy_data_between_tables or
# Assertion `thd->transaction.stmt.is_empty() ||
# (thd->state_flags & Open_tables_state::BACKUPS_AVAIL)'
# fails in close_tables_for_reopen upon concurrent
# ALTER TABLE and FLUSH
#
CREATE TABLE t1 (a INT, KEY(a)) ENGINE=InnoDB;
INSERT INTO t1 VALUES(1),(2);
CREATE TABLE t2 (b INT, KEY(b)) ENGINE=InnoDB;
INSERT INTO t2 VALUES(2);
ALTER TABLE t2 ADD FOREIGN KEY(b) REFERENCES t1(a), LOCK=EXCLUSIVE;
DROP TABLE t2, t1;
create table t1 (a int primary key, b int) engine=innodb; create table t1 (a int primary key, b int) engine=innodb;
create table t2 (c int primary key, d int, create table t2 (c int primary key, d int,
foreign key (d) references t1 (a) on update cascade) engine=innodb; foreign key (d) references t1 (a) on update cascade) engine=innodb;
......
...@@ -112,6 +112,21 @@ drop table t2; ...@@ -112,6 +112,21 @@ drop table t2;
drop table t1; drop table t1;
set debug_sync='reset'; set debug_sync='reset';
--echo #
--echo # MDEV-17595 - Server crashes in copy_data_between_tables or
--echo # Assertion `thd->transaction.stmt.is_empty() ||
--echo # (thd->state_flags & Open_tables_state::BACKUPS_AVAIL)'
--echo # fails in close_tables_for_reopen upon concurrent
--echo # ALTER TABLE and FLUSH
--echo #
CREATE TABLE t1 (a INT, KEY(a)) ENGINE=InnoDB;
INSERT INTO t1 VALUES(1),(2);
CREATE TABLE t2 (b INT, KEY(b)) ENGINE=InnoDB;
INSERT INTO t2 VALUES(2);
ALTER TABLE t2 ADD FOREIGN KEY(b) REFERENCES t1(a), LOCK=EXCLUSIVE;
DROP TABLE t2, t1;
# #
# FK and prelocking: # FK and prelocking:
# child table accesses (reads and writes) wait for locks. # child table accesses (reads and writes) wait for locks.
......
...@@ -9547,6 +9547,8 @@ do_continue:; ...@@ -9547,6 +9547,8 @@ do_continue:;
new_table->file->get_foreign_key_list(thd, &fk_list); new_table->file->get_foreign_key_list(thd, &fk_list);
while ((fk= fk_list_it++)) while ((fk= fk_list_it++))
{ {
MDL_request mdl_request;
if (lower_case_table_names) if (lower_case_table_names)
{ {
char buf[NAME_LEN]; char buf[NAME_LEN];
...@@ -9558,20 +9560,14 @@ do_continue:; ...@@ -9558,20 +9560,14 @@ do_continue:;
len = my_casedn_str(files_charset_info, buf); len = my_casedn_str(files_charset_info, buf);
thd->make_lex_string(fk->referenced_table, buf, len); thd->make_lex_string(fk->referenced_table, buf, len);
} }
if (table_already_fk_prelocked(table_list, fk->referenced_db,
fk->referenced_table, TL_READ_NO_INSERT))
continue;
TABLE_LIST *tl= (TABLE_LIST *) thd->alloc(sizeof(TABLE_LIST)); mdl_request.init(MDL_key::TABLE,
tl->init_one_table_for_prelocking(fk->referenced_db->str, fk->referenced_db->length, fk->referenced_db->str, fk->referenced_table->str,
fk->referenced_table->str, fk->referenced_table->length, MDL_SHARED_NO_WRITE, MDL_TRANSACTION);
NULL, TL_READ_NO_INSERT, false, NULL, 0, if (thd->mdl_context.acquire_lock(&mdl_request,
&thd->lex->query_tables_last); thd->variables.lock_wait_timeout))
goto err_new_table_cleanup;
} }
if (open_tables(thd, &table_list->next_global, &tables_opened, 0,
&alter_prelocking_strategy))
goto err_new_table_cleanup;
} }
} }
......
...@@ -98,8 +98,8 @@ row_merge_create_fts_sort_index( ...@@ -98,8 +98,8 @@ row_merge_create_fts_sort_index(
field = dict_index_get_nth_field(new_index, 0); field = dict_index_get_nth_field(new_index, 0);
field->name = NULL; field->name = NULL;
field->prefix_len = 0; field->prefix_len = 0;
field->col = new(mem_heap_zalloc(new_index->heap, sizeof(dict_col_t))) field->col = static_cast<dict_col_t*>(
dict_col_t(); mem_heap_zalloc(new_index->heap, sizeof(dict_col_t)));
field->col->prtype = idx_field->col->prtype | DATA_NOT_NULL; field->col->prtype = idx_field->col->prtype | DATA_NOT_NULL;
field->col->mtype = charset == &my_charset_latin1 field->col->mtype = charset == &my_charset_latin1
? DATA_VARCHAR : DATA_VARMYSQL; ? DATA_VARCHAR : DATA_VARMYSQL;
...@@ -113,8 +113,8 @@ row_merge_create_fts_sort_index( ...@@ -113,8 +113,8 @@ row_merge_create_fts_sort_index(
field = dict_index_get_nth_field(new_index, 1); field = dict_index_get_nth_field(new_index, 1);
field->name = NULL; field->name = NULL;
field->prefix_len = 0; field->prefix_len = 0;
field->col = new(mem_heap_zalloc(new_index->heap, sizeof(dict_col_t))) field->col = static_cast<dict_col_t*>(
dict_col_t(); mem_heap_zalloc(new_index->heap, sizeof(dict_col_t)));
field->col->mtype = DATA_INT; field->col->mtype = DATA_INT;
*opt_doc_id_size = FALSE; *opt_doc_id_size = FALSE;
...@@ -152,8 +152,8 @@ row_merge_create_fts_sort_index( ...@@ -152,8 +152,8 @@ row_merge_create_fts_sort_index(
field = dict_index_get_nth_field(new_index, 2); field = dict_index_get_nth_field(new_index, 2);
field->name = NULL; field->name = NULL;
field->prefix_len = 0; field->prefix_len = 0;
field->col = new(mem_heap_zalloc(new_index->heap, sizeof(dict_col_t))) field->col = static_cast<dict_col_t*>(
dict_col_t(); mem_heap_zalloc(new_index->heap, sizeof(dict_col_t)));
field->col->mtype = DATA_INT; field->col->mtype = DATA_INT;
field->col->len = 4 ; field->col->len = 4 ;
field->fixed_len = 4; field->fixed_len = 4;
......
...@@ -101,8 +101,8 @@ row_merge_create_fts_sort_index( ...@@ -101,8 +101,8 @@ row_merge_create_fts_sort_index(
field = dict_index_get_nth_field(new_index, 0); field = dict_index_get_nth_field(new_index, 0);
field->name = NULL; field->name = NULL;
field->prefix_len = 0; field->prefix_len = 0;
field->col = new(mem_heap_zalloc(new_index->heap, sizeof(dict_col_t))) field->col = static_cast<dict_col_t*>(
dict_col_t(); mem_heap_zalloc(new_index->heap, sizeof(dict_col_t)));
field->col->prtype = idx_field->col->prtype | DATA_NOT_NULL; field->col->prtype = idx_field->col->prtype | DATA_NOT_NULL;
field->col->mtype = charset == &my_charset_latin1 field->col->mtype = charset == &my_charset_latin1
? DATA_VARCHAR : DATA_VARMYSQL; ? DATA_VARCHAR : DATA_VARMYSQL;
...@@ -116,8 +116,8 @@ row_merge_create_fts_sort_index( ...@@ -116,8 +116,8 @@ row_merge_create_fts_sort_index(
field = dict_index_get_nth_field(new_index, 1); field = dict_index_get_nth_field(new_index, 1);
field->name = NULL; field->name = NULL;
field->prefix_len = 0; field->prefix_len = 0;
field->col = new(mem_heap_zalloc(new_index->heap, sizeof(dict_col_t))) field->col = static_cast<dict_col_t*>(
dict_col_t(); mem_heap_zalloc(new_index->heap, sizeof(dict_col_t)));
field->col->mtype = DATA_INT; field->col->mtype = DATA_INT;
*opt_doc_id_size = FALSE; *opt_doc_id_size = FALSE;
...@@ -155,8 +155,8 @@ row_merge_create_fts_sort_index( ...@@ -155,8 +155,8 @@ row_merge_create_fts_sort_index(
field = dict_index_get_nth_field(new_index, 2); field = dict_index_get_nth_field(new_index, 2);
field->name = NULL; field->name = NULL;
field->prefix_len = 0; field->prefix_len = 0;
field->col = new(mem_heap_zalloc(new_index->heap, sizeof(dict_col_t))) field->col = static_cast<dict_col_t*>(
dict_col_t(); mem_heap_zalloc(new_index->heap, sizeof(dict_col_t)));
field->col->mtype = DATA_INT; field->col->mtype = DATA_INT;
field->col->len = 4 ; field->col->len = 4 ;
field->fixed_len = 4; field->fixed_len = 4;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment