Bug #31860 Server crashes after inserting into InnoDB table with auto_increment column
Submitted: 25 Oct 2007 20:03 Modified: 4 Dec 2007 22:19
Reporter: Sveta Smirnova
Status: Closed
Category:Server: InnoDB Severity:S1 (Critical)
Version:5.1 BK OS:Linux
Assigned to: Sunny Bains Target Version:

[25 Oct 2007 20:03] Sveta Smirnova
Description:
Server crashes after inserting into InnoDB table with auto_increment column

How to repeat:
use test
drop table if exists t;
create table t(`_id` bigint(20) NOT NULL auto_increment primary key)engine=innodb;
insert into t values(-10);
select * from t;

mysqld restart

use test
insert into t values(null),(null);
ERROR 2013 (HY000): Lost connection to MySQL server during query
[26 Oct 2007 4:00] Sunny Bains
This bug was introduced when fixing Bug#16979. It assumes that the table AUTOINC 
counter stored in the table cannot be negative.
[26 Oct 2007 20:01] Sunny Bains
The fix will change the way InnoDB behaves if the auto-increment column contains negative
values. Earlier the behavior was undefined. With the change, if the maximum value read
from an auto-increment column is negative during auto-increment initialization, the
auto-increment counter will be reset to 0 and the next number that will be allocated,
will start from 1.
[7 Nov 2007 0:41] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/37233

ChangeSet@1.2605, 2007-11-06 16:40:50-07:00, tsmith@ramayana.hindu.god +6 -0
  Apply snapshot innodb-5.1-ss2034
  
  The following bugs are fixed:
  
  Bug #31860: Server crashes after inserting into InnoDB table with auto_increment column
    In the Bug 16979 fix there was an erroneous assertion that
    autoincrement columns can't contain negative values. With the fix, the
    autoincrement table counter is set to 0 if the maximum value read from
    the autoinc column index is negative.
[7 Nov 2007 2:03] Timothy Smith
Queued to 5.1-build
[21 Nov 2007 19:54] Bugs System
Pushed into 5.1.23-rc
[21 Nov 2007 19:54] Bugs System
Pushed into 6.0.4-alpha
[4 Dec 2007 22:19] Paul DuBois
Noted in 5.1.23, 6.0.4 changelogs.

The server crashed after insertion of a negative value into an
AUTO_INCREMENT column of an InnoDB table.