Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
5.5(EOL), 10.0(EOL), 10.1(EOL), 10.2(EOL)
-
None
Description
Comparison of a YEAR column to DECIMAL and DOUBLE literal works differently in different function and operators:
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a YEAR);
|
INSERT INTO t1 VALUES (2000);
|
SELECT a=2000.1 AS c1, CASE a WHEN 2000.1 THEN TRUE ELSE FALSE END AS c2, NULLIF(a,2000.1) AS c3, GREATEST(a,2000.1) AS c4 FROM t1;
|
returns:
+------+------+------+--------+
|
| c1 | c2 | c3 | c4 |
|
+------+------+------+--------+
|
| 1 | 0 | NULL | 2000.1 |
|
+------+------+------+--------+
|
That means:
- for c1 it compared as YEAR
- for c2 it compared as DECIMAL
- for c3 it compared as YEAR
- for c4 it compared as DECIMAL
It should work the same way in all functions. Perhaps it should always compare as follows:
- YEAR vs DECIMAL as DECIMAL
- YEAR vs DOUBLE as DOUBLE
Another option would be to compare:
- YEAR vs DECIMAL as YEAR
- YEAR vs DOUBLE as YEAR