]> granicus.if.org Git - postgresql/commit
Add num_nulls() and num_nonnulls() to count NULL arguments.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 5 Feb 2016 04:03:10 +0000 (23:03 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 5 Feb 2016 04:03:37 +0000 (23:03 -0500)
commit6819514fca22f8554edcab6e4d0402b0221f03bb
treee78c772e621f3f83804d76d024fdbdf80943a7de
parentd0cd7bda97a626049aa7d247374909c52399c413
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
doc/src/sgml/func.sgml
src/backend/utils/adt/misc.c
src/include/catalog/catversion.h
src/include/catalog/pg_proc.h
src/include/utils/builtins.h
src/test/regress/expected/misc_functions.out [new file with mode: 0644]
src/test/regress/parallel_schedule
src/test/regress/serial_schedule
src/test/regress/sql/misc_functions.sql [new file with mode: 0644]