aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/plan/setrefs.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2023-06-12 10:01:26 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2023-06-12 10:01:26 -0400
commitbfd332b3fda5c73e28c05b7ba0aac6cf053cdf00 (patch)
tree7d29b08446723d1ed812546bc092c768be087a5c /src/backend/optimizer/plan/setrefs.c
parent548d7260309008b146bd9eaa66f3c5be0a8d725a (diff)
downloadpostgresql-bfd332b3fda5c73e28c05b7ba0aac6cf053cdf00.tar.gz
postgresql-bfd332b3fda5c73e28c05b7ba0aac6cf053cdf00.zip
Fix "wrong varnullingrels" for subquery nestloop parameters.
If we apply outer join identity 3 when relation C is a subquery having lateral references to relation B, then the lateral references within C continue to bear the original syntactically-correct varnullingrels marks, but that won't match what is available from the outer side of the nestloop. Compensate for that in process_subquery_nestloop_params(). This is a slightly hacky fix, but we certainly don't want to re-plan C in toto for each possible outer join order, so there's not a lot of better alternatives. Richard Guo and Tom Lane, per report from Markus Winand Discussion: https://postgr.es/m/DFBB2D25-DE97-49CA-A60E-07C881EA59A7@winand.at
Diffstat (limited to 'src/backend/optimizer/plan/setrefs.c')
-rw-r--r--src/backend/optimizer/plan/setrefs.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c
index 1ca26baa259..3585a703fbd 100644
--- a/src/backend/optimizer/plan/setrefs.c
+++ b/src/backend/optimizer/plan/setrefs.c
@@ -2289,9 +2289,11 @@ set_join_references(PlannerInfo *root, Join *join, int rtoffset)
* the outer-join level at which they are used, Vars seen in the
* NestLoopParam expression may have nullingrels that are just a
* subset of those in the Vars actually available from the outer
- * side. Not checking this exactly is a bit grotty, but the work
- * needed to make things match up perfectly seems well out of
- * proportion to the value.
+ * side. Another case that can cause that to happen is explained
+ * in the comments for process_subquery_nestloop_params. Not
+ * checking this exactly is a bit grotty, but the work needed to
+ * make things match up perfectly seems well out of proportion to
+ * the value.
*/
nlp->paramval = (Var *) fix_upper_expr(root,
(Node *) nlp->paramval,