Evdokimov Ilia · GitHub

Commits on Aug 22, 2026

  1. Fold NOT IN / <> ALL with NULL array element to false in qual context

    When a ScalarArrayOpExpr with useOr=false (NOT IN or <> ALL) appears in
    a qual context and its array contains a NULL element, the expression can
    never evaluate to true: with a strict operator, comparing any value to
    NULL yields NULL, so the overall result is either false or NULL.  In a
    qual, both mean the row is excluded, so the expression can be safely
    folded to constant false during eval_const_expressions().  This allows
    the planner to eliminate the scan entirely rather than performing it and
    discarding all rows.
    To inform eval_const_expressions() that an expression is used as a
    qual, a new entry point eval_const_expressions_qual() is introduced.
    It sets a new is_qual flag in eval_const_expressions_context.  The flag
    is saved into a local variable and immediately reset to false at the
    start of eval_const_expressions_mutator(), so it cannot leak into
    sub-expressions where false and NULL are not interchangeable (e.g., an
    argument to a non-strict function).  The folding checks
    func_strict(saop->opfuncid) explicitly to confirm the operator is
    strict before applying the optimization.

    Evdokimov Ilia Commitfest Bot

    authored and Commitfest Bot committed

    Aug 22, 2026
    Configuration menu

    Browse the repository at this point in the history

  2. Configuration menu

    Browse the repository at this point in the history

Read the original on github.com ↗