]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Avoid mislabeling of lateral references, redux.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 30 Nov 2024 17:42:20 +0000 (12:42 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 30 Nov 2024 17:42:20 +0000 (12:42 -0500)
commit7b456f040fb6ca320c756cd822cfbd219b0c4078
tree89f9c0661c2aa405211216cd5e5b2969095a3221
parent85990e2fd5610576635c65db9292297b1730c947
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/E1tGn4j-0003zi-MP@gemulon.postgresql.org
src/backend/optimizer/prep/prepjointree.c
src/test/regress/expected/subselect.out
src/test/regress/sql/subselect.sql
src/tools/pgindent/typedefs.list