Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i5FM7-0001Af-JB for pgsql-interfaces@arkaria.postgresql.org; Tue, 03 Sep 2019 20:24:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i5FM5-00059W-Qn for pgsql-interfaces@arkaria.postgresql.org; Tue, 03 Sep 2019 20:24:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i5FM5-000547-I4 for pgsql-interfaces@lists.postgresql.org; Tue, 03 Sep 2019 20:24:45 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i5FM3-0001vO-3u for pgsql-interfaces@lists.postgresql.org; Tue, 03 Sep 2019 20:24:45 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x83KOdOI032019; Tue, 3 Sep 2019 16:24:39 -0400 From: Tom Lane To: Malcolm Matalka cc: pgsql-interfaces@lists.postgresql.org Subject: Re: Object IDs in Parse message In-reply-to: <86o9019mjr.fsf@gmail.com> References: <86o9019mjr.fsf@gmail.com> Comments: In-reply-to Malcolm Matalka message dated "Tue, 03 Sep 2019 22:01:28 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <32017.1567542279.1@sss.pgh.pa.us> Date: Tue, 03 Sep 2019 16:24:39 -0400 Message-ID: <32018.1567542279@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Malcolm Matalka 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