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

Incorrect result for (time_expr BETWEEN timestamp_exp1 AND timestamp_expr2)

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.0(EOL), 10.1(EOL), 10.2(EOL), 10.3(EOL)
    • 10.3.0
    • Temporal Types

    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

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

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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