Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.0(EOL), 10.1(EOL), 10.2(EOL), 10.3(EOL), 10.4(EOL)
-
None
Description
This script:
CREATE OR REPLACE TABLE t1 (a YEAR); |
INSERT INTO t1 VALUES (2000); |
SELECT CAST(a AS DATE), CAST(COALESCE(a) AS DATE) FROM t1; |
SHOW WARNINGS;
|
produces the following output:
+-----------------+---------------------------+
|
| CAST(a AS DATE) | CAST(COALESCE(a) AS DATE) |
|
+-----------------+---------------------------+
|
| 2000-00-00 | NULL |
|
+-----------------+---------------------------+
|
1 row in set, 1 warning (0.00 sec)
|
 |
+---------+------+----------------------------------+
|
| Level | Code | Message |
|
+---------+------+----------------------------------+
|
| Warning | 1292 | Incorrect datetime value: '2000' |
|
+---------+------+----------------------------------+
|
NULL in the second column is wrong. Both columns should return the same value, without warnings.
This happens because Type_handler_year has a special implementation in Item_get_date():
bool Type_handler_year::Item_get_date(Item *item, MYSQL_TIME *ltime, |
ulonglong fuzzydate) const |
{
|
return item->get_date_from_year(ltime, fuzzydate); |
}
|
but does not have a similar implementation for Item_func_hybrid_field_type_get_date().
Attachments
Issue Links
- blocks
-
MDEV-4912 Data type plugin API version 1
- Closed
- relates to
-
MDEV-8284 Comparison of YEAR to '1970' is not consistent
- Open
-
MDEV-9343 Copying from YEAR to DATE result in '0000-00-00'
- Open
-
MDEV-17607 DATE(COALESCE(year_column)) returns a wrong result
- Closed