Copilot commented on code in PR #4117:
URL: https://github.com/apache/flink-cdc/pull/4117#discussion_r2731734984


##########
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 +78,19 @@ 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 
bigint unsigned to
+    // BigDecimal.
+    public static void setSafeObject(PreparedStatement ps, int parameterIndex, 
Object value)
+            throws SQLException {
+        if (value instanceof BigInteger) {
+            ps.setBigDecimal(parameterIndex, new BigDecimal((BigInteger) 
value));
+        } else {
+            ps.setObject(parameterIndex, value);

Review Comment:
   The PR description says `setSafeObject` “detects the overflow”, but the 
implementation converts *all* `BigInteger` values to `BigDecimal` (even when 
the value would fit in a signed `long`). If the JDBC driver returns 
`BigInteger` for all BIGINT UNSIGNED values (including small ones), this 
changes parameter typing from BIGINT to DECIMAL for every bound, which can 
affect query planning/index usage. Consider only converting when `value` is 
outside `Long.MIN_VALUE..Long.MAX_VALUE` (or when explicitly handling unsigned 
overflow), and otherwise keep `setObject`/`setLong` for the common case.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to