From 108f4a30bba0f4be98dfdbc459ce9e2fae6a4277 Mon Sep 17 00:00:00 2001 From: ChangRui-Ryan Date: Thu, 28 Aug 2025 20:35:36 +0800 Subject: [PATCH 1/3] tiflash: MySQL compatibility about decimal insert through jdbc --- develop/dev-guide-sample-application-java-jdbc.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/develop/dev-guide-sample-application-java-jdbc.md b/develop/dev-guide-sample-application-java-jdbc.md index 3e725f887b0de..c3300fc1f1350 100644 --- a/develop/dev-guide-sample-application-java-jdbc.md +++ b/develop/dev-guide-sample-application-java-jdbc.md @@ -310,6 +310,16 @@ Unless you need to write complex SQL statements, it is recommended to use [ORM]( - Reduce [boilerplate code](https://en.wikipedia.org/wiki/Boilerplate_code) for managing connections and transactions. - Manipulate data with data objects instead of a number of SQL statements. +### MySQL compatibility + +When inserting data of the DECIMAL type, if the number of decimal places exceeds the number defined for the field, MySQL will perform a TRUNCATE operation and insert the data successfully, regardless of how many extra decimal places there are. + +In TiDB versions v8.1.2 and earlier: +- If the number of decimal places exceeds the field's defined limit but does not exceed 72, TiDB will also perform a TRUNCATE and insert the data successfully. +- However, if the number of decimal places exceeds 72, the write operation will fail and return an error. + +Starting from TiDB v8.1.3, TiDB's behavior aligns with that of MySQL: regardless of how many decimal places are exceeded, it will perform a TRUNCATE operation and insert the data successfully. + ## Next steps - Learn more usage of MySQL Connector/J from [the documentation of MySQL Connector/J](https://dev.mysql.com/doc/connector-j/en/). @@ -329,4 +339,4 @@ Ask the community on [Discord](https://discord.gg/DQZ2dy3cuc?utm_source=doc) or Ask the community on [Discord](https://discord.gg/DQZ2dy3cuc?utm_source=doc) or [Slack](https://slack.tidb.io/invite?team=tidb-community&channel=everyone&ref=pingcap-docs), or [submit a support ticket](https://tidb.support.pingcap.com/). - + \ No newline at end of file From 069dc525e546f7178bdb768ee81055ee46029ddc Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Fri, 29 Aug 2025 09:09:27 +0800 Subject: [PATCH 2/3] Update develop/dev-guide-sample-application-java-jdbc.md Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- develop/dev-guide-sample-application-java-jdbc.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/develop/dev-guide-sample-application-java-jdbc.md b/develop/dev-guide-sample-application-java-jdbc.md index c3300fc1f1350..b78688febbdb0 100644 --- a/develop/dev-guide-sample-application-java-jdbc.md +++ b/develop/dev-guide-sample-application-java-jdbc.md @@ -312,13 +312,13 @@ Unless you need to write complex SQL statements, it is recommended to use [ORM]( ### MySQL compatibility -When inserting data of the DECIMAL type, if the number of decimal places exceeds the number defined for the field, MySQL will perform a TRUNCATE operation and insert the data successfully, regardless of how many extra decimal places there are. +When you insert data into a `DECIMAL` column, if the number of decimal places exceeds the defined scale, MySQL performs a `TRUNCATE` operation and inserts the data successfully, regardless of how many extra decimal places there are. In TiDB versions v8.1.2 and earlier: -- If the number of decimal places exceeds the field's defined limit but does not exceed 72, TiDB will also perform a TRUNCATE and insert the data successfully. -- However, if the number of decimal places exceeds 72, the write operation will fail and return an error. +- If the number of decimal places exceeds the column's defined scale but does not exceed 72, TiDB also performs a `TRUNCATE` operation and inserts the data successfully. +- However, if the number of decimal places exceeds 72, the write operation fails and returns an error. -Starting from TiDB v8.1.3, TiDB's behavior aligns with that of MySQL: regardless of how many decimal places are exceeded, it will perform a TRUNCATE operation and insert the data successfully. +Starting from TiDB v8.1.3, TiDB's behavior aligns with that of MySQL: regardless of the number of excess decimal places, it performs a `TRUNCATE` operation and inserts the data successfully. ## Next steps From dd0d31ccde54fff1e1890eef5eb77a2def66aa3b Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Fri, 29 Aug 2025 09:20:56 +0800 Subject: [PATCH 3/3] Update develop/dev-guide-sample-application-java-jdbc.md --- develop/dev-guide-sample-application-java-jdbc.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/develop/dev-guide-sample-application-java-jdbc.md b/develop/dev-guide-sample-application-java-jdbc.md index b78688febbdb0..e6bf529215b3e 100644 --- a/develop/dev-guide-sample-application-java-jdbc.md +++ b/develop/dev-guide-sample-application-java-jdbc.md @@ -314,7 +314,8 @@ Unless you need to write complex SQL statements, it is recommended to use [ORM]( When you insert data into a `DECIMAL` column, if the number of decimal places exceeds the defined scale, MySQL performs a `TRUNCATE` operation and inserts the data successfully, regardless of how many extra decimal places there are. -In TiDB versions v8.1.2 and earlier: +In TiDB v8.1.2 and earlier versions: + - If the number of decimal places exceeds the column's defined scale but does not exceed 72, TiDB also performs a `TRUNCATE` operation and inserts the data successfully. - However, if the number of decimal places exceeds 72, the write operation fails and returns an error.