oid data types mapping in libpq functions

Started by zhong ming wualmost 16 years ago3 messagesgeneral
Jump to latest
#1zhong ming wu
mr.z.m.wu@gmail.com

Dear List

Where can I find this mapping of oid to pg data types mentioned in
libpq documentation?
Why is such information not mentioned in the documentation? A general
knowledge?

Thanks

Mr Wi

#2Adrian Klaver
adrian.klaver@aklaver.com
In reply to: zhong ming wu (#1)
Re: oid data types mapping in libpq functions

On Wednesday 16 June 2010 7:42:02 pm zhong ming wu wrote:

Dear List

Where can I find this mapping of oid to pg data types mentioned in
libpq documentation?
Why is such information not mentioned in the documentation? A general
knowledge?

Thanks

Mr Wi

I think you are looking for the table pg_type.

SELECT oid,typname from pg_type;

--
Adrian Klaver
adrian.klaver@gmail.com

#3Merlin Moncure
mmoncure@gmail.com
In reply to: zhong ming wu (#1)
Re: oid data types mapping in libpq functions

On Wed, Jun 16, 2010 at 10:42 PM, zhong ming wu <mr.z.m.wu@gmail.com> wrote:

Dear List

Where can I find this mapping of oid to pg data types mentioned in
libpq documentation?
Why is such information not mentioned in the documentation?  A general
knowledge?

curious: what do you need the oids for?

built in type oids are defined in pg_type.h:
cat src/include/catalog/pg_type.h | grep OID | grep define

built in type oids don't change. you can pretty much copy/pasto the
output of above into an app...just watch out for some types that may
not be in older versions.

user defined type oids (tables, views, composite types, enums, and
domains) have an oid generated when it is created. since that oid can
change via ddl so you should look it up by name at appropriate times.

if you want to be completely abstracted from the type oids, look here:
http://libpqtypes.esilo.com/

merlin