Bug #8489 Strange auto_increment behaviour with HEAP table
Submitted: 13 Feb 2005 14:40 Modified: 16 Mar 2005 18:33
Reporter: Richard Clarke Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.1.9 OS:Any (*)
Assigned to: Ramil Kalimullin CPU Architecture:Any

[13 Feb 2005 14:40] Richard Clarke
Description:
AUTO_INCREMENT field in the following table does not seem to work at all.

How to repeat:
CREATE TABLE `forum_issue_log` (
  `log_id` bigint(20) unsigned NOT NULL auto_increment,
  `request_id` int(10) unsigned NOT NULL default '0',
  `forum_id` mediumint(8) unsigned NOT NULL default '0',
  `created` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  `completed` timestamp NOT NULL default '0000-00-00 00:00:00',
  `status` enum('notdone','done','void') default 'notdone',
  PRIMARY KEY  (`log_id`),
  KEY `forums` (`forum_id`,`created`,`status`),
  KEY `status` (`forum_id`,`status`),
  KEY `request` (`forum_id`,`request_id`,`log_id`)
) ENGINE=HEAP DEFAULT CHARSET=latin1

mysql> insert into forum_issue_log (request_id,forum_id) values (10001,1);
Query OK, 1 row affected (0.00 sec)

mysql> insert into forum_issue_log (request_id,forum_id) values (10001,1);
Query OK, 1 row affected (0.00 sec)

mysql> insert into forum_issue_log (request_id,forum_id) values (10001,1);
Query OK, 1 row affected (0.00 sec)

mysql> insert into forum_issue_log (request_id,forum_id) values (10001,1);
ERROR 1062 (23000): Duplicate entry '18594281858007042' for key 1
mysql> select * from forum_issue_log;
+-------------------+------------+----------+---------------------+---------------------+---------+
| log_id            | request_id | forum_id | created             | completed           | status  |
+-------------------+------------+----------+---------------------+---------------------+---------+
|                 1 |      10001 |        1 | 2005-02-13 14:39:24 | 0000-00-00 00:00:00 | notdone |
| 18594281841229826 |      10001 |        1 | 2005-02-13 14:39:25 | 0000-00-00 00:00:00 | notdone |
| 18594281858007042 |      10001 |        1 | 2005-02-13 14:39:25 | 0000-00-00 00:00:00 | notdone |
+-------------------+------------+----------+---------------------+---------------------+---------+
3 rows in set (0.00 sec)

mysql> 

Suggested fix:
Make AUTO_INCREMENT field work as expected :)
[13 Feb 2005 15:15] Aleksey Kishkin
thank you for bug report
[14 Mar 2005 16:07] 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/internals/23004
[15 Mar 2005 9:33] 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/internals/23025
[15 Mar 2005 14:58] Ramil Kalimullin
fixed in 4.1.11
[16 Mar 2005 18:33] Paul DuBois
Noted in 4.1.11 changelog.