Re: BUG #17976: Inconsistent results of SELECT using CASE WHEN clause - Mailing list pgsql-bugs

From Richard Guo
Subject Re: BUG #17976: Inconsistent results of SELECT using CASE WHEN clause
Date
Msg-id CAMbWs4-bAEqV_2yggbB0z42zqgWHpcM9d1nWkD1FygpHuFms9g@mail.gmail.com
Whole thread Raw
In response to Re: BUG #17976: Inconsistent results of SELECT using CASE WHEN clause  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #17976: Inconsistent results of SELECT using CASE WHEN clause  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs

On Thu, Jun 15, 2023 at 7:34 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
I'd always kind of wondered how we got away with not updating
EquivalenceClasses during join removal, and the answer evidently
is that we can't anymore.  I've not tried to write a patch yet.

I wondered about that too, and I thought that the target rel could not
be mentioned in any EC, otherwise join_is_removable should have noticed
that this rel is used above the join and thus decided that the join is
not removable.  Hence there is no need to update ECs during join
removal.  Apparently this is not right, as shown by this issue.

I went ahead and drafted a patch as attached.  But I'm not sure if it
suffices to only update ec_relids, em_relids and ec_sources as the patch
does.  Also I'm wondering if any of them would become empty after the
update.

Thanks
Richard
Attachment

pgsql-bugs by date:

Previous
From: Michael Paquier
Date:
Subject: Re: BUG #17888: Incorrect memory access in gist__int_ops for an input array with many elements
Next
From: Dmitry Dolgov
Date:
Subject: Re: BUG #17949: Adding an index introduces serialisation anomalies.