Bug #42661 sec_to_time() and signedness
Submitted: 6 Feb 2009 18:55 Modified: 7 Mar 2010 12:54
Reporter: Tatiana Azundris Nuernberg Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Data Types Severity:S3 (Non-critical)
Version:5.0+ OS:Any
Assigned to: Tatiana Azundris Nuernberg CPU Architecture:Any

[6 Feb 2009 18:55] Tatiana Azundris Nuernberg
Description:
Once again, we seem to lose the signs o' the times.

How to repeat:
SELECT sec_to_time(3020399)=time('838:59:59');
1
SELECT sec_to_time(-3020399)=time('-838:59:59');
0
SELECT sec_to_time(-3020399)='-838:59:59';
1
SELECT time(sec_to_time(-3020399))=time('-838:59:59');
1
SELECT time(sec_to_time(-3020399))=time('-838:59:58');
1

This is possibly not what we want, especially seeing as docs say that sec_to_time() returns, perchance unsurprisingly, TIME, so wrapping it in another time() seems somewhat off.

Suggested fix:
Give it to Tatiana.
[6 Feb 2009 19:08] MySQL Verification Team
Thank you for the bug report.
[9 Feb 2009 5:29] 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/65566

2739 Tatiana A. Nurnberg	2009-02-09
      Bug#42661: sec_to_time() and signedness
      Bug#42662: maketime() and signedness
      
      Item_time_typecast::val_int() dropped sign from
      MYSQL_TIME gotten using from get_time().
      
      Propagates sign now.
[9 Apr 2009 11:53] Georgi Kodinov
OK to push. Maybe it's a good idea to make the implicit casts to TIME explicit, just to be more clear what's going on.
[15 Apr 2009 16:32] Tatiana Azundris Nuernberg
patch queued for 6.0.11 in -bugteam
[6 May 2009 14:06] Bugs System
Pushed into 6.0.12-alpha (revid:svoj@sun.com-20090506125450-yokcmvqf2g7jhujq) (version source revid:azundris@mysql.com-20090414213640-3grwghkd2fkijx9m) (merge vers: 6.0.11-alpha) (pib:6)
[12 May 2009 1:36] Paul DuBois
Noted in 6.0.12 changelog.

SEC_TO_TIME() could lose the sign of negative arguments.
[4 Nov 2009 8:55] 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/89255

2906 Magne Mahre	2009-11-04 [merge]
      Bug#42661: sec_to_time() and signedness
      Bug#42662: maketime() and signedness
            
      Item_time_typecast::val_int() dropped sign from
      MYSQL_TIME gotten using from get_time().
            
      Propagates sign now.
      
      
      Backported to 5.5.0  (6.0-codebase revid: 1810.3897.1)
[4 Nov 2009 8:56] Magne Mæhre
Correction.
Backported to 5.6.0, not 5.5.0
[20 Nov 2009 12:54] Bugs System
Pushed into 5.6.0-beta (revid:davi.arnaut@sun.com-20091119234808-xbjpkwaxjt5x5c0b) (version source revid:jon.hauglid@sun.com-20090928163426-2lg1gofzz44xzzxf) (merge vers: 6.0.14-alpha) (pib:13)
[20 Nov 2009 12:57] Bugs System
Pushed into 6.0.14-alpha (revid:kostja@sun.com-20091120124947-yi6h2jbgw0kbciwm) (version source revid:jon.hauglid@sun.com-20090928163426-2lg1gofzz44xzzxf) (merge vers: 6.0.14-alpha) (pib:13)
[20 Nov 2009 23:45] Paul DuBois
Noted in 5.6.0 changelog.
[6 Mar 2010 11:07] Bugs System
Pushed into 5.5.3-m3 (revid:alik@sun.com-20100306103849-hha31z2enhh7jwt3) (version source revid:jon.hauglid@sun.com-20090928163426-2lg1gofzz44xzzxf) (merge vers: 6.0.14-alpha) (pib:16)
[7 Mar 2010 12:54] Paul DuBois
Moved 5.6.0 changelog entry to 5.5.3.