Re: Fold NOT IN / <> ALL expressions containing NULL to FALSE - Mailing list pgsql-hackers

From Denis Smirnov
Subject Re: Fold NOT IN / <> ALL expressions containing NULL to FALSE
Date
Msg-id D28893E9-411D-4D89-B4A8-4F3E3FD48A21@gmail.com
Whole thread
In response to Re: Fold NOT IN / <> ALL expressions containing NULL to FALSE  (Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>)
Responses Re: Fold NOT IN / <> ALL expressions containing NULL to FALSE
List pgsql-hackers
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

pgsql-hackers by date:

Previous
From: Xuneng Zhou
Date:
Subject: Re: Logical slot creation/synchronization on a standby may deadlock with recovery conflict resolution
Next
From: Nico Williams
Date:
Subject: Re: Proposal: Supporting URI SAN in Certificate Authentication