In PostgreSQL 18, what does SELECT NULL IN (SELECT 1 WHERE false); return, given that the subquery produces no rows?
Explanation
IN over a subquery is false when no equal row is found, and that includes the case where the subquery returns nothing at all: with zero rows on the right, no comparison is ever performed, so nothing can be unknown. NULL is the tempting answer because a null left-hand side normally poisons the result, and it does as soon as the subquery returns a row: SELECT NULL IN (SELECT 1); returns NULL.