diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2019-03-11 22:50:24 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2019-03-11 22:50:24 +0400 |
commit | ea52ecbc103b1424cf0b6f8faf990676b2b57a63 (patch) | |
tree | 29e968dbb2f0391fe397a89217513559165bfec0 | |
parent | 2a2ab121b0f65cdc4b104ec763d23f1b7035a644 (diff) | |
parent | 149b75476837fb96c28739d5368e977e39fd671b (diff) | |
download | mariadb-git-ea52ecbc103b1424cf0b6f8faf990676b2b57a63.tar.gz |
Merge remote-tracking branch 'origin/10.0' into 10.1
-rw-r--r-- | mysql-test/suite/innodb/r/foreign-keys.result | 13 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/foreign-keys.test | 15 | ||||
-rw-r--r-- | sql/sql_table.cc | 20 |
3 files changed, 36 insertions, 12 deletions
diff --git a/mysql-test/suite/innodb/r/foreign-keys.result b/mysql-test/suite/innodb/r/foreign-keys.result index 66fc00e34d0..68528521fb6 100644 --- a/mysql-test/suite/innodb/r/foreign-keys.result +++ b/mysql-test/suite/innodb/r/foreign-keys.result @@ -87,3 +87,16 @@ drop table t3; drop table t2; drop table t1; 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; diff --git a/mysql-test/suite/innodb/t/foreign-keys.test b/mysql-test/suite/innodb/t/foreign-keys.test index 7ef440b260b..ced44a89d7c 100644 --- a/mysql-test/suite/innodb/t/foreign-keys.test +++ b/mysql-test/suite/innodb/t/foreign-keys.test @@ -111,3 +111,18 @@ drop table t3; drop table t2; drop table t1; 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; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 55b77c8b934..57333e7dc30 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -9150,6 +9150,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, new_table->file->get_foreign_key_list(thd, &fk_list); while ((fk= fk_list_it++)) { + MDL_request mdl_request; + if (lower_case_table_names) { char buf[NAME_LEN]; @@ -9161,20 +9163,14 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, len = my_casedn_str(files_charset_info, buf); 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)); - tl->init_one_table_for_prelocking(fk->referenced_db->str, fk->referenced_db->length, - fk->referenced_table->str, fk->referenced_table->length, - NULL, TL_READ_NO_INSERT, false, NULL, 0, - &thd->lex->query_tables_last); + mdl_request.init(MDL_key::TABLE, + fk->referenced_db->str, fk->referenced_table->str, + MDL_SHARED_NO_WRITE, MDL_TRANSACTION); + if (thd->mdl_context.acquire_lock(&mdl_request, + 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; } } /* |