Bug #6270 | UPDATE report a duplicate key error whereas it shouldn't | ||
---|---|---|---|
Submitted: | 26 Oct 2004 20:28 | Modified: | 1 Dec 2004 19:44 |
Reporter: | jocelyn fournier (Silver Quality Contributor) | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: MyISAM storage engine | Severity: | S2 (Serious) |
Version: | 4.1.7 | OS: | Linux (Linux) |
Assigned to: | Sergei Golubchik | CPU Architecture: | Any |
[26 Oct 2004 20:28]
jocelyn fournier
[26 Oct 2004 20:31]
jocelyn fournier
I have uploaded the testcase in ftp://support.mysql.com/pub/mysql/secret/update_bug.tar.gz (table name is indexpagedesgroupiestest, not indexpagedesgroupies)
[26 Oct 2004 23:50]
MySQL Verification Team
Verified on BK source server.
[15 Nov 2004 9:44]
jocelyn fournier
Hi Sanja, Any update on this bug ? (it affects quite badly my application :( ) Thanks ! Jocelyn
[1 Dec 2004 19:44]
Sergei Golubchik
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.mysql.com/documentation/ and the instructions on how to report a bug at http://bugs.mysql.com/how-to-report.php Additional info: This is not a bug. As you know MyISAM (and InnoDB, and HEAP) do not support delayed constraints, when you do UPDATE page=page-1 uniqueness of (`cat`,`numeropost`,`page`) conbination (your primary key) is verified after each row update. Basically in your UPDATE you rely on the fact that rows will be updated in increasing page order. It is not the fact in your table, try select page from i ignore key (cat,cat_3,`PRIMARY`) WHERE cat='1' AND numeropost='1' AND numreponse>12; to see it. Of course when you copy data in the new table row order is not necessarily preserved (you may see in explain 'Using index' - that your UNIQUE KEY `cat` (`cat`,`numeropost`,`page`,`numreponse`) index - so rows come up ordered by the index) so UPDATE in the new table succeeds. To make your update working, specify explicit ORDER BY clause: UPDATE i SET page=page-1 WHERE cat='1' AND numeropost='1' AND numreponse>12 order by page;
[1 Dec 2004 19:47]
jocelyn fournier
Hi ! Thanks for clarification Sergei ! Jocelyn