Hi Ilia, I checked v4. A few more cases could be simplified:
create table t(a int); insert into t values (1), (42), (null); explain (costs off) select * from t where (a not in (42, null)) is true; explain (costs off) select * from t where (a not in (42, null)) is not true; Both plans still contain the array comparison. The first condition could be folded to false, and the second to true. A null array is another case: explain (costs off) select * from t where a <> all (null::int[]); explain (costs off) select * from t where a = any (null::int[]); Both plans still contain the array comparison. These comparisons always return null, so in a where clause they could be folded to false. The comment in saop_never_true() says that ordinary constant folding handles a null array, but this does not happen when the left argument is a column. Could you cover these cases and add regression tests? Best regards, Denis Smirnov
