diff options
author | Thirunarayanan Balathandayuthapani <thiru@mariadb.com> | 2021-04-30 16:39:06 +0530 |
---|---|---|
committer | Thirunarayanan Balathandayuthapani <thiru@mariadb.com> | 2021-04-30 21:39:51 +0530 |
commit | 9fe681c9e4db6f2ffde058773bbf83c471862318 (patch) | |
tree | 827134e2b3d958cabfdaaf5a000621a437fdef9d | |
parent | fd8c68c7fe6b74fa8f83483c028c83638a2edbf2 (diff) | |
download | mariadb-git-bb-10.6-MDEV-25509.tar.gz |
MDEV-25509 Atomic DDL: Assertion `err != DB_DUPLICATE_KEY' failsbb-10.6-MDEV-25509
after previous error upon multi-RENAME
- InnoDB fails to rename the foreign key constraint while
rollbacking the rename operation. In that case, InnoDB should
rename the FK constraint too.
-rw-r--r-- | mysql-test/suite/innodb/r/innodb-truncate.result | 2 | ||||
-rw-r--r-- | mysql-test/suite/innodb/r/rename_table.result | 14 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/rename_table.test | 16 | ||||
-rw-r--r-- | storage/innobase/row/row0uins.cc | 5 |
4 files changed, 35 insertions, 2 deletions
diff --git a/mysql-test/suite/innodb/r/innodb-truncate.result b/mysql-test/suite/innodb/r/innodb-truncate.result index 3e2ab7936dc..3bcee0e8ed4 100644 --- a/mysql-test/suite/innodb/r/innodb-truncate.result +++ b/mysql-test/suite/innodb/r/innodb-truncate.result @@ -89,7 +89,7 @@ ALTER TABLE t1 RENAME TO t3; ERROR HY000: Error on rename of './test/t1' to './test/t3' (errno: 150 "Foreign key constraint is incorrectly formed") ALTER TABLE t1 FORCE; TRUNCATE TABLE t1; -ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f2`) REFERENCES `test`.`t3` (`f2`)) +ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f2`) REFERENCES `test`.`t1` (`f2`)) DROP TABLE t2, t1; # # MDEV-24861 Assertion `trx->rsegs.m_redo.rseg' failed diff --git a/mysql-test/suite/innodb/r/rename_table.result b/mysql-test/suite/innodb/r/rename_table.result index e5f4e5d77e6..8c3722c7940 100644 --- a/mysql-test/suite/innodb/r/rename_table.result +++ b/mysql-test/suite/innodb/r/rename_table.result @@ -1,3 +1,4 @@ +call mtr.add_suppression("InnoDB: In RENAME TABLE table `test`.`t4` is referenced in foreign key constraints which are not compatible with the new table definition."); CREATE DATABASE test_jfg; CREATE DATABASE test_jfg2; CREATE TABLE test_jfg.test (a int unsigned PRIMARY KEY) ENGINE=InnoDB; @@ -26,3 +27,16 @@ RENAME TABLE t1 TO non_existing_db.t1; ERROR HY000: Error on rename of './test/t1' to './non_existing_db/t1' (errno: 168 "Unknown (generic) error from engine") FOUND 1 /\[ERROR\] InnoDB: Cannot rename file '.*t1\.ibd' to '.*non_existing_db/ in mysqld.1.err DROP TABLE t1; +# +# MDEV-25509 Atomic DDL: Assertion `err != DB_DUPLICATE_KEY' +# fails after previous error upon multi-RENAME +# +SET FOREIGN_KEY_CHECKS= OFF; +CREATE TABLE t1 (pk INT PRIMARY KEY, f INT, FOREIGN KEY (f) REFERENCES t4 (x)) ENGINE=InnoDB; +ALTER TABLE t1 DROP KEY f; +CREATE TABLE t2 (a INT) ENGINE=InnoDB; +RENAME TABLE t1 TO t3, t3 TO t4; +ERROR HY000: Error on rename of './test/t3' to './test/t4' (errno: 150 "Foreign key constraint is incorrectly formed") +RENAME TABLE t2 TO t3; +DROP TABLE t3, t1; +SET FOREIGN_KEY_CHECKS=DEFAULT; diff --git a/mysql-test/suite/innodb/t/rename_table.test b/mysql-test/suite/innodb/t/rename_table.test index f7e3998cf63..35421f0ce7a 100644 --- a/mysql-test/suite/innodb/t/rename_table.test +++ b/mysql-test/suite/innodb/t/rename_table.test @@ -1,6 +1,8 @@ --source include/have_innodb.inc --source include/not_embedded.inc +call mtr.add_suppression("InnoDB: In RENAME TABLE table `test`.`t4` is referenced in foreign key constraints which are not compatible with the new table definition."); + CREATE DATABASE test_jfg; CREATE DATABASE test_jfg2; CREATE TABLE test_jfg.test (a int unsigned PRIMARY KEY) ENGINE=InnoDB; @@ -43,3 +45,17 @@ let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err; # Cleanup DROP TABLE t1; + +--echo # +--echo # MDEV-25509 Atomic DDL: Assertion `err != DB_DUPLICATE_KEY' +--echo # fails after previous error upon multi-RENAME +--echo # +SET FOREIGN_KEY_CHECKS= OFF; +CREATE TABLE t1 (pk INT PRIMARY KEY, f INT, FOREIGN KEY (f) REFERENCES t4 (x)) ENGINE=InnoDB; +ALTER TABLE t1 DROP KEY f; +CREATE TABLE t2 (a INT) ENGINE=InnoDB; +--error ER_ERROR_ON_RENAME +RENAME TABLE t1 TO t3, t3 TO t4; +RENAME TABLE t2 TO t3; +DROP TABLE t3, t1; +SET FOREIGN_KEY_CHECKS=DEFAULT; diff --git a/storage/innobase/row/row0uins.cc b/storage/innobase/row/row0uins.cc index a549e2fc2b1..3c67fcee9e1 100644 --- a/storage/innobase/row/row0uins.cc +++ b/storage/innobase/row/row0uins.cc @@ -398,7 +398,10 @@ static bool row_undo_ins_parse_undo_rec(undo_node_t* node, bool dict_locked) ptr[len] = 0; const char* name = reinterpret_cast<char*>(ptr); if (strcmp(table->name.m_name, name)) { - dict_table_rename_in_cache(table, name, false, true); + dict_table_rename_in_cache( + table, name, + !dict_table_t::is_temporary_name(name), + true); } else if (table->space) { const auto s = table->space->name(); if (len != s.size() || memcmp(name, s.data(), len)) { |