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 1i5VuI-0000SY-5e for pgsql-interfaces@arkaria.postgresql.org; Wed, 04 Sep 2019 14:05:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i5VuG-0003Rd-Q8 for pgsql-interfaces@arkaria.postgresql.org; Wed, 04 Sep 2019 14:05:08 +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 1i5VuG-0003RW-J5 for pgsql-interfaces@lists.postgresql.org; Wed, 04 Sep 2019 14:05:08 +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 1i5VuE-000560-Fn for pgsql-interfaces@lists.postgresql.org; Wed, 04 Sep 2019 14:05:08 +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 x84E53kx023809; Wed, 4 Sep 2019 10:05:03 -0400 From: Tom Lane To: Malcolm Matalka cc: pgsql-interfaces@lists.postgresql.org Subject: Re: Object IDs in Parse message In-reply-to: <86a7bk33y4.fsf@gmail.com> References: <86o9019mjr.fsf@gmail.com> <32018.1567542279@sss.pgh.pa.us> <86a7bk33y4.fsf@gmail.com> Comments: In-reply-to Malcolm Matalka message dated "Wed, 04 Sep 2019 09:39:47 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <23807.1567605903.1@sss.pgh.pa.us> Date: Wed, 04 Sep 2019 10:05:03 -0400 Message-ID: <23808.1567605903@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Malcolm Matalka writes: > Tom Lane writes: >> 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 > Ok, it wasn't clear to me if and when I should pass this data in. I > couldn't find any documentation for this translating to performance > improvement, or addressing any possible errors due to ambiguity in > types. In general, should an interface no pass that information in on a > Parse? Is there a reason to do it? You should only pass type OIDs if you know for sure what they should be, which an interface library passing on a query generated elsewhere will not know --- unless it provides an API for the caller to tell it. The convention that seems to have evolved in places that lack such APIs is to pass zeroes, and instruct human authors of queries that if the server doesn't resolve the types of parameter placeholders the way they want, force it with a cast in the text of the query, eg "$1::int8". Otherwise you need to add some out-of-band notation for specifying the types, plus a way to resolve that notation into numeric OIDs, and it's all a giant pain in the rear for all concerned. Passing zeroes is more workable than you might think, since the server can correctly guess the type of a placeholder in a lot of cases. However, it might be best to avoid it if you intend to pass parameter values in binary, since that will lose a lot of the safety margin for detecting wrong guesses. regards, tom lane