RaigorJiang opened a new pull request, #40236:
URL: https://github.com/apache/shardingsphere/pull/40236

   ## Problem
   
   ShardingSphere-Proxy loses submillisecond precision when encoding a 
`java.sql.Timestamp` in a MySQL binary result row.
   
   The existing conversion handles `Timestamp` through the generic `Date` path 
and reconstructs it using `getTime()`, which only retains millisecond 
precision. As a result, `.123456` becomes `.123000`, and `.000001` becomes zero 
before the value reaches the existing microsecond encoder.
   
   This causes prepared-statement binary results to differ from direct MySQL 
results.
   
   ## Changes
   
   - Convert `Timestamp` directly through `toLocalDateTime()` before the 
generic `Date` fallback, preserving its fractional seconds for the existing 
microsecond encoding.
   - Preserve the existing wire layout and supported `Date`, `LocalDate`, and 
`LocalDateTime` behavior.
   - Strengthen parameterized tests to inspect the actual encoded bytes, 
including packet length, date and time fields, microseconds, and the absence of 
trailing bytes.
   - Add regression cases for six-digit fractions, a single microsecond, 
fractional trailing zeros, and midnight with a nonzero microsecond.
   
   This change is limited to Timestamp precision preservation in MySQL binary 
output. It does not change TIME encoding or result-set metadata.
   
   ## Verification
   
   - All 22 tests in `MySQLDateBinaryProtocolValueTest` pass.
   - All 494 tests in the MySQL protocol module pass, with no failures, errors, 
or skipped tests.
   - The target production class has full line coverage (64/64) and branch 
coverage (29/29).
   - Spotless and Checkstyle pass for both changed Java files.
   - A freshly built Proxy distribution was verified against MySQL 8.0.37 using 
Connector/J 8.4.0, with the driver installed separately.
   
   Real-environment verification compared direct MySQL and Proxy results using 
both text queries and actual server-prepared binary queries. It covered all 
four combinations of backend `useServerPrepStmts` and 
`treatMysqlDatetimeAsTimestamp`, confirming both Java `Timestamp` and 
`LocalDateTime` result paths.
   
   The unfixed encoder reproduced four precision mismatches. The fixed 
distribution completed 112 query comparisons with zero precision mismatches and 
passed 224 additional NULL/DATE checks. Verification used read-only 
`DATETIME(6)` constant queries and made no database changes.


-- 
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