Thread: OIDs of data types

OIDs of data types

From
"M. Bastin"
Date:
Hi,

I have been using the docs for about a month now, but I still haven't found where to find  a table with the field types, their matching OIDs, and type modifiers.

If anyone could show me where to find this, I would appreciate it a lot.  (I also still don't know what a "type modifier" is.  If anyone can elaborate...)

Thanks,

Marc


PS: I need that info in the light of the following spec, to know how to interprete incoming data.

backend-frontend protocol v2.0:

RowDescription (B)

Byte1('T')
Identifies the message as a row description.

Int16
Specifies the number of fields in a row (may be zero).

Then, for each field, there is the following:

String
Specifies the field name.

Int32
Specifies the object ID of the field type.

Int16
Specifies the type size.

Int32
Specifies the type modifier.

Re: OIDs of data types

From
Tom Lane
Date:
"M. Bastin" <marcbastin@mindspring.com> writes:
> I have been using the docs for about a month now, but I still haven't
> found where to find  a table with the field types, their matching
> OIDs, and type modifiers.

select oid, typname from pg_type;

> If anyone could show me where to find this, I would appreciate it a
> lot.  (I also still don't know what a "type modifier" is.  If anyone
> can elaborate...)

Type-specific additional information, for example the max length for
a CHARACTER(n) column or the precision for a TIMESTAMP(n) column.
This is poorly documented, but you can figure out the encoding by
experimentation --- there are only a very small number of types that use
typmod, since by definition special type declaration syntax is needed
for each such type.

            regards, tom lane