MDEV-25509 Atomic DDL: Assertion `err != DB_DUPLICATE_KEY' fails
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.
This commit is contained in:
parent
fd8c68c7fe
commit
9fe681c9e4
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user