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

Wrong result for SELECT..WHERE LENGTH(time_column)=8 AND time_column=TIMESTAMP'2001-01-01 10:20:31'

Details

    Description

      SET timestamp=UNIX_TIMESTAMP('2001-01-01 01:02:03');
      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a TIME);
      INSERT INTO t1 VALUES ('10:20:31'),('-10:20:31');
      SELECT * FROM t1 WHERE a=TIMESTAMP'2001-01-01 10:20:31';
      SELECT * FROM t1 WHERE LENGTH(a)=8;
      SELECT * FROM t1 WHERE LENGTH(a)=8 AND a=TIMESTAMP'2001-01-01 10:20:31';

      In the above script the first and the second SELECT queries correctly return one row, the third SELECT query returns erroneously no rows.

      Attachments

        Issue Links

          Activity

            bar Alexander Barkov created issue -
            bar Alexander Barkov made changes -
            Field Original Value New Value
            bar Alexander Barkov made changes -
            bar Alexander Barkov made changes -
            bar Alexander Barkov made changes -
            Fix Version/s 10.1.7 [ 19604 ]
            Fix Version/s 10.1 [ 16100 ]
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Closed [ 6 ]
            bar Alexander Barkov made changes -
            Labels propagation

            MySQL-5.7.8 does not support propagation in this case:

            explain extended SELECT * FROM t1 WHERE LENGTH(a)=8 AND a=TIMESTAMP'2001-01-01 10:20:31';
            SHOW WARNINGS;

            +---------+------+----------------------------------------------------------------------------------------------------------------------------------------+
            | Level   | Code | Message                                                                                                                                |
            +---------+------+----------------------------------------------------------------------------------------------------------------------------------------+
            | Warning | 1681 | 'EXTENDED' is deprecated and will be removed in a future release.                                                                      |
            | Note    | 1003 | /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((length(`test`.`t1`.`a`) = 8) and (`test`.`t1`.`a` = '10:20:31')) |
            +---------+------+----------------------------------------------------------------------------------------------------------------------------------------+

            bar Alexander Barkov added a comment - MySQL-5.7.8 does not support propagation in this case: explain extended SELECT * FROM t1 WHERE LENGTH(a)=8 AND a=TIMESTAMP'2001-01-01 10:20:31'; SHOW WARNINGS; +---------+------+----------------------------------------------------------------------------------------------------------------------------------------+ | Level | Code | Message | +---------+------+----------------------------------------------------------------------------------------------------------------------------------------+ | Warning | 1681 | 'EXTENDED' is deprecated and will be removed in a future release. | | Note | 1003 | /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((length(`test`.`t1`.`a`) = 8) and (`test`.`t1`.`a` = '10:20:31')) | +---------+------+----------------------------------------------------------------------------------------------------------------------------------------+
            bar Alexander Barkov made changes -
            Labels propagation propagation upstream-not-supported
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 71408 ] MariaDB v4 [ 149588 ]

            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.