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
@@ -20,3 +20,26 @@ CREATE TABLE t2 (n BLOB, UNIQUE(n));
|
||||
INSERT INTO t2 VALUES (1);
|
||||
DELETE FROM t2 WHERE n = 1;
|
||||
DROP TABLE t2;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # Beginning of 11.4 tests
|
||||
--echo #
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-36389
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (c1 TEXT, UNIQUE (c1(1)));
|
||||
INSERT INTO t1 (c1) VALUES ('a');
|
||||
SELECT c1 FROM t1 WHERE ('abc' IN (SELECT c1 FROM t1)) IS FALSE;
|
||||
DROP TABLE t1;
|
||||
|
||||
CREATE TABLE t0 (c1 text not null);
|
||||
insert into t0 values ('abc'),('abc');
|
||||
CREATE TABLE t1 (c1 TEXT, UNIQUE (c1(1))) engine=myisam;
|
||||
INSERT INTO t1 (c1) VALUES ('a'),('b'),('c');
|
||||
SELECT c1, c1 IN (SELECT c1 FROM t1) FROM t0;
|
||||
DROP TABLE t0, t1;
|
||||
|
||||
--echo # End of 11.4 tests
|
||||
|
Reference in New Issue
Block a user