Re: [libpq] OIDs of extension types? Of custom types?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [libpq] OIDs of extension types? Of custom types?
Дата
Msg-id 1183347.1665758109@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [libpq] OIDs of extension types? Of custom types?  (Dominique Devienne <ddevienne@gmail.com>)
Ответы Re: [libpq] OIDs of extension types? Of custom types?  (Dominique Devienne <ddevienne@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Dominique Devienne
Дата:
Сообщение: Re: [libpq] OIDs of extension types? Of custom types?
Следующее
От: "Daniel Verite"
Дата:
Сообщение: Re: Number of updated rows with LibPQ