Add num_nulls() and num_nonnulls() to count NULL arguments.

An example use-case is "CHECK(num_nonnulls(a,b,c) = 1)" to assert that
exactly one of a,b,c isn't NULL.  The functions are variadic, so they
can also be pressed into service to count the number of null or nonnull
elements in an array.

Marko Tiikkaja, reviewed by Pavel Stehule

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/6819514fca22f8554edcab6e4d0402b0221f03bb

Modified Files
--------------
doc/src/sgml/func.sgml                       |  53 ++++++++++-
src/backend/utils/adt/misc.c                 | 121 ++++++++++++++++++++++++
src/include/catalog/catversion.h             |   2 +-
src/include/catalog/pg_proc.h                |   6 ++
src/include/utils/builtins.h                 |   4 +-
src/test/regress/expected/misc_functions.out | 135 +++++++++++++++++++++++++++
src/test/regress/parallel_schedule           |   2 +-
src/test/regress/serial_schedule             |   1 +
src/test/regress/sql/misc_functions.sql      |  31 ++++++
9 files changed, 347 insertions(+), 8 deletions(-)


-- 
Sent via pgsql-committers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

Reply via email to