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/[email protected]
Discussion: 
https://postgr.es/m/[email protected]

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2b75c38b707a070922231de667a0bd08ee71b268

Modified Files
--------------
doc/src/sgml/func/func-comparison.sgml       | 22 ++++++++++++++++++++
src/backend/utils/adt/misc.c                 | 14 +++++++++++++
src/include/catalog/pg_proc.dat              |  3 +++
src/test/regress/expected/misc_functions.out | 31 ++++++++++++++++++++++++++++
src/test/regress/sql/misc_functions.sql      | 11 ++++++++++
5 files changed, 81 insertions(+)

Reply via email to