Re: how to determine which types take a length argument - Mailing list pgsql-hackers

From Martijn van Oosterhout
Subject Re: how to determine which types take a length argument
Date
Msg-id 20060809145357.GN22329@svana.org
Whole thread Raw
In response to how to determine which types take a length argument  (Robert Treat <xzilla@users.sourceforge.net>)
Responses Re: how to determine which types take a length argument
List pgsql-hackers
On Wed, Aug 09, 2006 at 10:44:22AM -0400, Robert Treat wrote:
> Is there a way to determine which datatypes take a length argument (eg.
> varchar, time, etc...) by looking in the system catalogs? pg_type doesnt seem
> to have the info... or is there a single place in the back end code that
> contains this info?

Sure, wherever the typlen column in pg_type is -1. In that column,
positive is fixed length, -1 is a verlena type and -2 is null
terminated (for cstring).

In the backend this info is available using get_typlenbyval() or a few
other functions, see utils/cache/lsyscache.c

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: 8.2 features status
Next
From: Bruce Momjian
Date:
Subject: Re: proposal for PL packages for 8.3.