Re: [HACKERS] Types - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] Types
Date
Msg-id 20545.948557376@sss.pgh.pa.us
Whole thread Raw
In response to Re: [HACKERS] Types  ("Oliver Elphick" <olly@lfix.co.uk>)
List pgsql-hackers
"Oliver Elphick" <olly@lfix.co.uk> writes:
> Michael Meskes wrote:
>> libpq gives back the internal typenumbers of the attributes. How do I know
>> which number means which type? I need to find out if the type is an array.

> If the type is 1007, then:

> template1=> select typname from pg_type where oid = 1007;
> typname
> -------
> _int4  
> (1 row)

Right...

> If the typename begins with an underscore, it is an array type.

If you are going to the trouble of looking in pg_type, then you
shouldn't rely on the convention that array type names begin with
underscores.  What you *should* do is look at the typelem field.
If that's zero, it's not an array; if nonzero, it is an array type
(and typelem gives the OID of the array elements' type).
        regards, tom lane


pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: [HACKERS] Status on 7.0
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] Re: vacuum timings