pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Support domains over composite types.
3+ messages / 1 participants
[nested] [flat]

* pgsql: Support domains over composite types.
@ 2017-10-26 17:47 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2017-10-26 17:47 UTC (permalink / raw)
  To: 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(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Support domains over composite types in PL/Tcl.
@ 2017-10-26 20:00 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2017-10-26 20:00 UTC (permalink / raw)
  To: pgsql-committers

Support domains over composite types in PL/Tcl.

Since PL/Tcl does little with SQL types internally, this is just a
matter of making it work with composite-domain function arguments
and results.

In passing, make it allow RECORD-type arguments --- that's a trivial
change that nobody had bothered with up to now.

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/820c0305f64507490f00b6220f9175a303c821dd

Modified Files
--------------
src/pl/tcl/expected/pltcl_queries.out | 94 +++++++++++++++++++++++++++++++++++
src/pl/tcl/pltcl.c                    | 82 ++++++++++++++++++++----------
src/pl/tcl/sql/pltcl_queries.sql      | 43 ++++++++++++++++
3 files changed, 193 insertions(+), 26 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Support domains over composite types in PL/Perl.
@ 2017-10-28 18:02 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2017-10-28 18:02 UTC (permalink / raw)
  To: pgsql-committers

Support domains over composite types in PL/Perl.

In passing, don't insist on rsi->expectedDesc being set unless we
actually need it; this allows succeeding in a couple of cases where
PL/Perl functions returning setof composite would have failed before,
and makes the error message more apropos in other cases.

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/60651e4cddbb77e8f1a0c7fc0be6a7e7bf626fe0

Modified Files
--------------
src/pl/plperl/expected/plperl.out      |  88 ++++++++++++++++++++++++++--
src/pl/plperl/expected/plperl_util.out |  11 +++-
src/pl/plperl/plperl.c                 | 103 ++++++++++++++++++++++-----------
src/pl/plperl/sql/plperl.sql           |  49 ++++++++++++++++
src/pl/plperl/sql/plperl_util.sql      |   9 +++
5 files changed, 222 insertions(+), 38 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2017-10-28 18:02 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-10-26 17:47 pgsql: Support domains over composite types. Tom Lane <tgl@sss.pgh.pa.us>
2017-10-26 20:00 pgsql: Support domains over composite types in PL/Tcl. Tom Lane <tgl@sss.pgh.pa.us>
2017-10-28 18:02 pgsql: Support domains over composite types in PL/Perl. Tom Lane <tgl@sss.pgh.pa.us>

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