Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.0(EOL), 10.1(EOL), 10.2(EOL)
-
None
-
10.2.11
Description
CAST from DATE to TIME usually returns zero time 00:00:00:
SELECT CAST(DATE'2001-01-01' AS TIME) |
+--------------------------------+
|
| CAST(DATE'2001-01-01' AS TIME) |
|
+--------------------------------+
|
| 00:00:00 |
|
+--------------------------------+
|
However, in some cases it works differently:
SELECT CAST(MAX(DATE'2001-01-01') AS TIME); |
SHOW WARNINGS;
|
+-------------------------------------+
|
| CAST(MAX(DATE'2001-01-01') AS TIME) |
|
+-------------------------------------+
|
| 00:20:01 |
|
+-------------------------------------+
|
1 row in set, 1 warning (0.00 sec)
|
 |
+---------+------+----------------------------------------------+
|
| Level | Code | Message |
|
+---------+------+----------------------------------------------+
|
| Warning | 1292 | Truncated incorrect time value: '2001-01-01' |
|
+---------+------+----------------------------------------------+
|
1 row in set (0.00 sec)
|
The problem happens because Item_sum_max does not implement its own get_date() method, so execution goes through the generic Item::get_date() which calls val_str() followed by string-to-time conversion.