Re: BUG #17976: Inconsistent results of SELECT using CASE WHEN clause

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: zuming(dot)jiang(at)inf(dot)ethz(dot)ch, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17976: Inconsistent results of SELECT using CASE WHEN clause
Date: 2023-06-15 07:12:01
Message-ID: CAMbWs4-bAEqV_2yggbB0z42zqgWHpcM9d1nWkD1FygpHuFms9g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Jun 15, 2023 at 7:34 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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 Content-Type Size
v1-0001-Remove-references-to-the-removed-rel-from-EquivalenceClasses.patch application/octet-stream 3.9 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Dmitry Dolgov 2023-06-15 07:29:28 Re: BUG #17949: Adding an index introduces serialisation anomalies.
Previous Message Michael Paquier 2023-06-15 04:53:36 Re: BUG #17888: Incorrect memory access in gist__int_ops for an input array with many elements