pgsql: Avoid mislabeling of lateral references, redux.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Avoid mislabeling of lateral references, redux.
Date: 2024-11-30 17:42:36
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Avoid mislabeling of lateral references, redux.

As I'd feared, commit 5c9d8636d was still a few bricks shy of a load.
We can't just leave pulled-up lateral-reference Vars with no new
nullingrels: we have to carefully compute what subset of the
to-be-replaced Var's nullingrels apply to them, else we still get
"wrong varnullingrels" errors. This is a bit tedious, but it looks
like we can use the nullingrel data this patch computes for other
purposes, enabling better optimization. We don't want to inject
unnecessary plan changes into stable branches though, so leave that
idea for a later HEAD-only patch.

Patch by me, but thanks to Richard Guo for devising a test case that
broke 5c9d8636d, and for preliminary investigation about how to fix
it. As before, back-patch to v16.

Discussion: https://postgr.es/m/[email protected]

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e032e4c7ddd0e1f7865b246ec18944365d4f8614

Modified Files
--------------
src/backend/optimizer/prep/prepjointree.c | 171 +++++++++++++++++++++++++++++-
src/test/regress/expected/subselect.out | 51 +++++++++
src/test/regress/sql/subselect.sql | 15 +++
src/tools/pgindent/typedefs.list | 1 +
4 files changed, 233 insertions(+), 5 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2024-12-01 19:16:05 pgsql: Fix broken list-munging in ecpg's remove_variables().
Previous Message Peter Eisentraut 2024-11-30 07:44:47 pgsql: doc: Fix typo