Re: Binary params in libpq - Mailing list pgsql-general

From Craig Ringer
Subject Re: Binary params in libpq
Date
Msg-id 4D6AFCCC.1020603@postnewspapers.com.au
Whole thread Raw
In response to Re: Binary params in libpq  (Merlin Moncure <mmoncure@gmail.com>)
Responses Re: Binary params in libpq  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-general
On 28/02/2011 7:48 AM, Merlin Moncure wrote:

>> How stable is the binary representation for the PostgreSQL types? We
>> may just pass bytea data in binary format and pass everything else as
>> text parameters, or pass different types too as binary, if performace
>> would benefit. Did binary format ever changed in the past (at least
>> since the introduction of the V3 protocol)?

AFAIK, the `timestamp' type moved from a floating-point to an integer
representation internally, which would've affected the binary protocol
representation. That was even a compile-time config option, so it could
be different between two different Pg installs with the same version.

>> Is such binary
>> representation more likely to change in the future respect to the
>> textual one, in a way that forward/backward compatibility between
>> server and client would be compromised?

History to date suggests that the binary representation certainly does
change. Then again, so has the textual one at least in the case of bytea.

> The binary representations of types are mostly stable.  On average of
> about one per release you might see a wire format change...it doesn't
> happen that often but you have to be prepared to deal with it.

Refusing to talk to databases newer than the version the driver was
tested with *might* be a good idea, just to be safe, though some kind of
user override would be needed. At least warn about it when you see a new
and unfamiliar Pg version. You can't always *tell* that a new
representation is incompatible, as the text-format bytea affair
demonstrated.

--
Craig Ringer

Tech-related writing at http://soapyfrogs.blogspot.com/

pgsql-general by date:

Previous
From: Michael Harris
Date:
Subject: ERROR: missing chunk number 0 for toast value 382548694 in pg_toast_847386
Next
From: Craig Ringer
Date:
Subject: Re: ERROR: invalid byte sequence for encoding "UTF8": 0xc35c