Re: ERROR: no relation entry for relid 6 - Mailing list pgsql-hackers

From Richard Guo
Subject Re: ERROR: no relation entry for relid 6
Date
Msg-id CAMbWs49=uXcRNfV3nH0LAgwpo2F=jYnbhOJqWOaaBT8x-vnHdw@mail.gmail.com
Whole thread Raw
In response to Re: ERROR: no relation entry for relid 6  (Richard Guo <guofenglinux@gmail.com>)
Responses Re: ERROR: no relation entry for relid 6
List 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

pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: [16Beta1][doc] Add BackendType for standalone backends
Next
From: Bruce Momjian
Date:
Subject: Re: PG 16 draft release notes ready