Re: v16 regression - wrong query results with LEFT JOINs + join removal

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: v16 regression - wrong query results with LEFT JOINs + join removal
Date: 2023-05-11 16:46:03
Message-ID: 1085792.1683823563@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> On Thu, May 11, 2023 at 10:14 AM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>> Ouch, so we've had a known queries-returning-wrong-answers bug for
>> more than two months. That's not great. I'll try to find time today to
>> check whether the patches on that thread resolve this issue.

> I tried out the v3 patches from that thread and they don't seem to
> make any difference for me in this test case. So either (1) it's a
> different issue or (2) those patches don't fully fix it or (3) I'm bad
> at testing things.

Yeah, I've just traced the problem to remove_rel_from_query() deciding
that it can drop the qual of interest :-(. I'd done this:

- if (RINFO_IS_PUSHED_DOWN(rinfo, joinrelids))
+ if (bms_is_member(ojrelid, rinfo->required_relids))

as part of an unfinished effort at getting rid of RestrictInfos'
is_pushed_down flags, and this example shows that the replacement
condition is faulty.

What I'm inclined to do about it is just revert this particular
change. But I'd better run around and see where else I did that,
because the idea is evidently not ready for prime time.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2023-05-11 17:46:33 Re: v16 regression - wrong query results with LEFT JOINs + join removal
Previous Message Robert Haas 2023-05-11 16:18:03 Re: base backup vs. concurrent truncation