mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-17411 Wrong WHERE optimization with simple CASE and searched CASE
This commit is contained in:
@ -546,5 +546,32 @@ Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 'a'
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-17411 Wrong WHERE optimization with simple CASE and searched CASE
|
||||
#
|
||||
CREATE TABLE t1 (a INT, b INT, KEY(a));
|
||||
INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
|
||||
SELECT * FROM t1 WHERE CASE a WHEN b THEN 1 END=1;
|
||||
a b
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
SELECT * FROM t1 WHERE CASE WHEN a THEN b ELSE 1 END=3;
|
||||
a b
|
||||
3 3
|
||||
SELECT * FROM t1 WHERE
|
||||
CASE a WHEN b THEN 1 END=1 AND
|
||||
CASE WHEN a THEN b ELSE 1 END=3;
|
||||
a b
|
||||
3 3
|
||||
EXPLAIN EXTENDED
|
||||
SELECT * FROM t1 WHERE
|
||||
CASE a WHEN b THEN 1 END=1 AND
|
||||
CASE WHEN a THEN b ELSE 1 END=3;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (case `test`.`t1`.`a` when `test`.`t1`.`b` then 1 end) = 1 and (case when `test`.`t1`.`a` then `test`.`t1`.`b` else 1 end) = 3
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# End of 10.3 test
|
||||
#
|
||||
|
Reference in New Issue
Block a user