Commit b16ad3ba authored by Tatiana A. Nurnberg's avatar Tatiana A. Nurnberg

Bug#42525: TIMEDIFF function

In 37553 we declared longlong results for
class Item_str_timefunc as per comments/docs,
but didn't add a method for that. And the
default just wasn't good enough for some
cases.

Changeset adds dedicated val_int() to class.
parent d36d50f4
...@@ -268,3 +268,17 @@ timediff('2008-09-29 20:10:10','2008-09-30 20:10:10')<time('00:00:00') ...@@ -268,3 +268,17 @@ timediff('2008-09-29 20:10:10','2008-09-30 20:10:10')<time('00:00:00')
SELECT CAST(time('-73:42:12') AS DECIMAL); SELECT CAST(time('-73:42:12') AS DECIMAL);
CAST(time('-73:42:12') AS DECIMAL) CAST(time('-73:42:12') AS DECIMAL)
-734212 -734212
SELECT TIMEDIFF(TIME('17:00:00'),TIME('17:00:00'))=TIME('00:00:00') AS 1Eq,
TIMEDIFF(TIME('17:59:00'),TIME('17:00:00'))=TIME('00:00:00') AS 1NEq1,
TIMEDIFF(TIME('18:00:00'),TIME('17:00:00'))=TIME('00:00:00') AS 1NEq2,
TIMEDIFF(TIME('17:00:00'),TIME('17:00:00'))= '00:00:00' AS 2Eq,
TIMEDIFF(TIME('17:59:00'),TIME('17:00:00'))= '00:00:00' AS 2NEq1,
TIMEDIFF(TIME('18:00:00'),TIME('17:00:00'))= '00:00:00' AS 2NEq2,
TIMEDIFF(TIME('17:00:00'),TIME('17:00:00'))=TIME(0) AS 3Eq,
TIMEDIFF(TIME('17:59:00'),TIME('17:00:00'))=TIME(0) AS 3NEq1,
TIMEDIFF(TIME('18:00:00'),TIME('17:00:00'))=TIME(0) AS 3NEq2,
TIME(0) AS Time0, TIME('00:00:00') AS Time00, '00:00:00' AS Literal0000,
TIMEDIFF(TIME('17:59:00'),TIME('17:00:00')),
TIMEDIFF(TIME('17:00:00'),TIME('17:59:00'));
1Eq 1NEq1 1NEq2 2Eq 2NEq1 2NEq2 3Eq 3NEq1 3NEq2 Time0 Time00 Literal0000 TIMEDIFF(TIME('17:59:00'),TIME('17:00:00')) TIMEDIFF(TIME('17:00:00'),TIME('17:59:00'))
1 0 0 1 0 0 1 0 0 00:00:00 00:00:00 00:00:00 00:59:00 -00:59:00
...@@ -151,4 +151,22 @@ select timediff('2008-09-29 20:10:10','2008-09-30 20:10:10')<time('00:00:00'); ...@@ -151,4 +151,22 @@ select timediff('2008-09-29 20:10:10','2008-09-30 20:10:10')<time('00:00:00');
SELECT CAST(time('-73:42:12') AS DECIMAL); SELECT CAST(time('-73:42:12') AS DECIMAL);
#
# Bug#42525 - TIMEDIFF function
#
SELECT TIMEDIFF(TIME('17:00:00'),TIME('17:00:00'))=TIME('00:00:00') AS 1Eq,
TIMEDIFF(TIME('17:59:00'),TIME('17:00:00'))=TIME('00:00:00') AS 1NEq1,
TIMEDIFF(TIME('18:00:00'),TIME('17:00:00'))=TIME('00:00:00') AS 1NEq2,
TIMEDIFF(TIME('17:00:00'),TIME('17:00:00'))= '00:00:00' AS 2Eq,
TIMEDIFF(TIME('17:59:00'),TIME('17:00:00'))= '00:00:00' AS 2NEq1,
TIMEDIFF(TIME('18:00:00'),TIME('17:00:00'))= '00:00:00' AS 2NEq2,
TIMEDIFF(TIME('17:00:00'),TIME('17:00:00'))=TIME(0) AS 3Eq,
TIMEDIFF(TIME('17:59:00'),TIME('17:00:00'))=TIME(0) AS 3NEq1,
TIMEDIFF(TIME('18:00:00'),TIME('17:00:00'))=TIME(0) AS 3NEq2,
TIME(0) AS Time0, TIME('00:00:00') AS Time00, '00:00:00' AS Literal0000,
TIMEDIFF(TIME('17:59:00'),TIME('17:00:00')),
TIMEDIFF(TIME('17:00:00'),TIME('17:59:00'));
# End of 5.0 tests # End of 5.0 tests
...@@ -398,6 +398,7 @@ class Item_str_timefunc :public Item_str_func ...@@ -398,6 +398,7 @@ class Item_str_timefunc :public Item_str_func
{ {
return save_time_in_field(field); return save_time_in_field(field);
} }
longlong val_int() { return val_int_from_decimal(); }
bool result_as_longlong() { return TRUE; } bool result_as_longlong() { return TRUE; }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment