mirror of
https://github.com/postgres/postgres.git
synced 2025-09-09 13:09:39 +03:00
Fix how SJE checks against PHVs
It seems that a PHV evaluated/needed at or below the self join should not have a problem if we remove the self join. But this requires further investigation. For now, we just do not remove self joins if the rel to be removed is laterally referenced by PHVs. Discussion: https://postgr.es/m/CAMbWs4-ns73VF9gi37q61G3dS6Xuos+HtryMaBh37WQn=BsaJw@mail.gmail.com Author: Richard Guo
This commit is contained in:
@@ -476,7 +476,6 @@ remove_rel_from_query(PlannerInfo *root, RelOptInfo *rel,
|
||||
phv->phrels = replace_relid(phv->phrels, ojrelid, subst);
|
||||
Assert(!bms_is_empty(phv->phrels));
|
||||
replace_varno((Node *) phv->phexpr, relid, subst);
|
||||
phinfo->ph_lateral = replace_relid(phinfo->ph_lateral, relid, subst);
|
||||
Assert(phv->phnullingrels == NULL); /* no need to adjust */
|
||||
}
|
||||
}
|
||||
@@ -2134,7 +2133,8 @@ remove_self_joins_one_group(PlannerInfo *root, Relids relids)
|
||||
|
||||
/* there isn't any other place to eval PHV */
|
||||
if (bms_is_subset(phinfo->ph_eval_at, joinrelids) ||
|
||||
bms_is_subset(phinfo->ph_needed, joinrelids))
|
||||
bms_is_subset(phinfo->ph_needed, joinrelids) ||
|
||||
bms_is_member(r, phinfo->ph_lateral))
|
||||
break;
|
||||
}
|
||||
if (lc)
|
||||
|
Reference in New Issue
Block a user