Bug #12434 | Update auto_increment column to last ID + 1 causes error on next insert | ||
---|---|---|---|
Submitted: | 8 Aug 2005 12:57 | Modified: | 8 Aug 2005 19:02 |
Reporter: | Taco van den Broek | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: InnoDB storage engine | Severity: | S3 (Non-critical) |
Version: | 5.0.7-beta-nt | OS: | Any (any) |
Assigned to: | CPU Architecture: | Any |
[8 Aug 2005 12:57]
Taco van den Broek
[8 Aug 2005 18:01]
MySQL Verification Team
Verified with 5.0.11 and 4.1.14
[8 Aug 2005 19:02]
Heikki Tuuri
Hi! This is the documented behavior of the InnoDB auto-increment. Why would you update the value of the auto-increment column? Workaround: use DELETE + INSERT. Regards, Heikki
[9 Aug 2005 6:48]
Taco van den Broek
Thanks for the quick reply! I've found this behavior while trying out the 'INSERT ... ON DUPLICATE KEY UPDATE ...' syntax. In the on duplicate key clause I accidentaly updated an auto-increment column like described in this bug report. I've searched for this behavior on the innodb site, but couldn't find it? Nevertheless I still think it is unwanted behavior that a table can become useless after a valid update query unless you manually reset the auto-increment counter after each update in which this behavior might occur. Taco
[12 Sep 2005 9:27]
Marko Mäkelä
This behavior could be fixed by acquiring an auto-increment lock in UPDATE statements. However, it would reduce concurrency and possibly make deadlocks occur more often. As there is very little need to update an auto-increment column in real-world applications, we have chosen performance over ease-of-use.