pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add error_on_null(), checking if the input is the null value
Date: Wed, 22 Oct 2025 00:59:20 +0000
Message-ID: <E1vBNCC-002ryU-0S@gemulon.postgresql.org> (raw)

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 <joel@compiler.org>
Reviewed-by: Vik Fearing <vik@postgresfriends.org>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/ece8c6d1-2ab1-45d5-ba12-8dec96fc8886@app.fastmail.com
Discussion: https://postgr.es/m/de94808d-ed58-4536-9e28-e79b09a534c7@app.fastmail.com

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(+)



Message-ID: <E1vBNCC-002ryU-0S@gemulon.postgresql.org>
Permalink:  ../E1vBNCC-002ryU-0S@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1vBNCC-002ryU-0S@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Add error_on_null(), checking if the input is the null value
  In-Reply-To: <E1vBNCC-002ryU-0S@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox