Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ojLmO-00047s-84 for pgsql-general@arkaria.postgresql.org; Fri, 14 Oct 2022 14:35:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ojLmN-0004i0-5X for pgsql-general@arkaria.postgresql.org; Fri, 14 Oct 2022 14:35:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ojLmM-0004hr-RS for pgsql-general@lists.postgresql.org; Fri, 14 Oct 2022 14:35:14 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ojLmK-0001Ee-9o for pgsql-general@postgresql.org; Fri, 14 Oct 2022 14:35:13 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 29EEZ9Dd1183348; Fri, 14 Oct 2022 10:35:09 -0400 From: Tom Lane To: Dominique Devienne cc: Laurenz Albe , pgsql-general@postgresql.org Subject: Re: [libpq] OIDs of extension types? Of custom types? In-reply-to: References: Comments: In-reply-to Dominique Devienne message dated "Fri, 14 Oct 2022 15:42:13 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1183346.1665758109.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 14 Oct 2022 10:35:09 -0400 Message-ID: <1183347.1665758109@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Dominique Devienne writes: > On Fri, Oct 14, 2022 at 2:31 PM Laurenz Albe = 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