Re: MySQL 4.0.20 auto_increment bug

Fred <[email protected]> Thu, 05 Aug 2004 16:09:45 -0400
Newsgroups gmane.comp.db.mysql.bugs
Organization HydraNuke.com
Message-ID <1091736585.22999.87.camel@jupiter>
On Fri, 2004-08-06 at 13:02, Hartmut Holzgraefe wrote:
...
> 
> expected behaviour for InnoDB, see
>    http://dev.mysql.com/doc/mysql/en/InnoDB_auto-increment_column.html

Most curious. I've read that before, and now I've read it again. What
caught my eye is this:

===
InnoDB uses the following algorithm to initialize the auto-increment
counter for a table T that contains an AUTO_INCREMENT column named
ai_col: After a server startup, when a user first does an insert to a
table T, InnoDB executes the equivalent of this statement:

SELECT MAX(ai_col) FROM T FOR UPDATE;
===

No where in this documentation does it mentions what happens if someone
re sequence the numbers. Restarting MySQL works around the problem
because it forces the above SELECT statement (or the equivalent) to be
called again. Another workaround would be to execute that SELECT
statement after any re-sequencing of an auto_increment column. 

I am a big proponent of *expected* behavior, especially since a subtlety
such as this could easily be missed and wind up corrupting a database.
So I personally would consider this a bug.

-- 
Fred Mitchell, HydraNuke.com
E-Commerce and Hosting Solutions 
Whatever you want, we'll make it happen
(603)557-5986
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQBBEpQIVZ97vCsahg4RAjEBAKDOdGFjKI+IkaXkj8LB3cqSH2OpJQCfawsO
taA4SfIXtafg+MyfaZXVofA=
=dU9C
-----END PGP SIGNATURE-----