Remove an unnecessary check on semijoin_target_ok() on postgres_fdw.c

From: Tender Wang <tndrwang(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Remove an unnecessary check on semijoin_target_ok() on postgres_fdw.c
Date: 2024-10-09 07:26:03
Message-ID: CAHewXN=8aW4hd_W71F7Ua4+_w0=bppuvvTEBFBF6G0NuSXLwUw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,
When I debug FDW join pushdown codes, I found below codes in
semijoin_target_ok():
if (bms_is_member(var->varno, innerrel->relids) &&
!bms_is_member(var->varno, outerrel->relids))

As far as I know, if a var belongs to the innerrel of joinrel, it's not
possible that it
may belong to the outerrel. So if the bms_is_member(var->varno,
innerrel->relids)
returns TRUE, then !bms_is_member(var->varno, outerrel->relids) must be
TRUE.
If bms_is_member(var->varno, innerrel->relids) returns FALSE,
!bms_is_member(var->varno, outerrel->relids) will not execute due to short
circuit.

So I think we can remove the "!bms_is_member(var->varno, outerrel->relids)"
from if.
Any thoughts?

--
Thanks,
Tender Wang

Attachment Content-Type Size
0001-Remove-an-unnecessary-check-as-Var-can-only-belong-t.patch application/octet-stream 1.2 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message ChengWen Wu 2024-10-09 07:51:59 Re: Fix orphaned 2pc file which may casue instance restart failed
Previous Message Shayon Mukherjee 2024-10-09 07:06:50 Re: Proposal to Enable/Disable Index using ALTER INDEX