From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Add num_nulls() and num_nonnulls() to count NULL arguments. |
Date: | 2016-02-05 04:03:55 |
Message-ID: | E1aRXch-0001OD-2H@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
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(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2016-02-05 12:59:00 | pgsql: Fix typo. |
Previous Message | Robert Haas | 2016-02-05 03:33:02 | pgsql: postgres_fdw: pgindent run. |