#include "postgres.h" #include "fmgr.h" PG_MODULE_MAGIC; Datum count_nulls(PG_FUNCTION_ARGS); PG_FUNCTION_INFO_V1(count_nulls); Datum count_nulls(PG_FUNCTION_ARGS) { int nargs = PG_NARGS(); int num_nulls = 0; int i; for (i = 0; i < nargs; i++) { if (PG_ARGISNULL(i)) num_nulls++; } PG_RETURN_INT32(num_nulls); }