pgsql: Support domains over composite types.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Support domains over composite types.
Date: 2017-10-26 17:47:51
Message-ID: E1e7mFz-0002Gh-Qw@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Support domains over composite types.

This is the last major omission in our domains feature: you can now
make a domain over anything that's not a pseudotype.

The major complication from an implementation standpoint is that places
that might be creating tuples of a domain type now need to be prepared
to apply domain_check(). It seems better that unprepared code fail
with an error like "<type> is not composite" than that it silently fail
to apply domain constraints. Therefore, relevant infrastructure like
get_func_result_type() and lookup_rowtype_tupdesc() has been adjusted
to treat domain-over-composite as a distinct case that unprepared code
won't recognize, rather than just transparently treating it the same
as plain composite. This isn't a 100% solution to the possibility of
overlooked domain checks, but it catches most places.

In passing, improve typcache.c's support for domains (it can now cache
the identity of a domain's base type), and rewrite the argument handling
logic in jsonfuncs.c's populate_record[set]_worker to reduce duplicative
per-call lookups.

I believe this is code-complete so far as the core and contrib code go.
The PLs need varying amounts of work, which will be tackled in followup
patches.

Discussion: https://postgr.es/m/4206.1499798337@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/37a795a60b4f4b1def11c615525ec5e0e9449e05

Modified Files
--------------
contrib/hstore/hstore_io.c | 46 +++-
doc/src/sgml/datatype.sgml | 3 +-
doc/src/sgml/rowtypes.sgml | 5 +-
doc/src/sgml/xfunc.sgml | 37 ++-
src/backend/catalog/pg_inherits.c | 9 +-
src/backend/catalog/pg_proc.c | 2 +-
src/backend/commands/tablecmds.c | 6 +-
src/backend/commands/typecmds.c | 11 +-
src/backend/executor/execExprInterp.c | 6 +-
src/backend/executor/execSRF.c | 5 +-
src/backend/executor/functions.c | 15 +-
src/backend/executor/nodeFunctionscan.c | 3 +-
src/backend/nodes/makefuncs.c | 6 +-
src/backend/optimizer/util/clauses.c | 10 +-
src/backend/parser/parse_coerce.c | 48 +++-
src/backend/parser/parse_func.c | 9 +-
src/backend/parser/parse_relation.c | 18 +-
src/backend/parser/parse_target.c | 49 ++--
src/backend/parser/parse_type.c | 38 ++-
src/backend/utils/adt/domains.c | 9 +-
src/backend/utils/adt/jsonfuncs.c | 431 +++++++++++++++++++++-----------
src/backend/utils/adt/ruleutils.c | 18 +-
src/backend/utils/cache/lsyscache.c | 18 +-
src/backend/utils/cache/typcache.c | 130 ++++++++--
src/backend/utils/fmgr/funcapi.c | 93 +++++--
src/include/access/htup_details.h | 5 +
src/include/access/tupdesc.h | 6 +
src/include/funcapi.h | 11 +-
src/include/nodes/primnodes.h | 11 +-
src/include/parser/parse_type.h | 4 +-
src/include/utils/typcache.h | 17 +-
src/test/regress/expected/domain.out | 96 +++++++
src/test/regress/expected/json.out | 53 ++++
src/test/regress/expected/jsonb.out | 53 ++++
src/test/regress/sql/domain.sql | 47 ++++
src/test/regress/sql/json.sql | 23 ++
src/test/regress/sql/jsonb.sql | 23 ++
37 files changed, 1083 insertions(+), 291 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2017-10-26 20:00:22 pgsql: Support domains over composite types in PL/Tcl.
Previous Message Michael Paquier 2017-10-26 16:23:00 Re: [COMMITTERS] pgsql: Process variadic arguments consistently in json functions