"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