Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Fixed
-
10.0.8, 10.1(EOL)
-
10.1.8-4
Description
GREATEST and COALESCE return different data types
for a combination of TIME and DATE parameters:
mysql> SELECT GREATEST(CURRENT_TIME, CURRENT_DATE), COALESCE(CURRENT_TIME, CURRENT_DATE);
|
+--------------------------------------+--------------------------------------+
|
| GREATEST(CURRENT_TIME, CURRENT_DATE) | COALESCE(CURRENT_TIME, CURRENT_DATE) |
|
+--------------------------------------+--------------------------------------+
|
| 838:59:59 | 0000-00-00 16:24:54 |
|
+--------------------------------------+--------------------------------------+
|
1 row in set, 1 warning (0.00 sec)
|
 |
mysql> show warnings;
|
+---------+------+----------------------------------------------+
|
| Level | Code | Message |
|
+---------+------+----------------------------------------------+
|
| Warning | 1292 | Truncated incorrect time value: '1944:00:00' |
|
+---------+------+----------------------------------------------+
|
1 row in set (0.00 sec)
|
GREATEST returns TIME, which looks wrong.
COALESCE return DATETIME, which looks more correct.
(DATETIME is a minumal common type for DATE and TIME).
GREATEST should be fixed to return DATETIME as well.