| From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
|---|---|
| To: | Robert Treat <xzilla(at)users(dot)sourceforge(dot)net> |
| Cc: | pgsql-hackers(at)postgresql(dot)org |
| Subject: | Re: how to determine which types take a length argument |
| Date: | 2006-08-09 14:53:58 |
| Message-ID: | 20060809145357.GN22329@svana.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bruce Momjian | 2006-08-09 14:55:30 | Re: proposal for PL packages for 8.3. |
| Previous Message | Tom Lane | 2006-08-09 14:50:13 | Re: 8.2 features status |