mirror of
https://github.com/MariaDB/server.git
synced 2025-08-31 22:22:30 +03:00
Bug#30747 Create table with identical constraint names behaves incorrectly
MySQL provides what appears to be a non standard extension to the FOREIGN KEY syntax which let users name (label/tag) a foreign key to more easily identify a specific foreign key if any problems show up later during the query parsing or execution. But the foreign key name was not being properly set to the right key, possible leaving the foreign key with no name.
This commit is contained in:
@@ -1096,4 +1096,38 @@ select @b:=f2 from t1;
|
||||
select if(@a=@b,"ok","wrong");
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Bug#30747 Create table with identical constraint names behaves incorrectly
|
||||
#
|
||||
|
||||
if ($test_foreign_keys)
|
||||
{
|
||||
CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY (a,b)) engine=innodb;
|
||||
--error ER_WRONG_FK_DEF
|
||||
CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d),
|
||||
CONSTRAINT c2 FOREIGN KEY f2 (c) REFERENCES t1 (a,b) ON UPDATE NO ACTION) engine=innodb;
|
||||
--error ER_WRONG_FK_DEF
|
||||
CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d),
|
||||
CONSTRAINT c2 FOREIGN KEY (c) REFERENCES t1 (a,b) ON UPDATE NO ACTION) engine=innodb;
|
||||
CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d),
|
||||
CONSTRAINT c1 FOREIGN KEY c2 (c) REFERENCES t1 (a) ON DELETE NO ACTION,
|
||||
CONSTRAINT c2 FOREIGN KEY (c) REFERENCES t1 (a) ON UPDATE NO ACTION) engine=innodb;
|
||||
ALTER TABLE t2 DROP FOREIGN KEY c2;
|
||||
DROP TABLE t2;
|
||||
--error ER_WRONG_FK_DEF
|
||||
CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d),
|
||||
FOREIGN KEY (c) REFERENCES t1 (a,k) ON UPDATE NO ACTION) engine=innodb;
|
||||
--error ER_WRONG_FK_DEF
|
||||
CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d),
|
||||
FOREIGN KEY f1 (c) REFERENCES t1 (a,k) ON UPDATE NO ACTION) engine=innodb;
|
||||
CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d),
|
||||
CONSTRAINT c1 FOREIGN KEY f1 (c) REFERENCES t1 (a) ON DELETE NO ACTION,
|
||||
CONSTRAINT c2 FOREIGN KEY (c) REFERENCES t1 (a) ON UPDATE NO ACTION,
|
||||
FOREIGN KEY f3 (c) REFERENCES t1 (a) ON UPDATE NO ACTION,
|
||||
FOREIGN KEY (c) REFERENCES t1 (a) ON UPDATE NO ACTION) engine=innodb;
|
||||
SHOW CREATE TABLE t2;
|
||||
DROP TABLE t2;
|
||||
DROP TABLE t1;
|
||||
}
|
||||
|
||||
--echo End of 5.1 tests
|
||||
|
Reference in New Issue
Block a user