[MDEV-5694] GREATEST(date, time) returns a wrong data type Created: 2014-02-17  Updated: 2015-10-01  Resolved: 2015-10-01

Status: Closed
Project: MariaDB Server
Component/s: Temporal Types
Affects Version/s: 10.0.8, 10.1
Fix Version/s: 10.1.8

Type: Bug Priority: Minor
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: upstream-fixed

Sprint: 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.



 Comments   
Comment by Alexander Barkov [ 2015-10-01 ]

MySQL-5.7.8 is not affected.

Generated at Thu Feb 08 07:06:19 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.