We're updating the issue view to help you get more done. 

Improve error messaging when there is duplicate key or foreign key names

Description

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 CREATE TABLE t111 ( 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 t111 (id) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE t112 ( 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 t61 (id) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; ERROR 1005 (HY000): Can't create table `test`.`t112` (errno: 121 "Duplicate key on write or update") MariaDB [test]> show warnings; +---------+------+----------------------------------------------------------------------------------+ | Level | Code | Message | +---------+------+----------------------------------------------------------------------------------+ | Error | 1005 | Can't create table `test`.`t112` (errno: 121 "Duplicate key on write or update") | | Warning | 1022 | Can't write; duplicate key in table 't112' | +---------+------+----------------------------------------------------------------------------------+ 2 rows in set (0.00 sec)

This error message is not very helpful, it should contain what is the duplicate key name and why.

Environment

None

Status

Assignee

Jan Lindström

Reporter

Jan Lindström

Components

Sprint

None

Fix versions

Affects versions

5.5

Priority

Minor