Improve ruleutils' printout of LATERAL references within subplans.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 17 Nov 2022 01:06:09 +0000 (20:06 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 17 Nov 2022 01:06:09 +0000 (20:06 -0500)
commitadaf34241acd83afaa45a8b614b6484a285da847
tree0707fe1e75854c32c0fbadf071040fdfb22fc5d9
parent5db195f76f279a120edee448ad74d43578f56edd
Improve ruleutils' printout of LATERAL references within subplans.

Commit 1cc29fe7c, which taught EXPLAIN to print PARAM_EXEC Params as
the referenced expressions, included some checks to prevent matching
Params found in SubPlans or InitPlans to NestLoopParams of upper query
levels.  At the time, this seemed possibly necessary to avoid false
matches because of the planner's habit of re-using the same PARAM_EXEC
slot in multiple places in a plan.  Furthermore, in the absence of
LATERAL no such reference could be valid anyway.  But it's possible
now that we have LATERAL, and in the wake of 46c508fbc and 1db5667ba
I believe the false-match hazard is gone.  Hence, remove the
in_same_plan_level checks.  As shown in the regression test changes,
this provides a useful improvement in readability for EXPLAIN of
LATERAL-using subplans.

Richard Guo, reviewed by Greg Stark and myself

Discussion: https://postgr.es/m/CAMbWs4-YSOcQXAagJetP95cAeZPqzOy5kM5yijG0PVW5ztRb4w@mail.gmail.com
src/backend/utils/adt/ruleutils.c
src/test/regress/expected/join.out
src/test/regress/expected/subselect.out