pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Fix plpgsql to enforce domain checks when returning a NULL domai
Date: Thu, 15 Feb 2018 21:25:28 +0000
Message-ID: <E1emR20-0005Wb-0R@gemulon.postgresql.org> (raw)

Fix plpgsql to enforce domain checks when returning a NULL domain value.

If a plpgsql function is declared to return a domain type, and the domain's
constraints forbid a null value, it was nonetheless possible to return
NULL, because we didn't bother to check the constraints for a null result.
I'd noticed this while fooling with domains-over-composite, but had not
gotten around to fixing it immediately.

Add a regression test script exercising this and various other domain
cases, largely borrowed from the plpython_types test.

Although this is clearly a bug fix, I'm not sure whether anyone would
thank us for changing the behavior in stable branches, so I'm inclined
not to back-patch.

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/51db0d18fbf58b0c2e5ebc2b5b2c48daf45c8d93

Modified Files
--------------
src/pl/plpgsql/src/Makefile                    |   2 +-
src/pl/plpgsql/src/expected/plpgsql_domain.out | 397 +++++++++++++++++++++++++
src/pl/plpgsql/src/pl_comp.c                   |   4 +
src/pl/plpgsql/src/pl_exec.c                   |  16 +
src/pl/plpgsql/src/plpgsql.h                   |   1 +
src/pl/plpgsql/src/sql/plpgsql_domain.sql      | 279 +++++++++++++++++
6 files changed, 698 insertions(+), 1 deletion(-)



Message-ID: <E1emR20-0005Wb-0R@gemulon.postgresql.org>
Permalink:  ../E1emR20-0005Wb-0R@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1emR20-0005Wb-0R@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix plpgsql to enforce domain checks when returning a NULL domai
  In-Reply-To: <E1emR20-0005Wb-0R@gemulon.postgresql.org>
  References: <E1emR20-0005Wb-0R@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