The bogus calls in remove_self_join_rel()

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: The bogus calls in remove_self_join_rel()
Date: 2026-04-23 02:45:59
Message-ID: CAMbWs49fYQcqJfJ_Gtn8r1GFNoYtb1=2AUab4ieuqY4Zid9ocQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I noticed these two calls in remove_self_join_rel():

adjust_relid_set(root->all_result_relids, toRemove->relid, toKeep->relid);
adjust_relid_set(root->leaf_result_relids, toRemove->relid, toKeep->relid);

There's no comment explaining them, and as far as I can tell they do
nothing: adjust_relid_set returns a Relids and does not modify the
input in place.

Rather than make the calls do the cleanup they pretend to do, I think
a better way is to replace them with assertions: toRemove->relid is
not a member of either set. This is true as these two sets contain
only parse->resultRelation (rejected as an SJE candidate to preserve
EvalPlanQual) and inheritance children of the target, which never
appear in the joinlist that SJE scans for candidates.

Thoughts?

- Richard

Attachment Content-Type Size
v1-0001-Fix-bogus-calls-in-remove_self_join_rel.patch application/octet-stream 2.7 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2026-04-23 02:57:23 Re: [PATCH] Fix duplicate errmsg in ALTER TABLE SPLIT PARTITION
Previous Message Peter Smith 2026-04-23 02:31:31 Re: Parallel Apply