Bug #96383 rs.getTimestamp() has different results for time fields with useCursorFetch=true
Submitted: 31 Jul 2019 9:42 Modified: 7 Jan 2020 19:15
Reporter: Slawomir Chodnicki Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:8.0.17 OS:Any
Assigned to: CPU Architecture:Any

[31 Jul 2019 9:42] Slawomir Chodnicki
Description:
When retrieving TIME values, using resultSet.getTimestamp() fractional seconds are truncated when using useCursorFetch=true.

How to repeat:
SET time_zone = 'UTC';

DROP TABLE IF EXISTS my_times;

CREATE TABLE my_times (
  id VARCHAR(10),
  x_time TIME(6)
);

INSERT INTO my_times VALUES(
  'time',
  '00:00:05.123'
);

The field holds a value of 5.123 seconds, or 5123 ms.

SELECT * FROM my_times WHERE id='time';

with useCursorFetch=false:
a call to resultSet.getTimestamp().getTime() returns 5123

with useCursorFetch=true:
a call to resultSet.getTimestamp().getTime() returns 5000

Suggested fix:
Fractional seconds should not be truncated from TIME fields with useCursorFetch=true
[31 Jul 2019 10:39] MySQL Verification Team
Hello Slawomir,

Thank you for the report.

regards,
Umesh
[7 Jan 2020 19:15] Daniel So
Posted by developer:
 
Added the following entry to the Connector/J 8.0.19 changelog:

"When retrieving TIME values, using ResultSet.getTimestamp(), the fractional seconds are truncated when useCursorFetch=true. This patch corrects the problem by fixing the TIME value decoding in the MysqlBinaryValueDecoder. It also corrects some inconsistencies in formatting the fractional seconds when returning the TIME values as strings."