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

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

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 5.5, 10.0, 10.1, 10.2
    • 10.4
    • Temporal Types
    • 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

      Attachments

        Activity

          People

            bar Alexander Barkov
            bar Alexander Barkov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.