Re: BUG #16945: where value in (null) set results inconsistent - Mailing list pgsql-bugs

From Pantelis Theodosiou
Subject Re: BUG #16945: where value in (null) set results inconsistent
Date
Msg-id CAE3TBxx=dKcpGQ-owmuHx3=h28wrkt4E_wnOK+3PB7E42F=VOQ@mail.gmail.com
Whole thread Raw
In response to Re: BUG #16945: where value in (null) set results inconsistent  (Pantelis Theodosiou <ypercube@gmail.com>)
List pgsql-bugs


On Mon, Mar 29, 2021 at 10:10 AM Pantelis Theodosiou <ypercube@gmail.com> wrote:


On Mon, Mar 29, 2021 at 8:41 AM PG Bug reporting form <noreply@postgresql.org> wrote:
...

Pursuant to a fix in Hibernate, that uses "where value in (null)" as a
workaround for several DB's not handling "where value in ()":
https://hibernate.atlassian.net/browse/HHH-8091

Consider this inconsistency:

... 
The expression `id in (null)`  is equivalent to `id = null` which is always null (or more accurately Uknown) and where unknown will have the same result as where false.

Workarounds:

where id in (select null::int where false)
where id not in (select null::int where false)

or avoiding the cast:

where id in (select id from project_type_variants where false)
where id not in (select id from project_type_variants where false)
 

Even better in my opinion if Hibernate instead "where value in (null)" as a
workaround for several DB's not handling "where value in ()", use

"where false" instead of "where value in ()"
"where true" instead of "where value not in ()"

pgsql-bugs by date:

Previous
From: Pantelis Theodosiou
Date:
Subject: Re: BUG #16945: where value in (null) set results inconsistent
Next
From: hao li
Date:
Subject: Default Inline CTE makes JOIN slower