Bug #90903 | ALTER TABLE doesn't prevent AUTO_INCREMENT out of range in strict mode | ||
---|---|---|---|
Submitted: | 17 May 2018 6:13 | Modified: | 23 May 2018 14:50 |
Reporter: | monty solomon | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: InnoDB storage engine | Severity: | S2 (Serious) |
Version: | 5.6/5.7/8.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[17 May 2018 6:13]
monty solomon
[17 May 2018 6:18]
monty solomon
In this example, the ALTER TABLE statement permits the AUTO_INCREMENT value to be set to a value larger than can fit in the column. DROP TABLE IF EXISTS w; CREATE TABLE `w` ( `x` int NOT NULL AUTO_INCREMENT, `y` bigint(20) unsigned NOT NULL, PRIMARY KEY (`x`) ) ENGINE=InnoDB; ALTER TABLE w AUTO_INCREMENT=2147483648; Query OK, 0 rows affected (0.01 sec) Records: 0 Duplicates: 0 Warnings: 0 INSERT INTO w SET y=1; ERROR 1467 (HY000): Failed to read auto-increment value from storage engine SHOW CREATE TABLE w\G *************************** 1. row *************************** Table: w Create Table: CREATE TABLE `w` ( `x` int(11) NOT NULL AUTO_INCREMENT, `y` bigint(20) unsigned NOT NULL, PRIMARY KEY (`x`) ) ENGINE=InnoDB AUTO_INCREMENT=2147483648
[17 May 2018 6:30]
monty solomon
Operations that produce undefined behavior should be prevented in strict mode 14.8.1.5 AUTO_INCREMENT Handling in InnoDB https://dev.mysql.com/doc/refman/5.7/en/innodb-auto-increment-handling.html * Assigning a negative value to the AUTO_INCREMENT column In all lock modes (0, 1, and 2), the behavior of the auto-increment mechanism is not defined if you assign a negative value to the AUTO_INCREMENT column. * If the AUTO_INCREMENT value becomes larger than the maximum integer for the specified integer type In all lock modes (0, 1, and 2), the behavior of the auto-increment mechanism is not defined if the value becomes larger than the maximum integer that can be stored in the specified integer type.
[23 May 2018 14:50]
MySQL Verification Team
Thank you for the bug report. Verified as described.