Bug #28842 Different 'duplicate key' error code between 5.0 and 5.1
Submitted: 1 Jun 2007 17:33 Modified: 18 Jun 2007 15:08
Reporter: Domas Mituzas Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Errors Severity:S2 (Serious)
Version:5.1-bk OS:Any
Assigned to: Jim Winstead CPU Architecture:Any

[1 Jun 2007 17:33] Domas Mituzas
Description:
Duplicate key error number has changed between 5.0 and 5.1, causing incompatible change for any applications using it (and it is one of most used error codes):

5.1:
mysql> insert into inn values (1),(1);
ERROR 1582 (23000): Duplicate entry '1' for key 'PRIMARY'

5.0:
mysql> insert into inn values (1),(1);
ERROR 1062 (23000): Duplicate entry '1' for key 1

How to repeat:
n/a

Suggested fix:
n/a
[1 Jun 2007 17:53] Sergei Golubchik
you cannot change the history
[2 Jun 2007 3:44] Jim Winstead
maybe i'm missing something obvious, but i don't see why the error code had to change for the message to change. the code is calling my_printf_error(ER_DUP_ENTRY_WITH_KEY_NAME, msg, ...) in handler::print_keydup_error, where msg is either ER(ER_DUP_ENTRY_WITH_KEY_NAME) or ER(ER_DUP_ENTRY_AUTOINCREMENT_CASE)

seems to me that it could just be my_printf_error(ER_DUP_ENTRY, msg, ...) and we'd still get the key name in the error message, but the error code would not change.

best of both worlds?
[2 Jun 2007 8:44] Sergei Golubchik
Yes, I think it's possible. Good idea.
[6 Jun 2007 17:38] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/28227

ChangeSet@1.2545, 2007-06-06 10:57:07-07:00, jimw@rama.(none) +58 -0
  Bug #28842  Different 'duplicate key' error code between 5.0 and 5.1
  
    The patch for WL 1563 added a new duplicate key error message so that the
    key name could be provided instead of the key number. But the error code
    for the new message was used even though that did not need to change.
  
    This could cause unnecessary problems for applications that used the old
    ER_DUP_ENTRY error code to detect duplicate key errors.
[8 Jun 2007 1:30] Jim Winstead
Queued in the mysql-5.1-new-maint tree.
[16 Jun 2007 4:51] Bugs System
Pushed into 5.1.20-beta
[18 Jun 2007 15:08] Paul DuBois
Noted in 5.1.20 changelog.

Updated previous related 5.1.15 changelog entry.