public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tom Lane <[email protected]>
To: Malcolm Matalka <[email protected]>
Cc: [email protected]
Subject: Re: Object IDs in Parse message
Date: Wed, 04 Sep 2019 10:05:03 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<[email protected]>
	<[email protected]>

Malcolm Matalka <[email protected]> writes:
> Tom Lane <[email protected]> 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





view thread (6+ messages)

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Object IDs in Parse message
  In-Reply-To: <[email protected]>

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

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