• Tom Lane's avatar
    Improve predtest.c's internal docs, and enhance its functionality a bit. · 5748f3a0
    Tom Lane authored
    Commit b08df9ca left things rather poorly documented as far as the
    exact semantics of "clause_is_check" mode went.  Also, that mode did
    not really work correctly for predicate_refuted_by; although given the
    lack of specification as to what it should do, as well as the lack
    of any actual use-case, that's perhaps not surprising.
    
    Rename "clause_is_check" to "weak" proof mode, and provide specifications
    for what it should do.  I defined weak refutation as meaning "truth of A
    implies non-truth of B", which makes it possible to use the mode in the
    part of relation_excluded_by_constraints that checks for mutually
    contradictory WHERE clauses.  Fix up several places that did things wrong
    for that definition.  (As far as I can see, these errors would only lead
    to failure-to-prove, not incorrect claims of proof, making them not
    serious bugs even aside from the fact that v10 contains no use of this
    mode.  So there seems no need for back-patching.)
    
    In addition, teach predicate_refuted_by_recurse that it can use
    predicate_implied_by_recurse after all when processing a strong NOT-clause,
    so long as it asks for the correct proof strength.  This is an optimization
    that could have been included in commit b08df9ca, but wasn't.
    
    Also, simplify and generalize the logic that checks for whether nullness of
    the argument of IS [NOT] NULL would force overall nullness of the predicate
    or clause.  (This results in a change in the partition_prune test's output,
    as it is now able to prune an all-nulls partition that it did not recognize
    before.)
    
    In passing, in PartConstraintImpliedByRelConstraint, remove bogus
    conversion of the constraint list to explicit-AND form and then right back
    again; that accomplished nothing except forcing a useless extra level of
    recursion inside predicate_implied_by.
    
    Discussion: https://postgr.es/m/5983.1520487191@sss.pgh.pa.us
    5748f3a0
predtest.c 62.3 KB