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 | -1time | 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