mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-36389 Incorrect query results for an indexed text column
Fixes a scenario where an IN subquery returned the wrong result because the pushed WHERE clause was not retained for downstream result filtering. For example: CREATE TABLE t1 (c1 TEXT, UNIQUE (c1(1))); INSERT INTO t1 (c1) VALUES ('a'); SELECT 'abc' IN (SELECT c1 FROM t1); Internally, he 'abc' IN subquery condition becomes the constant condition: 'abc' = t1.c1 or t1.c1 is null Prior to this patch, this condition was incorrectly removed when converting the subquery engine to an index lookup-based engine. Now eligible conditions are preserved during such engine rewrites.
This commit is contained in:
committed by
Dave Gosselin
parent
3109d994eb
commit
a52362b90c
@@ -1121,7 +1121,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
EXPLAIN SELECT * FROM t2 AS t1 WHERE b NOT IN (SELECT b FROM t1 FORCE INDEX(b));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1
|
||||
2 SUBQUERY t1 index_subquery b b 5 func 3 Using index; Full scan on NULL key
|
||||
2 DEPENDENT SUBQUERY t1 index_subquery b b 5 func 3 Using index; Using where; Full scan on NULL key
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2, t3;
|
||||
#
|
||||
|
Reference in New Issue
Block a user