Bug #37927 | ALTER TABLE ... AUTO_INCREMENT=... copies table, should only change attribute | ||
---|---|---|---|
Submitted: | 7 Jul 2008 13:27 | Modified: | 7 Jul 2008 13:39 |
Reporter: | Hartmut Holzgraefe | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: DDL | Severity: | S4 (Feature request) |
Version: | 5.0, 5.1 | OS: | Linux |
Assigned to: | CPU Architecture: | Any |
[7 Jul 2008 13:27]
Hartmut Holzgraefe
[7 Jul 2008 13:39]
MySQL Verification Team
Thank you for the feature request bug.
[28 May 2009 16:25]
Micah Stevens
Workaround: If you insert a record, specifying the autoincrement column to be a higher value than autoincrement is set to, it will update this without copying the table.
[7 Apr 2010 10:27]
Valeriy Kravchuk
Bug #52647 was marked as a duplicate of this one.
[28 Sep 2011 14:36]
Aigars Mahinovs
As an explanation of why this bug/feature is quite important: Django unit testing framework does a database flush between different test classes. In most cases this take fractions of a second, but if you have several hundred tests a couple dozen applications and over 50 tables, then the time spent in ALTER TABLE ... AUTO_INCREMENT=1; call that Django does between test sets for all tables very quickly addds up. In a project I am working at right now running the unittests without the AUTO_INCREMENT reset takes only 3 minutes, but with default Django behavior the same tests take nearly 30 minutes to run! And this is with EMPTY tables (they are TRUNCATED right before the ALTER TABLE command)! There is no such problem in SQLite, Postgres or Oracle. And for some reason we don't see this in Windows version of MySQL Server either. This is a really annoying bug for Linux MySQL developers doing serious Django work!
[28 Sep 2011 15:32]
Boris Serebrov
The same (previous comment) also is true for Yii php framework. I guess this can also be important for any other unit testing environment. Reset database before running a test is a common practice and part of this process is reset of the AUTO_INCREMENT value.