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

Comparison of a TIME column to various literals works differently

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.0, 10.1, 10.2, 10.3, 10.4
    • 10.4
    • Temporal Types
    • None

    Description

      This script:

      SET timestamp=UNIX_TIMESTAMP('2001-01-01 00:00:00');
      DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a TIME);
      INSERT INTO t1 VALUES ('10:20:30');
      SELECT a=TIMESTAMP'2001-01-01 10:20:30' AS c1,a='2001-01-01 10:20:30' AS c2,a=20010101102030 AS c3,a=TIMESTAMP'2002-02-02 10:20:30' AS c4,a='2002-02-02 10:20:30' AS c5,a=20020202102030 AS c6 FROM t1;

      returns

      +------+------+------+------+------+------+
      | c1   | c2   | c3   | c4   | c5   | c6   |
      +------+------+------+------+------+------+
      |    1 |    0 |    0 |    0 |    0 |    0 |
      +------+------+------+------+------+------+

      which means it performs the datetime-to-time conversion using CURRENT_DATE only when a TIME field is compared to a TIMESTAMP literal, and does not perform conversion otherwise. Perhaps it could do conversion in more cases, e.g. at least for TIMESTAMP-alike string literals '2001-01-01 10:20:30'. Not sure about the numbers.

      MySQL-5.7 in the same scenario returns this result:

      +------+------+------+------+------+------+
      | c1   | c2   | c3   | c4   | c5   | c6   |
      +------+------+------+------+------+------+
      |    1 |    1 |    1 |    1 |    1 |    1 |
      +------+------+------+------+------+------+

      which means it does not perform TIME-to-DATETIME conversion at all, which is probably even worse.

      Attachments

        Activity

          People

            bar Alexander Barkov
            bar Alexander Barkov
            Votes:
            0 Vote for this issue
            Watchers:
            1 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.