Description:
mysql> create table t2(c1 int unsigned primary key auto_increment);
Query OK, 0 rows affected (0.00 sec)
mysql> insert into t2 values (4294967295); // yeah, 4294967295 = UINT32_MAX - 1
Query OK, 1 row affected (0.00 sec)
mysql> insert into t2 values (0);
ERROR 1062 (23000): Duplicate entry '4294967295' for key 'PRIMARY'
OK, let us see what will happen when it comes to bigint unsigned
mysql> drop table t2;
Query OK, 0 rows affected (0.00 sec)
mysql> create table t2(c1 bigint unsigned primary key auto_increment);
Query OK, 0 rows affected (0.00 sec)
mysql> insert into t2 values (18446744073709551614);// yeah, UINT64_MAX - 1
Query OK, 1 row affected (0.00 sec)
mysql> insert into t2 values (0);
ERROR 1467 (HY000): Failed to read auto-increment value from storage engine
How to repeat:
create table t2(c1 int unsigned primary key auto_increment);
insert into t2 values (4294967295);
insert into t2 values (0);
drop table t2;
create table t2(c1 bigint unsigned primary key auto_increment);
insert into t2 values (18446744073709551614);
insert into t2 values (0);
Suggested fix:
both failed with same error message and error code
or
both succeed and UINT32_MAX and UINT64_MAX are generated , respectively. (high recommended)