pgsql: Add to_regtypemod function to extract typemod from a string type

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add to_regtypemod function to extract typemod from a string type
Date: 2024-03-20 21:11:41
Message-ID: E1rn3Dp-004pt0-9c@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Add to_regtypemod function to extract typemod from a string type name.

In combination with to_regtype, this allows converting a string to
the "canonicalized" form emitted by format_type. That usage requires
parsing the string twice, which is slightly annoying but not really
too expensive. We considered alternatives such as returning a record
type, but that way was notationally uglier than this, and possibly
less flexible.

Like to_regtype(), we'd rather that this return NULL for any bad
input, but the underlying type-parsing logic isn't yet capable of
not throwing syntax errors. Adjust the documentation for both
functions to point that out.

In passing, fix up a couple of nearby entries in the System Catalog
Information Functions table that had not gotten the word about our
since-v13 convention for displaying function usage examples.

David Wheeler and Erik Wienhold, reviewed by Pavel Stehule, Jim Jones,
and others.

Discussion: https://postgr.es/m/DF2324CA-2673-4ABE-B382-26B5770B6AA3@justatheory.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1218ca9956ee60afc6975f14c1a4c953bd6bbaa7

Modified Files
--------------
doc/src/sgml/func.sgml | 77 +++++++++++++++++++++--------------
src/backend/utils/adt/regproc.c | 20 +++++++++
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_proc.dat | 3 ++
src/test/regress/expected/regproc.out | 37 +++++++++++++++++
src/test/regress/sql/regproc.sql | 8 ++++
6 files changed, 115 insertions(+), 32 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2024-03-20 22:02:57 pgsql: Un-break genbki.pl's error reporting capabilities.
Previous Message Nathan Bossart 2024-03-20 18:34:30 pgsql: Avoid overflow in MaybeRemoveOldWalSummaries().