[MDEV-33284] ERROR 1025 (HY000): Error on rename of './test/t1' to './test/t2' (errno: 150 "Foreign key constraint is incorrectly formed") on RENAME Created: 2024-01-19  Updated: 2024-01-19

Status: Open
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.4, 10.5, 10.6, 10.11, 11.0, 11.1, 11.2, 11.3, 11.4
Fix Version/s: 10.4, 10.5, 10.6, 10.11, 11.0, 11.1, 11.2, 11.3

Type: Bug Priority: Major
Reporter: Roel Van de Paar Assignee: Thirunarayanan Balathandayuthapani
Resolution: Unresolved Votes: 0
Labels: None


 Description   

While a few related bugs are open, I did not see any that this matched this scenario (RENAME, double ref needed).

SET foreign_key_checks=0;
CREATE TABLE t1 (pk INT KEY,b INT,c INT,FOREIGN KEY(b,c) REFERENCES t2 (pk,pk));
RENAME TABLE t1 TO t2;

Leads to:

11.4.0 9bd95e914f3f12d0d9d93e7a1f2c49e6e8841f17 (Debug)

11.4.0-dbg>RENAME TABLE t1 TO t2;
ERROR 1025 (HY000): Error on rename of './test/t1' to './test/t2' (errno: 150 "Foreign key constraint is incorrectly formed")

And in the error log:

11.4.0 9bd95e914f3f12d0d9d93e7a1f2c49e6e8841f17 (Debug)

[ERROR] InnoDB: In RENAME TABLE table `test`.`t2` is referenced in foreign key constraints which are not compatible with the new table definition.


Generated at Thu Feb 08 10:37:46 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.