Skip to content

Commit a6bf823

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

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
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/).

0 commit comments

Comments
 (0)