Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-8898

Inconsistent behaviour when comparing a YEAR column to DECIMAL or DOUBLE counterparts

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 10.1, 10.0, 5.5
    • Fix Version/s: 10.1
    • Component/s: None
    • 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

        Gliffy Diagrams

          Attachments

            Activity

            There are no comments yet on this issue.

              People

              • Assignee:
                bar Alexander Barkov
                Reporter:
                bar Alexander Barkov
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: