pingcap / pingcap/tidb

TiDB and MySQL get generated key different at INSERT ON DUPLICATE KEY

Open
#35,301 2 comments 0 reactions 0 assignees View on GitHub
severity/moderate sig/execution type/bug type/compatibility
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

I used `INSERT ... ON DUPLICATE KEY ...` statement to insert data. MySQL will add the PK of updated data to `GeneratedKeys`. TiDB will not do like that.

### 1. Minimal reproduce step (Required)

1. Install TiDB
2. Install MySQL
3. Clone this [code](https://github.com/Icemap/tidb-java-gitpod/tree/on-duplicate-key-generated-keys)
4. Point [JDBC URL](https://github.com/Icemap/tidb-java-gitpod/blob/on-duplicate-key-generated-keys/src/main/java/com/pingcap/App.java#L17) to TiDB host
5. Run `mvn clean package && java -jar target/tidb-java-gitpod-0.0.1-jar-with-dependencies.jar`
6. Point `JDBC URL` to MySQL host
7. Run `mvn clean package && java -jar target/tidb-java-gitpod-0.0.1-jar-with-dependencies.jar`
8. Outputs are not same

### 2. What did you expect to see? (Required)

[1, 2, 3]
[4]
[8]
[8]

### 3. What did you see instead (Required)

[1, 2, 3]
[4]
[8]
[]

### 4. What is your TiDB version? (Required)

5.7.25-TiDB-None (master branch)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.