[MDEV-8898] Inconsistent behaviour when comparing a YEAR column to DECIMAL or DOUBLE counterparts Created: 2015-10-05  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: Temporal Types
Affects Version/s: 5.5, 10.0, 10.1, 10.2
Fix Version/s: 10.4

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Unresolved Votes: 0
Labels: 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

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