Skip to content

Commit 108f4a3

Browse files
committed
tiflash: MySQL compatibility about decimal insert through jdbc
1 parent 09a0d64 commit 108f4a3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

develop/dev-guide-sample-application-java-jdbc.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,16 @@ Unless you need to write complex SQL statements, it is recommended to use [ORM](
310310
- Reduce [boilerplate code](https://en.wikipedia.org/wiki/Boilerplate_code) for managing connections and transactions.
311311
- Manipulate data with data objects instead of a number of SQL statements.
312312
313+
### MySQL compatibility
314+
315+
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.
316+
317+
In TiDB versions v8.1.2 and earlier:
318+
- 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.
319+
- However, if the number of decimal places exceeds 72, the write operation will fail and return an error.
320+
321+
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.
322+
313323
## Next steps
314324
315325
- 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
329339
330340
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/).
331341
332-
</CustomContent>
342+
</CustomContent>

0 commit comments

Comments
 (0)