1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +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:
Thirunarayanan Balathandayuthapani
2023-12-06 14:29:17 +05:30
parent dc9ac9266c
commit d5fc34db4c
7 changed files with 54 additions and 42 deletions

View File

@ -85,10 +85,8 @@ SET FOREIGN_KEY_CHECKS= ON;
CREATE TABLE t2 (f2 INT, FOREIGN KEY(f2) REFERENCES t1 (f2)) ENGINE=InnoDB;
--error ER_CANT_CREATE_TABLE
CREATE TABLE t3 (a INT) ENGINE=InnoDB;
--replace_result $datadir ./
--error ER_ERROR_ON_RENAME
ALTER TABLE t1 RENAME TO t3;
ALTER TABLE t1 FORCE;
ALTER TABLE t3 FORCE;
--error ER_TRUNCATE_ILLEGAL_FK
TRUNCATE TABLE t1;
DROP TABLE t2, t1;
TRUNCATE TABLE t3;
DROP TABLE t2, t3;