Details
-
Type:
Technical task
-
Status: Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:
Description
There are two similar errors, ER_DUP_ENTRY and ER_DUP_KEY; all in all, ER_DUP_ENTRY probably provides more useful information (the name of the key and the offending value vs the table name):
perror 1062 MySQL error code 1062 (ER_DUP_ENTRY): Duplicate entry '%-.192s' for key %d perror 1022 MySQL error code 1022 (ER_DUP_KEY): Can't write; duplicate key in table '%-.192s'
CREATE TABLE t1 (i INT PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1),(2),(3); INSERT INTO t1 VALUES (4),(2),(5); ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
CREATE TABLE t1 (i INT PRIMARY KEY) ENGINE=LevelDB; INSERT INTO t1 VALUES (1),(2),(3); INSERT INTO t1 VALUES (4),(2),(5); ERROR 23000: Can't write; duplicate key in table 't1'
So if it's possible, it might make sense to produce ER_DUP_ENTRY on a duplicate key error.
Gliffy Diagrams
Attachments
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
This automatically started to work when ON DUPLICATE KEY UPDATE part of Storage Engine interface was implemented. I think, it needed the storage engine to inform upper layer about which key had the unique-ness violation.