Bug #42146 DATETIME fractional seconds parse error
Submitted: 16 Jan 2009 2:53 Modified: 14 Mar 2009 1:44
Reporter: John Romine (OCA) Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:5.1.30 OS:Linux (RHEL 5)
Assigned to: Tatiana Azundris Nuernberg CPU Architecture:Any
Tags: Contribution, datetime, microseconds

[16 Jan 2009 2:53] John Romine
If the fractional seconds component of a DATETIME has more
than six digits, or has leading zeros, it is mis-parsed.

This is not a repeat of Bug #38435 as the parser returns
a wrong result in this case.

The fix attached should correct this bug as well as #38435.

How to repeat:
mysql> select CAST('2006-08-10 10:11:12.0123450' AS DATETIME);
| CAST('2006-08-10 10:11:12.0123450' AS DATETIME) |
| 2006-08-10 10:11:12.123450                      |

result should be 2006-08-10 10:11:12.012345

Suggested fix:
see attach patch
[16 Jan 2009 2:55] John Romine
patch to sql-common/my_time.c

Attachment: patch.txt (text/plain), 2.46 KiB.

[16 Jan 2009 3:02] John Romine
add tags
[16 Jan 2009 5:17] Valeriy Kravchuk
Thank you for the bug report and patch contributed.
[13 Feb 2009 18:15] 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:


2794 Tatiana A. Nurnberg	2009-02-13
      Bug#42146 - DATETIME fractional seconds parse error
      Bug#38435 - LONG Microseconds cause MySQL to fail a CAST to DATETIME or DATE
      Parsing of optional microsecond part in datetime did not
      fail gracefully when field width was larger than the allowed
      six places.
      Now handles up to the correct six places, and disregards
      any extra digits without messing up what we've already got.
[13 Feb 2009 18:43] Tatiana Azundris Nuernberg
patch queued for 5.1.32, 6.0.10 in -bugteam
[19 Feb 2009 13:03] Bugs System
Pushed into 6.0.10-alpha (revid:sergey.glukhov@sun.com-20090218125737-5y5b2xo3duo1wlvo) (version source revid:azundris@mysql.com-20090213181016-5p7fvpozygkoplo9) (merge vers: 6.0.10-alpha) (pib:6)
[27 Feb 2009 20:59] Paul Dubois
Noted in 6.0.10 changelog.

Parsing of the optional microsecond component of DATETIME values did
not fail gracefully when that component width was larger than the
allowed six places.

Setting report to NDI pending push into 5.1.x.
[13 Mar 2009 19:07] Bugs System
Pushed into 5.1.33 (revid:joro@sun.com-20090313111355-7bsi1hgkvrg8pdds) (version source revid:vvaintroub@mysql.com-20090218093153-sjzxf01i4ezte0xp) (merge vers: 5.1.33) (pib:6)
[14 Mar 2009 1:44] Paul Dubois
Noted in 5.1.33 changelog.
[9 May 2009 16:46] Bugs System
Pushed into 5.1.34-ndb-6.2.18 (revid:jonas@mysql.com-20090508185236-p9b3as7qyauybefl) (version source revid:jonas@mysql.com-20090508100057-30ote4xggi4nq14v) (merge vers: 5.1.33-ndb-6.2.18) (pib:6)
[9 May 2009 17:43] Bugs System
Pushed into 5.1.34-ndb-6.3.25 (revid:jonas@mysql.com-20090509063138-1u3q3v09wnn2txyt) (version source revid:jonas@mysql.com-20090508175813-s6yele2z3oh6o99z) (merge vers: 5.1.33-ndb-6.3.25) (pib:6)
[9 May 2009 18:41] Bugs System
Pushed into 5.1.34-ndb-7.0.6 (revid:jonas@mysql.com-20090509154927-im9a7g846c6u1hzc) (version source revid:jonas@mysql.com-20090509073226-09bljakh9eppogec) (merge vers: 5.1.33-ndb-7.0.6) (pib:6)