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

Incorrect result for (time_expr BETWEEN timestamp_exp1 AND timestamp_expr2)

    Details

      Description

      SET @@timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30');
      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a TIMESTAMP,b TIMESTAMP);
      INSERT INTO t1 VALUES ('2001-01-01 00:00:00','2001-01-01 23:59:59');
      SELECT * FROM t1 WHERE TIME'10:20:30' BETWEEN a and b;
      

      erroneously returns empty set.

      If I change one of the columns from TIMESTAMP to DATETIME it correctly returns one row:

      SET @@timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30');
      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a TIMESTAMP,b DATETIME);
      INSERT INTO t1 VALUES ('2001-01-01 00:00:00','2001-01-01 23:59:59');
      SELECT * FROM t1 WHERE TIME'10:20:30' BETWEEN a and b;
      

      +---------------------+---------------------+
      | a                   | b                   |
      +---------------------+---------------------+
      | 2001-01-01 00:00:00 | 2001-01-01 23:59:59 |
      +---------------------+---------------------+
      

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: