Re: [libpq] OIDs of extension types? Of custom types? - Mailing list pgsql-general

From Tom Lane
Subject Re: [libpq] OIDs of extension types? Of custom types?
Date
Msg-id 1183347.1665758109@sss.pgh.pa.us
Whole thread Raw
In response to Re: [libpq] OIDs of extension types? Of custom types?  (Dominique Devienne <ddevienne@gmail.com>)
Responses Re: [libpq] OIDs of extension types? Of custom types?
List pgsql-general
Dominique Devienne <ddevienne@gmail.com> writes:
> On Fri, Oct 14, 2022 at 2:31 PM Laurenz Albe <laurenz.albe@cybertec.at> wrote:
>> You use the #defines like TEXTOID for the built-in Oids, right?

> I don't. I used
> https://github.com/postgres/postgres/blob/master/src/include/catalog/pg_type.dat
> as a reference.
> I suspect that should be fairly stable, right? I have at least 2 or 3
> dozen OIDs pairs (scalar + array) of primitives
> and other types (Oid, Name, Text, Bytea, Uuid, etc...). Are there
> #defines for all of those? Where?

They're stable, but writing magic numbers leads to unreadable code.
Use the macros from catalog/pg_type_d.h.

>> For types from an extensions, you would run a query on "pg_type".

>  OK, thanks.

In SQL queries, you can avoid hard-wiring anything by writing
things like "'hstore'::regtype".  It may or may not be possible
to avoid fetching the OID altogether that way.

            regards, tom lane



pgsql-general by date:

Previous
From: Dominique Devienne
Date:
Subject: Re: [libpq] OIDs of extension types? Of custom types?
Next
From: "Daniel Verite"
Date:
Subject: Re: Number of updated rows with LibPQ