Bug #83763 unreasonable behavior for extracting year from time
Submitted: 10 Nov 2016 2:36 Modified: 10 Nov 2016 3:47
Reporter: 帅 Bang Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version: OS:Linux
Assigned to: CPU Architecture:Any

[10 Nov 2016 2:36] 帅 Bang
Description:
mysql> select CURTIME();
+-----------+
| CURTIME() |
+-----------+
| 18:10:42  |
+-----------+
1 row in set (0.00 sec)

quite ok.  what CURTIME returns is current time, neither current datetime nor current timestamp.

mysql> select extract(YEAR from CURTIME());
+------------------------------+
| extract(YEAR from CURTIME()) |
+------------------------------+
|                            0 |
+------------------------------+
1 row in set (0.00 sec)

IMHO, this is unreasonable since there is no year part in terms of a time value.

If CURTIME() were a datetime value or timestamp value, i think this could be quite ok.

How to repeat:
select CURTIME();
select extract(YEAR from CURTIME());

Suggested fix:
it is highly, highly, highly recommended for mysql to  return NULL with a warning when select extract(YEAR from CURTIME()) is performed
[10 Nov 2016 2:41] 帅 Bang
it is highly, highly, highly recommended for mysql to  return NULL with a warning or 0 when select extract(YEAR from CURTIME()) is performed
[10 Nov 2016 3:47] MySQL Verification Team
Hi Bang,

Thank you for the report.
Marking as duplicate of Bug #83765

Thanks,
Umesh