Bug #22529 | TIMEDIFF() returns incorrectly in multiple-row SELECTS | ||
---|---|---|---|
Submitted: | 20 Sep 2006 18:18 | Modified: | 4 Dec 2006 11:08 |
Reporter: | Michael Furdyk | Email Updates: | |
Status: | Can't repeat | Impact on me: | |
Category: | MySQL Server | Severity: | S3 (Non-critical) |
Version: | 5.0.29-BK, 5.0.24 | OS: | Linux (Linux, RHEL4) |
Assigned to: | Ramil Kalimullin | CPU Architecture: | Any |
Tags: | timediff |
[20 Sep 2006 18:18]
Michael Furdyk
[20 Sep 2006 18:24]
Michael Furdyk
I have isolated the issue: If I remove the ORDER BY clause, the query works fine. So ORDER BY is somehow messing with the TIMEDIFF()
[20 Sep 2006 18:29]
MySQL Verification Team
Thank you for the bug report. Yes please provide the data sample, the wrong result you got and the expected result. Thanks in advance.
[21 Sep 2006 11:01]
Martin Friebe
the following will show the diff: (and is likely the same as what the original submitter experienced) select timediff('2004-06-09 00:01','2004-04-08 01:00'); +-------------------------------------------------+ | timediff('2004-06-09 00:01','2004-04-08 01:00') | +-------------------------------------------------+ | 1487:01:00 | +-------------------------------------------------+ 1 row in set (0.00 sec) select * from (select timediff('2004-06-09 00:01','2004-04-08 01:00') ) x; +-------------------------------------------------+ | timediff('2004-06-09 00:01','2004-04-08 01:00') | +-------------------------------------------------+ | 838:59:59 | +-------------------------------------------------+ 1 row in set, 1 warning (0.03 sec) There are several relevant bugs: bug #20293 , bug #20293 , bug #11655 , probably more. If I understand this correct, the bug is in the first result. Timediff returns a time-value, which should be cut off at 838:59:59. But this only happens if mysql is forced towrite the value to a (temporary) table, like in group by, order by, views, or nested queries also happens in 4.1
[20 Oct 2006 23:00]
Bugs System
No feedback was provided for this bug for over a month, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open".
[23 Oct 2006 5:15]
Michael Furdyk
Yes, Martin is correct. Hopefully this provides the info needed to fix?
[1 Nov 2006 11:24]
Valeriy Kravchuk
Verified just as described by Martin with 5.0.29_BK on Linux: mysql> select timediff('2004-06-09 00:01','2004-04-08 01:00'); +-------------------------------------------------+ | timediff('2004-06-09 00:01','2004-04-08 01:00') | +-------------------------------------------------+ | 1487:01:00 | +-------------------------------------------------+ 1 row in set (0.08 sec) mysql> select * from (select timediff('2004-06-09 00:01','2004-04-08 01:00') ) x; +-------------------------------------------------+ | timediff('2004-06-09 00:01','2004-04-08 01:00') | +-------------------------------------------------+ | 838:59:59 | +-------------------------------------------------+ 1 row in set, 1 warning (0.05 sec) mysql> show warnings\G *************************** 1. row *************************** Level: Warning Code: 1292 Message: Incorrect time value: '1487:01:00' for column 'timediff('2004-06-09 00: 01','2004-04-08 01:00')' at row 1 1 row in set (0.00 sec) mysql> select version(); +--------------+ | version() | +--------------+ | 5.0.29-debug | +--------------+ 1 row in set (0.04 sec)
[4 Dec 2006 11:08]
Ramil Kalimullin
Couldn't repeat using the latest trees.