--source include/have_innodb.inc --echo # --echo # MDEV-22230 : Unexpected ER_ERROR_ON_RENAME upon DROP --echo # non-existing FOREIGN KEY --echo # CREATE TABLE t1 (a INT) ENGINE=InnoDB; --error ER_CANT_DROP_FIELD_OR_KEY ALTER TABLE t1 DROP FOREIGN KEY x, ALGORITHM=COPY; --error ER_CANT_DROP_FIELD_OR_KEY ALTER TABLE t1 DROP FOREIGN KEY x, ALGORITHM=INPLACE; # Cleanup DROP TABLE t1; CREATE TABLE t1 (a INT, KEY(a)) ENGINE=InnoDB; CREATE TABLE t2 (a INT, FOREIGN KEY fk_id (a) REFERENCES t1(a))ENGINE=InnoDB; CREATE TABLE t3 (a INT, FOREIGN KEY fk_1 (a) REFERENCES t1(a))ENGINE=InnoDB; ALTER TABLE t3 DROP FOREIGN KEY IF EXISTS fk_id; DROP TABLE t3, t2; ALTER TABLE t1 MODIFY COLUMN a VARCHAR(2), DROP FOREIGN KEY IF EXISTS x; DROP TABLE t1; CREATE DATABASE best; CREATE TABLE best.t1(f1 INT, KEY(f1))ENGINE=InnoDB; CREATE TABLE best.t2(f1 INT, FOREIGN KEY foo(f1) REFERENCES t1(f1))ENGINE=InnoDB; CREATE TABLE t1(f1 INT, KEY(f1))ENGINE=InnoDB; CREATE TABLE t2(f1 INT, FOREIGN KEY foo(f1) REFERENCES t1(f1))ENGINE=InnoDB; ALTER TABLE t2 DROP FOREIGN KEY foo; --error ER_CANT_DROP_FIELD_OR_KEY ALTER TABLE t2 DROP FOREIGN KEY foo; ALTER TABLE t2 DROP FOREIGN KEY IF EXISTS foo; SHOW CREATE TABLE best.t2; SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; DROP TABLE best.t2, best.t1, t2, t1; DROP DATABASE best;