[MDEV-8524] Improve error messaging when there is duplicate key or foreign key names Created: 2015-07-22  Updated: 2015-08-05  Resolved: 2015-08-05

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table
Affects Version/s: 5.5
Fix Version/s: 5.5.45

Type: Bug Priority: Minor
Reporter: Jan Lindström (Inactive) Assignee: Jan Lindström (Inactive)
Resolution: Fixed Votes: 0
Labels: None

Sprint: 5.5.45

 Description   

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.


Generated at Thu Feb 08 07:27:48 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.