Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Not a Bug
-
10.6.13
-
None
Description
When we use ON DUPLICATE UPDATE syntax to insert data, CURRENT_TIMESTAMP in primary key, we get wrong answer.
How to repeat:
we can repeat this by mysql-test.
create one file named 'test_update.test' in directory mysql-test/main
The content of 'test_update.test' is:
CREATE TABLE `test_up`(
|
`ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
`data` int, |
PRIMARY KEY(`ts`)
|
);
|
|
INSERT INTO test_up VALUES("2023-05-29 17:34:55.01", 1); |
|
INSERT INTO test_up VALUES("2023-05-29 17:34:55.01", 2) ON DUPLICATE KEY UPDATE data=2; |
INSERT INTO test_up VALUES("2023-05-29 17:34:55.01", 3) ON DUPLICATE KEY UPDATE data=3; |
INSERT INTO test_up VALUES("2023-05-29 17:34:55.01", 4) ON DUPLICATE KEY UPDATE data=4; |
now, we can use this command in directory mysql-test:
./mtr main.test_update
|
now, the wrong answer is:
mysqltest: At line 11: Query 'INSERT INTO test_up VALUES("2023-05-29 17:34:55.01", 4) ON DUPLICATE KEY UPDATE data=4' failed. |
ERROR 1062 (23000): Duplicate entry '2023-05-29 12:42:03' for key 'test_up.PRIMARY' |