Re: how to determine which types take a length argument

From: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: how to determine which types take a length argument
Date: 2006-08-09 17:20:41
Message-ID: 200608091320.41481.xzilla@users.sourceforge.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wednesday 09 August 2006 10:53, Martijn van Oosterhout wrote:
> 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).
>

pagila=# select now()::varchar(3), now()::time(3);
now | now
-----+--------------
200 | 13:19:34.339
(1 row)
pagila=# select typname, typlen from pg_type where typname in
('varchar', 'time');
typname | typlen
---------+--------
varchar | -1
time | 8
(2 rows)

Both time and varchar take an argument, but they have different typlen values.
I don't think the docs are wrong here, I think they just don't tell me what I
am looking for.

--
Robert Treat
Build A Brighter LAMP :: Linux Apache {middleware} PostgreSQL

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Pflug 2006-08-09 17:28:07 remote query debugging was: Plugins redux
Previous Message Andrew Dunstan 2006-08-09 17:15:13 Re: proposal for PL packages for 8.3.