Skip to content

Commit f55ec5b

Browse files
Do not merge until v8.5.4: MySQL compatibility about decimal insert through jdbc (#22007)
1 parent 43fc1a9 commit f55ec5b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,17 @@ 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+
In MySQL, when you insert data into a `DECIMAL` column, if the number of decimal places exceeds the column's defined scale, MySQL automatically truncates the extra digits and inserts the truncated data successfully, regardless of how many extra decimal places there are.
316+
317+
In TiDB v8.5.3 and earlier versions:
318+
319+
- If the number of decimal places exceeds the defined scale but does not exceed 72, TiDB also automatically truncates the extra digits and inserts the truncated data successfully.
320+
- However, if the number of decimal places exceeds 72, the insertion fails and returns an error.
321+
322+
Starting from TiDB v8.5.4, TiDB aligns its behavior with MySQL: regardless of how many extra decimal places there are, it automatically truncates the extra digits and inserts the truncated data successfully.
323+
313324
## Next steps
314325
315326
- 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)