Bug #34913 getNativeTimestamp returns random Month and Day versions 5.1.1 through 5.1.5

Submitted: 27 Feb 2008 23:08 Modified: 1 Mar 2008 12:31
Reporter: Harald Rudell Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:5.1.5 OS:Any
Assigned to: CPU Architecture:Any
Tags: date, random, timestamp

[27 Feb 2008 23:08] Harald Rudell
Description:
On examining timestamp fields in text form, the month and the day from the timetamp have random values

in com.mysql.jdbc.ResultSetRow.getNativeTimestamp, lines 646, 647 the offset variable is missing:

correct
			month = bits[offset + 2];
			day = bits[offset + 3];

incorrect (5.1.1-5.1.5)
			month = bits[2];
			day = bits[3];

so a ResultSet.getString("myTimestampFieldname") produces random month and day values, while year and time of day are correct

How to repeat:
test case goes here

Suggested fix:
correct lines 646,647 of ResultSetRow.java
			month = bits[offset + 2];
			day = bits[offset + 3];
[28 Feb 2008 5:34] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/43127
[1 Mar 2008 12:31] MC Brown
A note has been added to the 5.1.6 changelog: 

ResultSet.getTimestamp() returns incorrect values for month/day of TIMESTAMPs when using server-side prepared statements (not enabled by default).
[30 Jul 2008 14:53] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/50724

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.038 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.