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-03-03T06:40:47Z
Lists: pgsql-bugs
Attachments
- v3-0001-Avoid-NullTest-deduction-for-clone-clauses.patch (application/octet-stream) patch v3-0001
On Sat, Mar 1, 2025 at 12:48 AM Tom Lane <tgl@sss.pgh.pa.us> wrote: > Richard Guo <guofenglinux@gmail.com> writes: > > Now I'm inclined to agree with you. It seems we've been lucky so far > > not to encounter issues with IS NULL deductions on clone clauses, but > > this feels like a problem waiting to happen in the future. > > Yes, I'm on board with that too. I think the comments need more work > than you've done though. I think they should say something about > "nullingrel bits in clone clauses may not reflect reality, so we dare > not draw conclusions from clones about whether Vars are guaranteed > not-null". Also, I'm not convinced any more that this has anything to > do with missing clone members, so we should remove that claim. Agreed. Thanks for the suggestion. > > The no-clone-quals limitation in restriction_is_always_false makes the > > fix in f00ab1fd1 unnecessary. I think we should revert those changes. > > Hmm, I'm less on board with that. The saving-and-restoring of > last_rinfo_serial looks correct to me, even though this fix might > cause the test case you found before to not tickle that bug. Fair point. > > Attached is the updated patch. > > I'm confused by the changes to existing test cases in this? It looks > like you're undoing some test changes that are not from f00ab1fd1, so > I don't understand why. My inclination here would be to add a new > test that exposes the current bug, but leave the rest alone, even > though they may no longer be testing exactly what they were originally > meant to do. Yeah, the patch modifies some existing test cases that are intended to test a join clause that is IS_NOT_NULL/IS_NULL qual can or cannot be reduced depending on whether its Var is nullable by any outer joins. And it happens that the join clauses in these test cases are clone clauses, which are excluded from reduction by the fix here. As a result, they are no longer testing what they are intended to. This patch modifies them to ensure that those join clauses are not clone clauses. This patch also adds a new test that exposes the current bug, and tests that clone clauses are not reduced to constant true/false. Here is an updated patch, which also includes the test case you found proving the no-clone-quals limitation in restriction_is_always_false is also needed. Thanks Richard
Commits
-
Avoid NullTest deduction for clone clauses
- bc5a08af3c44 17.5 landed
- 716a051aaccd 18.0 landed
-
Add better handling of redundant IS [NOT] NULL quals
- b262ad440ede 17.0 cited