Re: Query result differences between PostgreSQL 17 vs 16 - Mailing list pgsql-bugs

From Richard Guo
Subject Re: Query result differences between PostgreSQL 17 vs 16
Date
Msg-id CAMbWs49rShAwK0sMz+-6d9hGd1RsRQd0tBuVUGvh88pNu9hG1w@mail.gmail.com
Whole thread Raw
In response to Re: Query result differences between PostgreSQL 17 vs 16  (Richard Guo <guofenglinux@gmail.com>)
Responses Re: Query result differences between PostgreSQL 17 vs 16
List pgsql-bugs
On Sat, Feb 22, 2025 at 12:08 PM Richard Guo <guofenglinux@gmail.com> wrote:
> On Sat, Feb 22, 2025 at 11:32 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > If the check against table not-null constraints is applied after we
> > clone outer-join quals, that's probably bad.  I think there are
> > assumptions in there that every clone qual will have doppelgangers,
> > so filtering NOT NULLs later would break that.  Maybe not applying
> > the filter to quals marked has_clone or is_clone would help?

> Yeah, I think this approach can fix the issue.  Perhaps we should
> check whether the RestrictInfo is a clone clause and avoid assuming
> that it's always true in that case, maybe by adding something like
> below at the start of restriction_is_always_true.
>
> +   if (restrictinfo->has_clone || restrictinfo->is_clone)
> +       return false;
>
> We may lose some optimization opportunities with NOT NULL quals, as
> this could prevent us from reducing certain such quals to constant
> true, but I think correctness should be our top priority.
>
> I'll go ahead and write a patch.

Here is the patch.

Thanks
Richard

Attachment

pgsql-bugs by date:

Previous
From: Kashaela Ransaw
Date:
Subject: Re: error -10825
Next
From: Tom Lane
Date:
Subject: Re: Query result differences between PostgreSQL 17 vs 16