From: Alexander Korotkov Date: Tue, 25 Mar 2025 10:48:48 +0000 (+0200) Subject: postgres_fdw: Remove redundant check in semijoin_target_ok() X-Git-Tag: REL_18_BETA1~454 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=62f36d6924c740b5a566d64c563789d20cd4a5e1;p=postgresql.git postgres_fdw: Remove redundant check in semijoin_target_ok() If a var belongs to the innerrel of the joinrel, it's not possible that it belongs to the outerrel. This commit removes the redundant check from the if-clause but keeps it as an assertion. Discussion: https://postgr.es/m/flat/CAHewXN=8aW4hd_W71F7Ua4+_w0=bppuvvTEBFBF6G0NuSXLwUw@mail.gmail.com Author: Tender Wang Reviewed-by: Alexander Pyhalov Backpatch-through: 17 --- diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c index d94c4ce9fd7..7a5439a460b 100644 --- a/contrib/postgres_fdw/postgres_fdw.c +++ b/contrib/postgres_fdw/postgres_fdw.c @@ -5768,8 +5768,7 @@ semijoin_target_ok(PlannerInfo *root, RelOptInfo *joinrel, RelOptInfo *outerrel, if (!IsA(var, Var)) continue; - if (bms_is_member(var->varno, innerrel->relids) && - !bms_is_member(var->varno, outerrel->relids)) + if (bms_is_member(var->varno, innerrel->relids)) { /* * The planner can create semi-join, which refers to inner rel @@ -5777,6 +5776,7 @@ semijoin_target_ok(PlannerInfo *root, RelOptInfo *joinrel, RelOptInfo *outerrel, * exists() subquery, so can't handle references to inner rel in * the target list. */ + Assert(!bms_is_member(var->varno, outerrel->relids)); ok = false; break; }