Bug #121419 `IN (SELECT NULL WHERE tautology) IS TRUE` returns NULL instead of 0
Submitted: 1 Oct 18:25
Reporter: jinxin gui Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S2 (Serious)
Version:26.7.0, 26.10.0-er OS:Linux
Assigned to: CPU Architecture:Any
Tags: IN clause, OR

[1 Oct 18:25] jinxin gui
Description:
Adding an always-true `WHERE` condition to a tableless subquery changes the value returned by `IS TRUE`. Both subqueries below return one row containing `NULL`, so the two queries should produce the same result. 

How to repeat:
```sql
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (id INT);
INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
ANALYZE TABLE t1;

SELECT id, id IN (SELECT NULL) IS TRUE AS result
FROM t1;

SELECT id, id IN (SELECT NULL WHERE TRUE) IS TRUE AS result
FROM t1;
```

Actual result:

The first query returns `result = 0` for all five IDs. The second query returns `result = NULL` for all five IDs.

Expected result:

The second query should also return `result = 0` for all five IDs. Its `WHERE` condition is true, so its subquery still returns one `NULL`. For a non-NULL `id`, the `IN` expression is `NULL`, and `NULL IS TRUE` is `0`.