Bug #14981 Adding ForeignKey with a duplicated name should show a proper error message
Submitted: 16 Nov 2005 12:54 Modified: 17 Nov 2005 11:22
Reporter: Alexandre Gomes Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S4 (Feature request)
Version: OS:
Assigned to: CPU Architecture:Any
Triage: D5 (Feature request)

[16 Nov 2005 12:54] Alexandre Gomes
Description:
When trying to add a foreign key with a name that already exists the error that mysql produces is:
ERROR 1216 (23000): Cannot add or update a child row: a foreign key constraint fails

And should be something more usefull like "That name already exists..."

How to repeat:
Create a table with a foreign key called "ABC". Try to add a foreign key to another table where the foreign key is called "ABC".

Suggested fix:
Proper error.
[16 Nov 2005 14:32] Heikki Tuuri
Hi!

Please use:

SHOW INNODB STATUS\G

to display a detailed explanation of the latest foreign key error.

Better error messages are in the TODO.

Regards,

Heikki
[17 Nov 2005 11:22] Jan Lindström
Duplicate of bug #13431.