[MDEV-31420] AUTO_INCREMENT increased incorrectly when INSERT INTO... SELECT Created: 2023-06-06  Updated: 2023-06-27

Status: Confirmed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.11.1, 10.6.12
Fix Version/s: 10.6

Type: Bug Priority: Minor
Reporter: Edward Stoever Assignee: Thirunarayanan Balathandayuthapani
Resolution: Unresolved Votes: 0
Labels: None


 Description   

create schema if not exists DD; use DD;
DROP TABLE IF EXISTS D1; DROP TABLE IF EXISTS D2;
CREATE TABLE D1 (`ID` int(11) PRIMARY KEY AUTO_INCREMENT, 
  `INFO` longtext DEFAULT NULL) ENGINE=InnoDB;
CREATE TABLE D2 (`ID` int(11) PRIMARY KEY AUTO_INCREMENT, 
  `SECTION` int(11) NOT NULL) ENGINE=InnoDB;
 
insert into D1 (`INFO`) values ('x');
insert into D1 (`INFO`) values ('x');
insert into D2 (`SECTION`) values (1);
insert into D2 (`SECTION`) select 2 as `SECTION` from D1;
insert into D2 (`SECTION`) values (1);
MariaDB [DD]> select * from D2;
+----+---------+
| ID | SECTION |
+----+---------+
|  1 |       1 |
|  2 |       2 |
|  3 |       2 |
|  5 |       1 |
+----+---------+
4 rows in set (0.000 sec)

Shouldn't the maximum ID value be 4?


Generated at Thu Feb 08 10:23:44 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.