Re: Query result differences between PostgreSQL 17 vs 16

Richard Guo <guofenglinux@gmail.com>

From: Richard Guo <guofenglinux@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Bruce Momjian <bruce@momjian.us>, David Rowley <dgrowleyml@gmail.com>, Ronald Cruz <cruz@rentec.com>, pgsql-bugs@lists.postgresql.org, Peter Ford <pford@rentec.com>, "Aaron J. Garcia" <agarcia@rentec.com>
Date: 2025-02-26T07:03:30Z
Lists: pgsql-bugs
On Wed, Feb 26, 2025 at 3:26 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Richard Guo <guofenglinux@gmail.com> writes:
> > Here is the patch.

> Thanks for that.  The code and comment added to
> restriction_is_always_true look good, but I can't help wondering
> whether we don't need the same in restriction_is_always_false.
> Not very sure what a query proving the need for that would
> look like, but leaving it asymmetric feels wrong.

Yeah, I think you are right.  The thing here is that we don't have a
reliable way to determine if the input expression of a NullTest is
non-nullable if it's a clone clause.  This applies to both
restriction_is_always_true and restriction_is_always_false.  So I
think we should add the same check in restriction_is_always_false too.

I'll give it a try to find a query that shows this is necessary.

Thanks
Richard



Commits

  1. Avoid NullTest deduction for clone clauses

  2. Add better handling of redundant IS [NOT] NULL quals