pgsql: Fix plpgsql to enforce domain checks when returning a NULLdomai - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Fix plpgsql to enforce domain checks when returning a NULLdomai
Date
Msg-id E1emR20-0005Wb-0R@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Doc: fix minor bug in CREATE TABLE example.
Next
From: Andres Freund
Date:
Subject: Re: pgsql: Use new overflow aware integer operations.