STRICT is an optional modifier in PostgreSQL's CREATE FUNCTION statement. It is a shorthand for the longer phrase RETURNS NULL ON NULL INPUT. When a function is declared STRICT, PostgreSQL first checks every argument passed at runtime. If at least one argument is NULL, the function body is not executed and the result is immediately NULL. This behaviour reduces code inside the function, avoids unnecessary computation, and enforces predictable NULL-propagation semantics. STRICT applies to any language supported by CREATE FUNCTION (SQL, PL/pgSQL, C, etc.). It only affects runtime calls; it does not change how NULLs are stored. If you supply both STRICT and RETURNS NULL ON NULL INPUT, PostgreSQL treats them as the same. STRICT is incompatible with the CALLED ON NULL INPUT attribute (the default) and will cause a syntax error if both appear. Strictness is checked per call, so set-returning functions declared STRICT still yield zero rows when any argument is NULL.
CREATE FUNCTION, RETURNS NULL ON NULL INPUT, IMMUTABLE, STABLE, VOLATILE, NULL handling
PostgreSQL 7.3
It checks whether **any** incoming argument is NULL. If at least one is NULL, PostgreSQL skips the function body and returns NULL.
Yes. Because PostgreSQL avoids running the function at all, it saves the overhead of entering the function language interpreter or executing SQL inside it.
Absolutely. STRICT is orthogonal to volatility classifications. Mark a function STRICT IMMUTABLE when it both propagates NULLs and has no side effects.
Use CREATE OR REPLACE FUNCTION without the STRICT keyword or with CALLED ON NULL INPUT. The new definition replaces the old one.