Re: ERROR: no relation entry for relid 6
Richard Guo <guofenglinux@gmail.com>
From: Richard Guo <guofenglinux@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2023-05-30T09:05:26Z
Lists: pgsql-hackers
On Tue, May 30, 2023 at 10:28 AM Richard Guo <guofenglinux@gmail.com> wrote:
> I haven't thought through how to fix it, but I suspect that we may need
> to do more checking before we decide to remove PHVs in
> remove_rel_from_query.
>
Hmm, maybe we can additionally check if the PHV needs to be evaluated
above the join. If so it cannot be removed.
--- a/src/backend/optimizer/plan/analyzejoins.c
+++ b/src/backend/optimizer/plan/analyzejoins.c
@@ -425,7 +425,8 @@ remove_rel_from_query(PlannerInfo *root, int relid,
SpecialJoinInfo *sjinfo)
Assert(!bms_is_member(relid, phinfo->ph_lateral));
if (bms_is_subset(phinfo->ph_needed, joinrelids) &&
- bms_is_member(relid, phinfo->ph_eval_at))
+ bms_is_member(relid, phinfo->ph_eval_at) &&
+ !bms_is_member(ojrelid, phinfo->ph_eval_at))
{
root->placeholder_list =
foreach_delete_current(root->placeholder_list,
l);
Does this make sense?
Thanks
Richard
Commits
-
Fix oversight in outer join removal.
- 9a2dbc614e6e 16.0 landed
-
Fix joinclause removal logic to cope with cloned clauses.
- 7a844c77ece1 16.0 landed