Add error_on_null(), checking if the input is the null value
authorMichael Paquier <[email protected]>
Wed, 22 Oct 2025 00:55:17 +0000 (09:55 +0900)
committerMichael Paquier <[email protected]>
Wed, 22 Oct 2025 00:55:17 +0000 (09:55 +0900)
commit2b75c38b707a070922231de667a0bd08ee71b268
tree554bcd6bd9ccca62674da2bb711441888d20917e
parent2470ca435c452fe4def9dcc4a831b5101691d541
Add error_on_null(), checking if the input is the null value

This polymorphic function produces an error if the input value is
detected as being the null value; otherwise it returns the input value
unchanged.

This function can for example become handy in SQL function bodies, to
enforce that exactly one row was returned.

Author: Joel Jacobson <[email protected]>
Reviewed-by: Vik Fearing <[email protected]>
Reviewed-by: Michael Paquier <[email protected]>
Discussion: https://postgr.es/m/ece8c6d1-2ab1-45d5-ba12-8dec96fc8886@app.fastmail.com
Discussion: https://postgr.es/m/de94808d-ed58-4536-9e28-e79b09a534c7@app.fastmail.com
doc/src/sgml/func/func-comparison.sgml
src/backend/utils/adt/misc.c
src/include/catalog/pg_proc.dat
src/test/regress/expected/misc_functions.out
src/test/regress/sql/misc_functions.sql