| Bug #74354 | REPLACE INTO affected_rows wrong | ||
|---|---|---|---|
| Submitted: | 13 Oct 2014 10:44 | Modified: | 13 Oct 2014 14:19 |
| Reporter: | Ulf Wendel | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | MySQL Server: DML | Severity: | S2 (Serious) |
| Version: | 5.7.5, 8.0.23, 5.7.33 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
[13 Oct 2014 10:44]
Ulf Wendel
[13 Oct 2014 14:19]
MySQL Verification Team
Hello Ulf Wendel, Thank you for the bug report and test case. Thanks, Umesh
[13 Oct 2014 14:20]
MySQL Verification Team
// 5.1.73, 5.5.41, 5.6.22 and 5.7.6 - affected
mysql> use test
Database changed
mysql>
mysql> CREATE TABLE `test` (
-> `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-> `data` varchar(64) DEFAULT NULL,
-> `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-> PRIMARY KEY (`id`)
-> ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
Query OK, 0 rows affected (0.11 sec)
mysql> delete from test;
Query OK, 0 rows affected (0.00 sec)
mysql> replace into test(id, data) values (1, 'a');
Query OK, 1 row affected (0.07 sec)
mysql> replace into test(id, data) values (1, 'a');
Query OK, 2 rows affected (0.07 sec)
mysql> replace into test(id, data) values (1, 'a');
Query OK, 2 rows affected (0.06 sec)
mysql> alter table test drop ts;
Query OK, 1 row affected (0.24 sec)
Records: 1 Duplicates: 0 Warnings: 0
mysql> delete from test;
Query OK, 1 row affected (0.07 sec)
mysql> show create table test\G
*************************** 1. row ***************************
Table: test
Create Table: CREATE TABLE `test` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`data` varchar(64) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
mysql> replace into test(id, data) values (1, 'a');
Query OK, 1 row affected (0.07 sec)
mysql> replace into test(id, data) values (1, 'a');
Query OK, 1 row affected (0.07 sec)
mysql> replace into test(id, data) values (1, 'a');
Query OK, 1 row affected (0.20 sec)
[14 Oct 2014 9:55]
Andrey Hristov
The bug seems to be in InnoDB. MyISAM behaves correctly. mysql> CREATE TABLE `test` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `data` varchar(64) DEFAULT NULL, `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=myisam AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; Query OK, 0 rows affected (0,00 sec) mysql> replace into test(id, data) values (1, 'a'); Query OK, 1 row affected (0,00 sec) mysql> replace into test(id, data) values (1, 'a'); Query OK, 2 rows affected (0,00 sec) mysql> replace into test(id, data) values (1, 'a'); Query OK, 2 rows affected (0,00 sec) mysql> alter table test drop ts; Query OK, 1 row affected (0,00 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> delete from test; Query OK, 1 row affected (0,00 sec) mysql> replace into test(id, data) values (1, 'a'); Query OK, 1 row affected (0,00 sec) mysql> replace into test(id, data) values (1, 'a'); Query OK, 2 rows affected (0,00 sec) mysql> replace into test(id, data) values (1, 'a'); Query OK, 2 rows affected (0,01 sec) mysql> show create table test; +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | test | CREATE TABLE `test` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `data` varchar(64) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 | +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0,00 sec) mysql> alter table test engine=innodb; Query OK, 1 row affected (0,02 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> delete from test; Query OK, 1 row affected (0,00 sec) mysql> replace into test(id, data) values (1, 'a'); Query OK, 1 row affected (0,00 sec) mysql> replace into test(id, data) values (1, 'a'); Query OK, 1 row affected (0,00 sec)
[12 Mar 2021 6:06]
MySQL Verification Team
Bug #102940 marked as duplicate of this one
