suhwan-cheon commented on code in PR #4117:
URL: https://github.com/apache/flink-cdc/pull/4117#discussion_r2359548090


##########
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/source/utils/StatementUtils.java:
##########
@@ -76,6 +77,18 @@ public static long queryApproximateRowCnt(JdbcConnection 
jdbc, TableId tableId)
                 });
     }
 
+    // PreparedStatement#setObject method will be converted to long type when 
handling bigint unsigned, which poses a data overflow issue.
+    // Therefore, we need to handle the overflow issue by converting the long 
value to BigDecimal.
+    public static void setSafeObject(PreparedStatement ps, int parameterIndex, 
Object value)
+            throws SQLException {
+        if (value instanceof Long && (Long) value < 0L) {

Review Comment:
   @lvyanquan 
   Hello! I added itcase in MySqlSourceITCase.
   
   I think JDBC may surface BIGINT UNSIGNED as Long (values > Long.MAX_VALUE 
appear negative due to two’s complement)
   So In this code, 1) detect negative Longs 2) bind them as BigInteger, 
ensuring values near 2^64−1 are handled correctly.
   I Added an IT in MySqlSourceITCase that creates unsigned_bigint_pk and 
verifies boundary values. And I saw that the test worked well.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to