mysql跳过int(11)auto increment列上的2147483646

dxpyg8gm  于 2021-06-24  发布在  Mysql
关注(0)|答案(1)|浏览(640)

这是我的密码:

create table test3 (
    num int(11) not null auto_increment,
    primary key (num)
) auto_increment=2147483644;

insert into test3 values();
insert into test3 values();
insert into test3 values();
insert into test3 values(); //duplicate key error

select * from test3;

您将注意到使用了2147483644、2147483645和2147483647,但没有使用2147483646。我可以手动设置为2147483646,但我想了解为什么会发生这种情况。我的innodb autoinc锁定模式是1(我的版本的默认值)。

nmpmafwu

nmpmafwu1#

此行为以前曾被报告为一个bug,2015年:
错误自动增量值从最大行值-2跳到最大
该漏洞报告中的一条评论称,该漏洞早在几年前就被报道过(大约在2010-2011年)。
还没修好。我刚刚测试了mysql 8.0.11,其行为仍然如您所描述的那样。
如果您想提高bug的优先级,应该登录mysql bug站点并单击“影响我”按钮。
无论如何,您不应该依赖于自动递增键的值是连续的。他们唯一的要求就是独一无二。

相关问题