Skip to content

Commit 0ecfde3

Browse files
authored
cherry-pick from v8.5.4: MySQL compatibility about decimal insert through jdbc (pingcap#22007) (pingcap#22446)
1 parent ff17cf8 commit 0ecfde3

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,17 @@ Unless you need to write complex SQL statements, it is recommended to use [ORM](
282282
- Reduce [boilerplate code](https://en.wikipedia.org/wiki/Boilerplate_code) for managing connections and transactions.
283283
- Manipulate data with data objects instead of a number of SQL statements.
284284
285+
### MySQL compatibility
286+
287+
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.
288+
289+
In TiDB v8.5.3 and earlier versions:
290+
291+
- 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.
292+
- However, if the number of decimal places exceeds 72, the insertion fails and returns an error.
293+
294+
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.
295+
285296
## Next steps
286297
287298
- 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)