mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-29092 FOREIGN_KEY_CHECKS does not prevent non-copy alter from creating invalid FK structure
Problem: ======== - InnoDB should have two keys on the same column for the self referencing foreign key relation. Solution: ========= - Allow self referential foreign key relation to work with one key.
This commit is contained in:
@@ -86,8 +86,7 @@ CREATE TABLE t2 (f2 INT, FOREIGN KEY(f2) REFERENCES t1 (f2)) ENGINE=InnoDB;
|
||||
CREATE TABLE t3 (a INT) ENGINE=InnoDB;
|
||||
ERROR HY000: Can't create table `test`.`t3` (errno: 150 "Foreign key constraint is incorrectly formed")
|
||||
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;
|
||||
ALTER TABLE t3 FORCE;
|
||||
TRUNCATE TABLE t3;
|
||||
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`))
|
||||
DROP TABLE t2, t1;
|
||||
DROP TABLE t2, t3;
|
||||
|
Reference in New Issue
Block a user