Bug #81254 Using INSERT_ID local variable, makes REPLACE fail when there is a duplicate key
| Submitted: | 1 May 2016 7:53 | Modified: | 2 May 2016 10:08 |
|---|---|---|---|
| Reporter: | Miguel Angel Nieto | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | MySQL Server: DML | Severity: | S2 (Serious) |
| Version: | 5.6, 5.6.30, 5.7.12 | OS: | Any |
| Assigned to: | CPU Architecture: | Any |
[1 May 2016 7:53]
Miguel Angel Nieto
[1 May 2016 8:21]
Miguel Angel Nieto
In order to make the replication fail, you need to add some data inconsistency. For example: Master's PK goes from 1 to 3. Slaves' PK goes from 1 to 4. If you run a REPLACE on the master, it will be logged with SET SESSION_ID=4, and that will make slave to fail (when it should just DELETE and INSERT). To make the REPLACE fail without replication, just set INSERT_ID and it will behave as it was a normal INSERT.
[1 May 2016 9:31]
Miguel Angel Nieto
CREATE TABLE `test_import_data` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`idFile` int(11) NOT NULL,
`line` int(11) NOT NULL,
`email` varchar(255) NOT NULL,
`status` enum('Failed','Success','Duplicated') NOT NULL DEFAULT 'Failed',
`reason` text NOT NULL,
PRIMARY KEY (`id`),
KEY `idFile` (`idFile`)
) ENGINE=InnoDB;
[2 May 2016 10:08]
MySQL Verification Team
Hello Miguel, Thank you for the report and test case. Observed this with 5.6.30/5.7.12. Thanks, Umesh
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.068 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.