Bug #113525 AUTO_INCREMENT wrong value
Submitted: 29 Dec 2023 9:32 Modified: 29 Dec 2023 15:04
Reporter: zongyi chen (OCA) Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: MySQL Verification Team CPU Architecture:Any

[29 Dec 2023 9:32] zongyi chen
Description:
AUTO_INCREMENT Property is expected to add 1 once,but in the situation below it Increases wrong value.

How to repeat:
CREATE TABLE t1 (f1 INT);
INSERT INTO t1 VALUES (1), (3);
CREATE TABLE t2(f1 int, f2 int auto_increment unique key) AS SELECT * FROM t1;
show create table t3;

context will be :
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                                  |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t3    | CREATE TABLE `t3` (
  `f2` int NOT NULL AUTO_INCREMENT,
  `f1` int DEFAULT NULL,
  UNIQUE KEY `f2` (`f2`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

we can find the AUTO_INCREMENT=4, but we expect AUTO_INCREMENT=3.

Suggested fix:
null
[29 Dec 2023 15:04] MySQL Verification Team
Hi,

Thank you for using MySQL. This is not a bug, you should not have expectations that are not based on SQL standard / MySQL documentation.