Bug #83090 | AUTO_INCREMENT not updated when using INSERT ON DUPLICATE KEY UPDATE | ||
---|---|---|---|
Submitted: | 22 Sep 2016 2:13 | Modified: | 22 Sep 2016 7:22 |
Reporter: | monty solomon | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Row Based Replication ( RBR ) | Severity: | S1 (Critical) |
Version: | 5.7.13, 5.7.15 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[22 Sep 2016 2:13]
monty solomon
[22 Sep 2016 2:20]
monty solomon
Now execute the following statements on the Master ALTER TABLE monty ADD COLUMN dummy BOOL NOT NULL DEFAULT '0'; mysql> INSERT INTO monty SET stub='foo' ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id+1), dummy=NOT dummy; ERROR 1062 (23000): Duplicate entry '2' for key 'PRIMARY' mysql> INSERT INTO monty SET stub='foo' ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id+1), dummy=NOT dummy; ERROR 1062 (23000): Duplicate entry '2' for key 'PRIMARY' mysql> SHOW CREATE TABLE monty\G *************************** 1. row *************************** Table: monty Create Table: CREATE TABLE `monty` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `stub` char(15) NOT NULL, `dummy` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `stub` (`stub`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC 1 row in set (0.00 sec) Observe that the AUTO_INCREMENT value was incremented to six (6) even though the statements failed with ERROR 1062. On the Slave observe that the AUTO_INCREMENT value is still three (3) mysql> SHOW CREATE TABLE monty\G *************************** 1. row *************************** Table: monty Create Table: CREATE TABLE `monty` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `stub` char(15) NOT NULL, `dummy` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `stub` (`stub`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC 1 row in set (0.00 sec)
[22 Sep 2016 7:22]
MySQL Verification Team
Hello monty, Thank you for the report. Observed this with 5.7.15 build. Thanks, Umesh