Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
5.5(EOL), 10.0(EOL), 10.1(EOL)
-
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
- blocks
-
MDEV-8728 Fix a number of problems in equal field and equal expression propagation
-
- Closed
-
Activity
Field | Original Value | New Value |
---|---|---|
Description |
This script: {code} 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'; {code} correctly returns one row for both SELECT queries. if I join the two conditions using AND: {code} SELECT * FROM t1 WHERE a=128 AND hex(a)='80'; {code} EXPLAIN for the above query tells "Impossible WHERE": {noformat} 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 | +------+-------------+-------+------+---------------+------+---------+------+------+------------------+ {noformat} |
This script: {code} 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'; {code} correctly returns one row for both SELECT queries. if I join the two conditions using AND: {code} SELECT * FROM t1 WHERE a=128 AND hex(a)='80'; {code} it unexpectedly returns Empty set. EXPLAIN for the above query tells "Impossible WHERE": {noformat} 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 | +------+-------------+-------+------+---------------+------+---------+------+------+------------------+ {noformat} |
Description |
This script: {code} 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'; {code} correctly returns one row for both SELECT queries. if I join the two conditions using AND: {code} SELECT * FROM t1 WHERE a=128 AND hex(a)='80'; {code} it unexpectedly returns Empty set. EXPLAIN for the above query tells "Impossible WHERE": {noformat} 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 | +------+-------------+-------+------+---------------+------+---------+------+------+------------------+ {noformat} |
This script: {code} 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'; {code} correctly returns one row for both SELECT queries. if I join the two conditions using AND: {code} SELECT * FROM t1 WHERE a=128 AND hex(a)='80'; {code} it unexpectedly returns Empty set. EXPLAIN for the above query tells "Impossible WHERE": {noformat} 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 | +------+-------------+-------+------+---------------+------+---------+------+------+------------------+ {noformat} |
Status | Open [ 1 ] | In Progress [ 3 ] |
Component/s | OTHER [ 10125 ] | |
Fix Version/s | 10.1.8 [ 19605 ] | |
Fix Version/s | 10.1 [ 16100 ] | |
Resolution | Fixed [ 1 ] | |
Status | In Progress [ 3 ] | Closed [ 6 ] |
Component/s | Optimizer [ 10200 ] | |
Component/s | OTHER [ 10125 ] |
Workflow | MariaDB v3 [ 70310 ] | MariaDB v4 [ 149297 ] |
explain extended SELECT * FROM t1 WHERE a=128 AND hex(a)='80';
show warnings;
+-------+------+--------------------------------------------------------+
| Level | Code | Message |
+-------+------+--------------------------------------------------------+
| Note | 1003 | select `test`.`t1`.`a` AS `a` from `test`.`t1` where 0 |
+-------+------+--------------------------------------------------------+
and without zerofil
explain extended SELECT * FROM t1 WHERE a=128 AND hex(a)='80';
+-------+------+------------------------------------------------------------------------------+
| Level | Code | Message |
+-------+------+------------------------------------------------------------------------------+
| Note | 1003 | select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 128) |
+-------+------+------------------------------------------------------------------------------+