Hey Hackers,

I just had reason to want the way that format_type converts type names (e.g., varchar => character varying) in pgTAP, but didn't want the namespace qualification (used by format_type() when the type in question is not visible). I figured out that I could get that conversion by simply casting the OID argument to regtype, but then to get the typmod, I still have to use format_type() like so:

CREATE OR REPLACE FUNCTION display_type ( OID, INTEGER )
RETURNS TEXT AS $$
SELECT $1::regtype || COALESCE(
substring(pg_catalog.format_type($1, $2), '[(][^)]+[)]$'),
'')
$$ LANGUAGE SQL;

Is there a saner way to do it than this? That is, is there a better way to get the typmod than by munging the value returned by format_type()?

Thanks,

David

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-hackers @
categoriespostgresql
postedDec 4, '09 at 1:40a
activeDec 4, '09 at 1:40a
posts1
users1
websitepostgresql.org...
irc#postgresql

1 user in discussion

David E. Wheeler: 1 post

People

Translate

site design / logo © 2022 Grokbase