postgres-github.git / summary / log / commit / refs

commit    c66d6d19eb1a7bde17acaab421158be9cc94add8
Author:   Richard Guo <rguo@postgresql.org>
Date:     Mon Apr 27 01:40:37 2026 +0000

    Fix bogus calls in remove_self_join_rel()
    
    remove_self_join_rel() called adjust_relid_set() on all_result_relids
    and leaf_result_relids but threw away the return value.  Since
    adjust_relid_set() returns a freshly-built Relids and does not modify
    the input in place, the calls did nothing.  This has been the case
    since the SJE feature went in (commit fc069a3a6).
    
    There has been no observable misbehavior, because the relid being
    passed is guaranteed not to be a member of either set.  At the point
    remove_self_join_rel() runs, those sets contain only resultRelation;
    inheritance children have not been added yet, as that happens later in
    query_planner(), in expand_single_inheritance_child() called from
    add_other_rels_to_query().  And remove_self_joins_recurse() rejects
    parse->resultRelation as an SJE candidate to preserve the EvalPlanQual
    mechanism.  Even with the result assigned, the calls would be no-ops
    in practice.
    
    Rather than make the calls do the cleanup they pretend to do, replace
    them with assertions of the invariant.  Any future loosening of the
    SJE candidate filter -- for instance to allow eliminating a result
    relation under provable conditions -- will trip the assertion and
    force whoever does it to revisit this code.
    
    Additionally, decorate adjust_relid_set() with pg_nodiscard so that
    any future accidental discard of its return value is caught at compile
    time.
    
    Author: Richard Guo <guofenglinux@gmail.com>
    Reviewed-by: David Rowley <dgrowleyml@gmail.com>
    Discussion: https://postgr.es/m/CAMbWs49fYQcqJfJ_Gtn8r1GFNoYtb1=2AUab4ieuqY4Zid9ocQ@mail.gmail.com

[parent: b801d5eef17f]