Bug #92813 insert ..on duplicate key update return 0 rows affected
Description:
When the table's self-increment exceeds its maximum, insert.. on duplicate key update can be executed normally, but the data is not written and updated. Normal should prompt the primary key conflict, and SQL execution fails.
How to repeat:
mysql> show create table at_test\G
*************************** 1. row ***************************
Table: at_test
Create Table: CREATE TABLE `at_test` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id',
`vid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'vid',
`tag` text COMMENT 'tag',
PRIMARY KEY (`id`),
UNIQUE KEY `uniq_vid` (`vid`)
) ENGINE=InnoDB AUTO_INCREMENT=4294967295 DEFAULT CHARSET=utf8mb4 COMMENT='vid info表'
1 row in set (0.00 sec)
mysql> select * from at_test;
+------------+-----+------+
| id | vid | tag |
+------------+-----+------+
| 4294967295 | 1 | 1111 |
+------------+-----+------+
1 row in set (0.00 sec)
mysql> insert into at_test(vid,tag)values(1,'2222') on duplicate key update tag = values(tag);
Query OK, 2 rows affected (0.00 sec)
mysql> select * from at_test;
+------------+-----+------+
| id | vid | tag |
+------------+-----+------+
| 4294967295 | 1 | 2222 |
+------------+-----+------+
1 row in set (0.00 sec)
insert.. on duplicate key update:
mysql> insert into at_test(vid,tag)values(2,'2222') on duplicate key update tag = values(tag);
Query OK, 0 rows affected (0.00 sec)
mysql> select * from at_test;
+------------+-----+------+
| id | vid | tag |
+------------+-----+------+
| 4294967295 | 1 | 2222 |
+------------+-----+------+
1 row in set (0.00 sec)
but insert :
mysql> insert into at_test(vid,tag)values(2,'2222');
ERROR 1062 (23000): Duplicate entry '4294967295' for key 'PRIMARY'
Suggested fix:
"insert ..on duplicate key update " and "Insert into" should return the same value
(ERROR 1062 (23000): Duplicate entry)
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.050 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.
Description: When the table's self-increment exceeds its maximum, insert.. on duplicate key update can be executed normally, but the data is not written and updated. Normal should prompt the primary key conflict, and SQL execution fails. How to repeat: mysql> show create table at_test\G *************************** 1. row *************************** Table: at_test Create Table: CREATE TABLE `at_test` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id', `vid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'vid', `tag` text COMMENT 'tag', PRIMARY KEY (`id`), UNIQUE KEY `uniq_vid` (`vid`) ) ENGINE=InnoDB AUTO_INCREMENT=4294967295 DEFAULT CHARSET=utf8mb4 COMMENT='vid info表' 1 row in set (0.00 sec) mysql> select * from at_test; +------------+-----+------+ | id | vid | tag | +------------+-----+------+ | 4294967295 | 1 | 1111 | +------------+-----+------+ 1 row in set (0.00 sec) mysql> insert into at_test(vid,tag)values(1,'2222') on duplicate key update tag = values(tag); Query OK, 2 rows affected (0.00 sec) mysql> select * from at_test; +------------+-----+------+ | id | vid | tag | +------------+-----+------+ | 4294967295 | 1 | 2222 | +------------+-----+------+ 1 row in set (0.00 sec) insert.. on duplicate key update: mysql> insert into at_test(vid,tag)values(2,'2222') on duplicate key update tag = values(tag); Query OK, 0 rows affected (0.00 sec) mysql> select * from at_test; +------------+-----+------+ | id | vid | tag | +------------+-----+------+ | 4294967295 | 1 | 2222 | +------------+-----+------+ 1 row in set (0.00 sec) but insert : mysql> insert into at_test(vid,tag)values(2,'2222'); ERROR 1062 (23000): Duplicate entry '4294967295' for key 'PRIMARY' Suggested fix: "insert ..on duplicate key update " and "Insert into" should return the same value (ERROR 1062 (23000): Duplicate entry)