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

Unexpected impossible WHERE for a condition on a ZEROFILL field

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.5, 10.0, 10.1
    • Fix Version/s: 10.1.8
    • Component/s: Optimizer
    • Labels:
      None

      Description

      This script:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a INT ZEROFILL);
      INSERT INTO t1 VALUES (128);
      SELECT * FROM t1 WHERE a=128;
      SELECT * FROM t1 WHERE hex(a)='80';

      correctly returns one row for both SELECT queries.

      if I join the two conditions using AND:

      SELECT * FROM t1 WHERE a=128 AND hex(a)='80';

      it unexpectedly returns Empty set.

      EXPLAIN for the above query tells "Impossible WHERE":

      MariaDB [test]> EXPLAIN SELECT * FROM t1 WHERE a=128 AND hex(a)='80';
      +------+-------------+-------+------+---------------+------+---------+------+------+------------------+
      | id   | select_type | table | type | possible_keys | key  | key_len | ref  | rows | Extra            |
      +------+-------------+-------+------+---------------+------+---------+------+------+------------------+
      |    1 | SIMPLE      | NULL  | NULL | NULL          | NULL | NULL    | NULL | NULL | Impossible WHERE |
      +------+-------------+-------+------+---------------+------+---------+------+------+------------------+

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:

                  Git Integration