Bug #44597 Cannot use an expression to se the AUTO_INCREMENT value for a table
Submitted: 1 May 2009 10:49 Modified: 20 Jul 2009 9:03
Reporter: alastair knowles Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: General Severity:S4 (Feature request)
Version:5.1 OS:Linux
Assigned to: CPU Architecture:Any
Tags: auto_increment, autoincrement, table creation

[1 May 2009 10:49] alastair knowles
Description:
Trying to use the the maximum value of a field in one table to set the starting autoincrement value for a second temporary table. Not possible. Autoincrement starting value cannot be specified by defining an expression.

How to repeat:
CREATE TABLE example (
    ex_id INT (10) AUTO_INCREMENT PRIMARY KEY);

CREATE TEMPORARY TABLE temp (
    te_id INT (10) AUTO_INCREMENT PRIMARY KEY)
    AUTO_INCREMENT = (
        SELECT MAX(example.ex_id) + 1
        FROM example);

Suggested fix:
Allow the autoincrement starting value to be set by defining an expression.
[20 Jul 2009 9:03] Susanne Ebrecht
This is a duplicate of bug #1625