Format Typmod? - Mailing list pgsql-hackers

From David E. Wheeler
Subject Format Typmod?
Date
Msg-id 4D34B4E6-E2CD-4D60-A607-65599BEC9D42@kineticode.com
Whole thread Raw
List pgsql-hackers
Hey Hackers,

I just had reason to want the way that format_type converts type names (e.g., varchar => character varying) in pgTAP,
butdidn't want the namespace qualification (used by format_type() when the type in question is not visible). I figured
outthat I could get that conversion by simply casting the OID argument to regtype, but then to get the typmod, I still
haveto 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
returnedby format_type()? 

Thanks,

David

pgsql-hackers by date:

Previous
From: "David E. Wheeler"
Date:
Subject: Re: First feature patch for plperl - draft [PATCH]
Next
From: Robert Haas
Date:
Subject: Re: operator exclusion constraints