postgres.git / summary / log / commit / refs

commit    c5cf99e9e52e99400654aa51fe6aa5a8e89bab6f
Author:   Alexander Korotkov <akorotkov@postgresql.org>
Date:     Tue Mar 25 10:48:48 2025 +0000
First released in: 18.0, 17.5

    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 <tndrwang@gmail.com>
    Reviewed-by: Alexander Pyhalov <a.yhalov@postgrespro.ru>
    Backpatch-through: 17


contrib/postgres_fdw/postgres_fdw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c index 6f030e4f31b..7c4b91e01fd 100644 --- a/contrib/postgres_fdw/postgres_fdw.c +++ b/contrib/postgres_fdw/postgres_fdw.c @@ -5758,8 +5758,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 @@ -5767,6 +5766,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; } [parent: 729fe699e612]