[FLINK-38247] Handle BIGINT UNSIGNED overflow in PreparedStatement
issue: https://issues.apache.org/jira/browse/FLINK-38247
Issue
An infinite loop occurred when using the MySqlChunkSplitter to split a table with a MySQL BIGINT UNSIGNED primary key. (This problem happens when the primary key value exceeds Long.MAX_VALUE)
Solution
I added StatementUtils.setSafeObject to detects the overflow and correctly converts the value to a BigDecimal before setting it in the PreparedStatement.
Verification
- I added
StatementUtilsTestto verify the correctness ofStatementUtils.setSafeObject. - I used Java's dynamic proxy (
createPreparedStatementProxy) to avoid creating a verbose mock class, simplifying the test code.
Please add an itcase in MySqlSourceITCase.
Run 'mvn spotless:apply' to fix these violations.
Run 'mvn spotless:apply' to fix these violations.
I've applied it. Can you run the test again?
there's a Checkstyle error. I'm not used to this environment, so I made a mistake.
I've fixed Checkstyle error and ran the MySQL connector unit tests with mvn -pl flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc -DskipITs=true test
please review.