mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-8524: Improve error messaging when there is duplicate key or foreign key names
Added better error message that will be printed when foreign key constraint name in create table is not unique in database.
This commit is contained in:
29
mysql-test/suite/innodb/t/innodb-fk-warnings.test
Normal file
29
mysql-test/suite/innodb/t/innodb-fk-warnings.test
Normal file
@ -0,0 +1,29 @@
|
||||
--source include/have_innodb.inc
|
||||
|
||||
#
|
||||
# MDEV-8524: Improve error messaging when there is duplicate key or foreign key names
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
id int(11) NOT NULL PRIMARY KEY,
|
||||
a int(11) NOT NULL,
|
||||
b int(11) NOT NULL,
|
||||
c int not null,
|
||||
CONSTRAINT test FOREIGN KEY (b) REFERENCES t1 (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
#
|
||||
# Below create table fails because constraint name test
|
||||
# is reserved for above table.
|
||||
#
|
||||
--error 1005
|
||||
CREATE TABLE t2 (
|
||||
id int(11) NOT NULL PRIMARY KEY,
|
||||
a int(11) NOT NULL,
|
||||
b int(11) NOT NULL,
|
||||
c int not null,
|
||||
CONSTRAINT test FOREIGN KEY (b) REFERENCES t2 (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
show warnings;
|
||||
|
||||
drop table t1;
|
Reference in New Issue
Block a user