pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dominique Devienne <ddevienne@gmail.com>
Cc: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: pgsql-general@postgresql.org
Subject: Re: [libpq] OIDs of extension types? Of custom types?
Date: Fri, 14 Oct 2022 10:35:09 -0400
Message-ID: <1183347.1665758109@sss.pgh.pa.us> (raw)
In-Reply-To: <CAFCRh-_k_kFRw6FWnmQdo4NEk9ufOaC+80ithjYESXk16ZMhKg@mail.gmail.com>
References: <CAFCRh-85tjcuHViBFtn8p53-URXrgJRqs3XdKx6igHqbZed0Gg@mail.gmail.com>
	<e413a7ce097b9f3beb015e42dfcb6f0d9d8eccea.camel@cybertec.at>
	<CAFCRh-_k_kFRw6FWnmQdo4NEk9ufOaC+80ithjYESXk16ZMhKg@mail.gmail.com>

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





view thread (5+ messages)  latest in thread

Message-ID: <1183347.1665758109@sss.pgh.pa.us>
Permalink:  ../1183347.1665758109@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1183347.1665758109@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ddevienne@gmail.com, laurenz.albe@cybertec.at
  Subject: Re: [libpq] OIDs of extension types? Of custom types?
  In-Reply-To: <1183347.1665758109@sss.pgh.pa.us>
  References: <CAFCRh-85tjcuHViBFtn8p53-URXrgJRqs3XdKx6igHqbZed0Gg@mail.gmail.com> <e413a7ce097b9f3beb015e42dfcb6f0d9d8eccea.camel@cybertec.at> <CAFCRh-_k_kFRw6FWnmQdo4NEk9ufOaC+80ithjYESXk16ZMhKg@mail.gmail.com> <1183347.1665758109@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox