From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Make PL/Python handle domain-type conversions correctly.
Date: Thu, 16 Nov 2017 21:23:14 +0000
Message-ID: <E1eFRcw-0002tn-GI@gemulon.postgresql.org> (raw)
Make PL/Python handle domain-type conversions correctly.
Fix PL/Python so that it can handle domains over composite, and so that
it enforces domain constraints correctly in other cases that were not
always done properly before. Notably, it didn't do arrays of domains
right (oversight in commit c12d570fa), and it failed to enforce domain
constraints when returning a composite type containing a domain field,
and if a transform function is being used for a domain's base type then
it failed to enforce domain constraints on the result. Also, in many
places it missed checking domain constraints on null values, because
the plpy_typeio code simply wasn't called for Py_None.
Rather than try to band-aid these problems, I made a significant
refactoring of the plpy_typeio logic. The existing design of recursing
for array and composite members is extended to also treat domains as
containers requiring recursion, and the APIs for the module are cleaned
up and simplified.
The patch also modifies plpy_typeio to rely on the typcache more than
it did before (which was pretty much not at all). This reduces the
need for repetitive lookups, and lets us get rid of an ad-hoc scheme
for detecting changes in composite types. I added a couple of small
features to typcache to help with that.
Although some of this is fixing bugs that long predate v11, I don't
think we should risk a back-patch: it's a significant amount of code
churn, and there've been no complaints from the field about the bugs.
Tom Lane, reviewed by Anthony Bykov
Discussion: https://postgr.es/m/24449.1509393613@sss.pgh.pa.us
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/687f096ea9da82d267f1809a5f3fdfa027092045
Modified Files
--------------
.../hstore_plpython/expected/hstore_plpython.out | 20 +-
contrib/hstore_plpython/sql/hstore_plpython.sql | 16 +-
src/backend/utils/cache/typcache.c | 7 +
src/include/utils/typcache.h | 5 +-
src/pl/plpython/expected/plpython_types.out | 128 +++
src/pl/plpython/expected/plpython_types_3.out | 128 +++
src/pl/plpython/plpy_cursorobject.c | 76 +-
src/pl/plpython/plpy_cursorobject.h | 2 +-
src/pl/plpython/plpy_exec.c | 173 +--
src/pl/plpython/plpy_main.c | 7 +-
src/pl/plpython/plpy_planobject.h | 2 +-
src/pl/plpython/plpy_procedure.c | 148 +--
src/pl/plpython/plpy_procedure.h | 8 +-
src/pl/plpython/plpy_spi.c | 84 +-
src/pl/plpython/plpy_typeio.c | 1192 +++++++++++---------
src/pl/plpython/plpy_typeio.h | 220 ++--
src/pl/plpython/sql/plpython_types.sql | 91 ++
17 files changed, 1378 insertions(+), 929 deletions(-)
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: Make PL/Python handle domain-type conversions correctly.
In-Reply-To: <E1eFRcw-0002tn-GI@gemulon.postgresql.org>
References: <E1eFRcw-0002tn-GI@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