Skip to content

Commit cd355c1

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

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

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

Lines changed: 12 additions & 1 deletion
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+
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
319+
insert the data successfully.
320+
- However, if the number of decimal places exceeds 72, the write operation will fail and return an error.
321+
322+
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.
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/).
@@ -329,4 +340,4 @@ Ask the community on [Discord](https://discord.gg/DQZ2dy3cuc?utm_source=doc) or
329340
330341
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/).
331342
332-
</CustomContent>
343+
</CustomContent>

0 commit comments

Comments
 (0)