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

Comparison of a TIME column to various literals works differently

    Details

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

        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: