Bug #16840 Duplicate Key error without keys being identical
| Submitted: | 27 Jan 2006 13:22 | Modified: | 10 Feb 2006 20:38 |
|---|---|---|---|
| Reporter: | Michael Friedel | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | MySQL Server | Severity: | S1 (Critical) |
| Version: | MySQL 5.0.18-standard | OS: | MacOS (OSX 10.4, RedHat 4) |
| Assigned to: | Evgeny Potemkin | CPU Architecture: | Any |
[27 Jan 2006 13:22]
Michael Friedel
[27 Jan 2006 22:12]
Jorge del Conde
Thanks for your bug report. I reproduced this under WinXP/5.0.18: mysql> select HEX(C_ID) from T_TEST where C_ID=0x820BF339CCBC4F24A93153AC8D36006 1; +----------------------------------+ | HEX(C_ID) | +----------------------------------+ | 820BF339CCBC4F24A93153AC8D360041 | +----------------------------------+ 1 row in set (0.00 sec) mysql> select 0x820BF339CCBC4F24A93153AC8D360041 = 0x820BF339CCBC4F24A93153AC8D3 60061; +-------------------------------------------------------------------------+ | 0x820BF339CCBC4F24A93153AC8D360041 = 0x820BF339CCBC4F24A93153AC8D360061 | +-------------------------------------------------------------------------+ | 0 | +-------------------------------------------------------------------------+ 1 row in set (0.00 sec) mysql>
[7 Feb 2006 7:26]
Michael Friedel
I have made some progress. If I alter the table and set the BINARY flag it seems to work. ALTER TABLE T_TEST MODIFY COLUMN C_ID CHAR(16) BINARY NOT NULL; It does not work if I set the BINARY flag during the CREATE statement.
[10 Feb 2006 20:38]
Evgeny Potemkin
Due to C_ID field in your table is char(16), mysqld treats '0x820BF339CCBC4F24A93153AC8D360061' as hex presentation of a string. The keys 0x820BF339CCBC4F24A93153AC8D360061 and 0x820BF339CCBC4F24A93153AC8D360041 differs only in last byte - 0x61 and 0x41, which is the 'a' and 'A' letters in latin1 codepage. By default a case insensitive collation is set, thus these keys become identical. In the query select 0x820BF339CCBC4F24A93153AC8D360041 = 0x820BF339CCBC4F24A93153AC8D360061; these values compared as long long, so the result is 0.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.055 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.