Skip to content

Commit 2cefd28

Browse files
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.
1 parent dbd7017 commit 2cefd28

11 files changed

+308
-88
lines changed

mysql-test/main/subselect.result

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -991,9 +991,9 @@ a t1.a in (select t2.a from t2)
991991
explain extended SELECT t1.a, t1.a in (select t2.a from t2) FROM t1;
992992
id select_type table type possible_keys key key_len ref rows filtered Extra
993993
1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 100.00 Using index
994-
2 SUBQUERY t2 index_subquery a a 5 func 2 100.00 Using index
994+
2 DEPENDENT SUBQUERY t2 index_subquery a a 5 func 2 100.00 Using index; Using where
995995
Warnings:
996-
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in t2 on a checking NULL having `test`.`t2`.`a` is null)))) AS `t1.a in (select t2.a from t2)` from `test`.`t1`
996+
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in t2 on a checking NULL where <cache>(`test`.`t1`.`a`) = `test`.`t2`.`a` or `test`.`t2`.`a` is null having `test`.`t2`.`a` is null)))) AS `t1.a in (select t2.a from t2)` from `test`.`t1`
997997
CREATE TABLE t3 (a int(11) default '0');
998998
INSERT INTO t3 VALUES (1),(2),(3);
999999
SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1;
@@ -1700,21 +1700,21 @@ a3 1
17001700
explain extended select s1, s1 NOT IN (SELECT s1 FROM t2) from t1;
17011701
id select_type table type possible_keys key key_len ref rows filtered Extra
17021702
1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index
1703-
2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key
1703+
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Using where; Full scan on NULL key
17041704
Warnings:
1705-
Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1`
1705+
Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where trigcond(<cache>(`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1`
17061706
explain extended select s1, s1 = ANY (SELECT s1 FROM t2) from t1;
17071707
id select_type table type possible_keys key key_len ref rows filtered Extra
17081708
1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index
1709-
2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key
1709+
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Using where; Full scan on NULL key
17101710
Warnings:
1711-
Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1`
1711+
Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where trigcond(<cache>(`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1`
17121712
explain extended select s1, s1 <> ALL (SELECT s1 FROM t2) from t1;
17131713
id select_type table type possible_keys key key_len ref rows filtered Extra
17141714
1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index
1715-
2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key
1715+
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Using where; Full scan on NULL key
17161716
Warnings:
1717-
Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1`
1717+
Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where trigcond(<cache>(`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1`
17181718
explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1;
17191719
id select_type table type possible_keys key key_len ref rows filtered Extra
17201720
1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index
@@ -3272,7 +3272,7 @@ INSERT INTO t2 VALUES (1),(2),(3);
32723272
EXPLAIN SELECT a, a IN (SELECT a FROM t1) FROM t2;
32733273
id select_type table type possible_keys key key_len ref rows Extra
32743274
1 PRIMARY t2 ALL NULL NULL NULL NULL 3
3275-
2 SUBQUERY t1 index_subquery a a 5 func 3 Using index; Full scan on NULL key
3275+
2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 3 Using index; Using where; Full scan on NULL key
32763276
SELECT a, a IN (SELECT a FROM t1) FROM t2;
32773277
a a IN (SELECT a FROM t1)
32783278
1 1

mysql-test/main/subselect4.result

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,7 @@ EXPLAIN
13641364
SELECT i FROM t1 WHERE (1) NOT IN (SELECT i FROM t2);
13651365
id select_type table type possible_keys key key_len ref rows Extra
13661366
1 PRIMARY t1 system NULL NULL NULL NULL 1
1367-
2 SUBQUERY t2 index_subquery k k 5 const 2 Using index
1367+
2 SUBQUERY t2 index_subquery k k 5 const 2 Using index; Using where
13681368
DROP TABLE t2;
13691369
DROP TABLE t1;
13701370
#
@@ -1555,7 +1555,7 @@ EXPLAIN
15551555
SELECT ( 5 ) IN ( SELECT * FROM v2 );
15561556
id select_type table type possible_keys key key_len ref rows Extra
15571557
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
1558-
2 SUBQUERY <derived3> index_subquery NULL distinct_key 5 const 2
1558+
2 SUBQUERY <derived3> index_subquery NULL distinct_key 5 const 2 Using where
15591559
3 DERIVED t1 system NULL NULL NULL NULL 1
15601560
4 UNION t2 system NULL NULL NULL NULL 1
15611561
NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
@@ -1608,7 +1608,7 @@ EXPLAIN
16081608
SELECT ( 5 ) IN ( SELECT * FROM v2 );
16091609
id select_type table type possible_keys key key_len ref rows Extra
16101610
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
1611-
2 SUBQUERY <derived3> index_subquery NULL distinct_key 5 const 2
1611+
2 SUBQUERY <derived3> index_subquery NULL distinct_key 5 const 2 Using where
16121612
3 DERIVED t1 system NULL NULL NULL NULL 1
16131613
4 UNION t2 system NULL NULL NULL NULL 1
16141614
NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL

mysql-test/main/subselect_no_exists_to_in.result

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -995,9 +995,9 @@ a t1.a in (select t2.a from t2)
995995
explain extended SELECT t1.a, t1.a in (select t2.a from t2) FROM t1;
996996
id select_type table type possible_keys key key_len ref rows filtered Extra
997997
1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 100.00 Using index
998-
2 SUBQUERY t2 index_subquery a a 5 func 2 100.00 Using index
998+
2 DEPENDENT SUBQUERY t2 index_subquery a a 5 func 2 100.00 Using index; Using where
999999
Warnings:
1000-
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in t2 on a checking NULL having `test`.`t2`.`a` is null)))) AS `t1.a in (select t2.a from t2)` from `test`.`t1`
1000+
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in t2 on a checking NULL where <cache>(`test`.`t1`.`a`) = `test`.`t2`.`a` or `test`.`t2`.`a` is null having `test`.`t2`.`a` is null)))) AS `t1.a in (select t2.a from t2)` from `test`.`t1`
10011001
CREATE TABLE t3 (a int(11) default '0');
10021002
INSERT INTO t3 VALUES (1),(2),(3);
10031003
SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1;
@@ -1704,21 +1704,21 @@ a3 1
17041704
explain extended select s1, s1 NOT IN (SELECT s1 FROM t2) from t1;
17051705
id select_type table type possible_keys key key_len ref rows filtered Extra
17061706
1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index
1707-
2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key
1707+
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Using where; Full scan on NULL key
17081708
Warnings:
1709-
Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1`
1709+
Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where trigcond(<cache>(`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1`
17101710
explain extended select s1, s1 = ANY (SELECT s1 FROM t2) from t1;
17111711
id select_type table type possible_keys key key_len ref rows filtered Extra
17121712
1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index
1713-
2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key
1713+
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Using where; Full scan on NULL key
17141714
Warnings:
1715-
Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1`
1715+
Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where trigcond(<cache>(`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1`
17161716
explain extended select s1, s1 <> ALL (SELECT s1 FROM t2) from t1;
17171717
id select_type table type possible_keys key key_len ref rows filtered Extra
17181718
1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index
1719-
2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key
1719+
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Using where; Full scan on NULL key
17201720
Warnings:
1721-
Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1`
1721+
Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where trigcond(<cache>(`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1`
17221722
explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1;
17231723
id select_type table type possible_keys key key_len ref rows filtered Extra
17241724
1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index
@@ -3275,7 +3275,7 @@ INSERT INTO t2 VALUES (1),(2),(3);
32753275
EXPLAIN SELECT a, a IN (SELECT a FROM t1) FROM t2;
32763276
id select_type table type possible_keys key key_len ref rows Extra
32773277
1 PRIMARY t2 ALL NULL NULL NULL NULL 3
3278-
2 SUBQUERY t1 index_subquery a a 5 func 3 Using index; Full scan on NULL key
3278+
2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 3 Using index; Using where; Full scan on NULL key
32793279
SELECT a, a IN (SELECT a FROM t1) FROM t2;
32803280
a a IN (SELECT a FROM t1)
32813281
1 1

mysql-test/main/subselect_no_mat.result

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -998,9 +998,9 @@ a t1.a in (select t2.a from t2)
998998
explain extended SELECT t1.a, t1.a in (select t2.a from t2) FROM t1;
999999
id select_type table type possible_keys key key_len ref rows filtered Extra
10001000
1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 100.00 Using index
1001-
2 SUBQUERY t2 index_subquery a a 5 func 2 100.00 Using index
1001+
2 DEPENDENT SUBQUERY t2 index_subquery a a 5 func 2 100.00 Using index; Using where
10021002
Warnings:
1003-
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in t2 on a checking NULL having `test`.`t2`.`a` is null)))) AS `t1.a in (select t2.a from t2)` from `test`.`t1`
1003+
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in t2 on a checking NULL where <cache>(`test`.`t1`.`a`) = `test`.`t2`.`a` or `test`.`t2`.`a` is null having `test`.`t2`.`a` is null)))) AS `t1.a in (select t2.a from t2)` from `test`.`t1`
10041004
CREATE TABLE t3 (a int(11) default '0');
10051005
INSERT INTO t3 VALUES (1),(2),(3);
10061006
SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1;
@@ -1707,21 +1707,21 @@ a3 1
17071707
explain extended select s1, s1 NOT IN (SELECT s1 FROM t2) from t1;
17081708
id select_type table type possible_keys key key_len ref rows filtered Extra
17091709
1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index
1710-
2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key
1710+
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Using where; Full scan on NULL key
17111711
Warnings:
1712-
Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1`
1712+
Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where trigcond(<cache>(`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1`
17131713
explain extended select s1, s1 = ANY (SELECT s1 FROM t2) from t1;
17141714
id select_type table type possible_keys key key_len ref rows filtered Extra
17151715
1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index
1716-
2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key
1716+
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Using where; Full scan on NULL key
17171717
Warnings:
1718-
Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1`
1718+
Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where trigcond(<cache>(`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1`
17191719
explain extended select s1, s1 <> ALL (SELECT s1 FROM t2) from t1;
17201720
id select_type table type possible_keys key key_len ref rows filtered Extra
17211721
1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index
1722-
2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key
1722+
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Using where; Full scan on NULL key
17231723
Warnings:
1724-
Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1`
1724+
Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where trigcond(<cache>(`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1`
17251725
explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1;
17261726
id select_type table type possible_keys key key_len ref rows filtered Extra
17271727
1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index
@@ -3277,7 +3277,7 @@ INSERT INTO t2 VALUES (1),(2),(3);
32773277
EXPLAIN SELECT a, a IN (SELECT a FROM t1) FROM t2;
32783278
id select_type table type possible_keys key key_len ref rows Extra
32793279
1 PRIMARY t2 ALL NULL NULL NULL NULL 3
3280-
2 SUBQUERY t1 index_subquery a a 5 func 3 Using index; Full scan on NULL key
3280+
2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 3 Using index; Using where; Full scan on NULL key
32813281
SELECT a, a IN (SELECT a FROM t1) FROM t2;
32823282
a a IN (SELECT a FROM t1)
32833283
1 1

0 commit comments

Comments
 (0)