Re: Object IDs in Parse message

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Malcolm Matalka <mmatalka(at)gmail(dot)com>
Cc: pgsql-interfaces(at)lists(dot)postgresql(dot)org
Subject: Re: Object IDs in Parse message
Date: 2019-09-03 20:24:39
Message-ID: 32018.1567542279@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Malcolm Matalka <mmatalka(at)gmail(dot)com> writes:
> Hello, I'm implementing my own pgsql client for fun and I'm trying to
> understand how to send a Parse message. The final parameter to Parse is
> a series of Int32s with the description:
> Specifies the object ID of the parameter data type. Placing a zero here
> is equivalent to leaving the type unspecified.

> But where do I find the list of object IDs?

SELECT oid, typname FROM pg_type;

> If so, It's not clear how to express some things. For example there is
> a MONEYARRAYOID, but no MONEYOID.

For historical reasons, the macro for money's OID is CASHOID.
There's no grandfathered symbol for money[], though, so that
gets a name constructed per standard rules (cf form_pg_type_symbol
in genbki.pl).

However, I fail to see why a generic client would need to know that.
If you're hard-wiring OIDs into your code for anything beyond very
basic types like int4, you're probably doing it wrong. Remember
that PG is an extensible system and you may be called on to handle
queries that deal with non-built-in types, so even if you had
code for everything appearing in pg_type_d.h, it wouldn't be
exhaustive. Better to look up type OIDs at runtime. In the case
of Parse messages, you likely want to let the backend resolve
the parameter types anyway, ie just send zeroes.

regards, tom lane

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Malcolm Matalka 2019-09-04 07:39:47 Re: Object IDs in Parse message
Previous Message Dave Cramer 2019-09-03 20:02:24 Re: Object IDs in Parse message