summaryrefslogtreecommitdiffstats
path: root/src/backend/optimizer/prep/prepjointree.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/backend/optimizer/prep/prepjointree.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/backend/optimizer/prep/prepjointree.c b/src/backend/optimizer/prep/prepjointree.c
index 7f4bb7b..ea05763 100644
--- a/src/backend/optimizer/prep/prepjointree.c
+++ b/src/backend/optimizer/prep/prepjointree.c
@@ -2471,8 +2471,13 @@ pullup_replace_vars_callback(Var *var,
else if (newnode && IsA(newnode, PlaceHolderVar) &&
((PlaceHolderVar *) newnode)->phlevelsup == 0)
{
- /* No need to wrap a PlaceHolderVar with another one, either */
- wrap = false;
+ /* The same rules apply for a PlaceHolderVar */
+ if (rcon->target_rte->lateral &&
+ !bms_is_subset(((PlaceHolderVar *) newnode)->phrels,
+ rcon->relids))
+ wrap = true;
+ else
+ wrap = false;
}
else if (rcon->wrap_non_vars)
{