mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
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.
32 lines
859 B
Plaintext
32 lines
859 B
Plaintext
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, a varchar(30000), UNIQUE (a)) ENGINE=innodb;
|
|
INSERT INTO t1 (a) VALUES (20),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
|
|
SELECT * FROM t1 WHERE a BETWEEN '1' AND '100';
|
|
pk a
|
|
DROP TABLE t1;
|
|
CREATE TABLE t2 (n BLOB, UNIQUE(n));
|
|
INSERT INTO t2 VALUES (1);
|
|
DELETE FROM t2 WHERE n = 1;
|
|
DROP TABLE t2;
|
|
#
|
|
# Beginning of 11.4 tests
|
|
#
|
|
#
|
|
# MDEV-36389
|
|
#
|
|
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;
|
|
c1
|
|
a
|
|
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;
|
|
c1 c1 IN (SELECT c1 FROM t1)
|
|
abc 0
|
|
abc 0
|
|
DROP TABLE t0, t1;
|
|
# End of 11.4 tests
|