| Bug #47125 | auto_increment start value is ignored if an index is created and engine=innodb | ||
|---|---|---|---|
| Submitted: | 4 Sep 10:15 | Modified: | 22 Nov 1:31 |
| Reporter: | Bernt Johnsen | ||
| Status: | Closed | ||
| Category: | Server: InnoDB | Severity: | S2 (Serious) |
| Version: | 5.1.37, 5.1.39-bzr, 5.0.85 | OS: | Any |
| Assigned to: | Satya B | Target Version: | |
| Triage: | Triaged: D2 (Serious) | ||
[4 Sep 10:15]
Bernt Johnsen
[4 Sep 10:20]
Valeriy Kravchuk
Verified just as described.
[4 Sep 10:24]
Valeriy Kravchuk
Same with recent 5.1.39 from bzr on Linux:
openxs@suse:/home2/openxs/dbs/5.1> bin/mysql -uroot test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.39-debug Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> drop table if exists t1;
Query OK, 0 rows affected (0.02 sec)
mysql> create table t1 (
-> pk integer auto_increment,
-> i integer,
-> primary key (pk)
-> ) auto_increment=10 engine=innodb;
Query OK, 0 rows affected (0.11 sec)
mysql> create index ix on t1(i);
Query OK, 0 rows affected (0.16 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql>
mysql> insert into t1 (i) values (0);
Query OK, 1 row affected (0.00 sec)
mysql> select * from t1;
+----+------+
| pk | i |
+----+------+
| 1 | 0 |
+----+------+
1 row in set (0.01 sec)
mysql>
mysql> drop table if exists t2;
Query OK, 0 rows affected (0.00 sec)
mysql> create table t2 (
-> pk integer auto_increment,
-> i integer,
-> primary key (pk),
-> key(i)
-> ) auto_increment=10 engine=innodb;
Query OK, 0 rows affected (0.02 sec)
mysql>
mysql> insert into t2 (i) values (0);
Query OK, 1 row affected (0.00 sec)
mysql> select * from t2;
+----+------+
| pk | i |
+----+------+
| 10 | 0 |
+----+------+
1 row in set (0.00 sec)
[4 Sep 10:27]
Valeriy Kravchuk
MyISAM is not affected:
mysql> create table t1 (
-> pk integer auto_increment,
-> i integer,
-> primary key (pk)
-> ) auto_increment=10 engine=MyISAM;
Query OK, 0 rows affected (0.08 sec)
mysql> create index ix on t1(i);
Query OK, 0 rows affected (0.13 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> insert into t1 (i) values (0);
Query OK, 1 row affected (0.06 sec)
mysql> select * from t1;
+----+------+
| pk | i |
+----+------+
| 10 | 0 |
+----+------+
1 row in set (0.00 sec)
[17 Sep 4:00]
Sunny Bains
Works with the plugin: mysql> create table t1 (pk integer auto_increment, i integer, primary key (pk) ) auto_increment=10 engine=innodb; Query OK, 0 rows affected (0.02 sec) mysql> create index ix on t1(i); Query OK, 0 rows affected (0.03 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> insert into t1 (i) values (0); Query OK, 1 row affected (10.48 sec) mysql> select * from t1; +----+------+ | pk | i | +----+------+ | 10 | 0 | +----+------+ 1 row in set (0.00 sec)
[22 Sep 1:48]
Sunny Bains
CREATE INDEX I ON T(C); creates a new table, copies the data, drops the old table and then renames the new table to the old table name. We need to check for SQLCOM_CREATE_INDEX and copy the old autoinc value across to the new table too.
[4 Nov 10:24]
Bugs System
Pushed into 5.1.41 (revid:joro@sun.com-20091104092152-qz96bzlf2o1japwc) (version source revid:kristofer.pettersson@sun.com-20091103162305-08l4gkeuif2ozsoj) (merge vers: 5.1.41) (pib:13)
[11 Nov 7:49]
Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20091110093407-rw5g8dys2baqkt67) (version source revid:alik@sun.com-20091109080109-7dxapd5y5pxlu08w) (merge vers: 6.0.14-alpha) (pib:13)
[11 Nov 7:56]
Bugs System
Pushed into 5.5.0-beta (revid:alik@sun.com-20091109115615-nuohp02h8mdrz8m2) (version source revid:svoj@sun.com-20091105122958-jyqjx9xus8v4e0yd) (merge vers: 5.5.0-beta) (pib:13)
[22 Nov 1:31]
Paul DuBois
Noted in 5.1.41, 5.5.0, 6.0.14 changelogs. If an InnoDB table was created with the AUTO_INCREMENT table option to specify an initial auto-increment value, and an index was added in a separate operation later, the auto-increment value was lost (subsequent inserts began at 1 rather than the specified value).
