Re: Binary params in libpq

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Binary params in libpq
Date: 2011-02-28 01:39:24
Message-ID: 4D6AFCCC.1020603@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2011-02-28 03:14:13 Re: ERROR: invalid byte sequence for encoding "UTF8": 0xc35c
Previous Message John R Pierce 2011-02-28 00:34:42 Re: PG on two nodes with shared disk ocfs2 & drbd