Details
-
Technical task
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Fixed
-
None
-
None
-
None
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.