Re: Stuff for 2.4.1

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>
Cc: psycopg(at)postgresql(dot)org
Subject: Re: Stuff for 2.4.1
Date: 2011-03-27 18:37:52
Message-ID: AANLkTinJMKF1xBw46TSB4V=HtX84_1BpgUi+EkkGt0Hb@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On Sun, Mar 27, 2011 at 6:40 PM, Karsten Hilbert
<Karsten(dot)Hilbert(at)gmx(dot)net> wrote:
>> [...] psycopg2's own bytea output parsing [...]
>
> I think it's conceptually better to endure the extra
> code/query(s) needed to determine at .connect() time whether
> "set bytea_output to ..." is needed or not.

This would imply an extra roundtrip to the server per connection:
we've already had enough people complaining we do too many of them
(they used to be 3, now there is a single one and I would have dropped
it as well, but there's not been consensus on this point).

I think we've already discussed about querying the server and we
agreed not to do this.

> After all this is only going to be relevant within the
> window where pre-9 libpq's try to connect to 9+ servers.
>
> For psycopg2's compiled against 9+ libpq's this would IFDEF
> out to a noop, essentially.

Unfortunately there's no reliable way to do this. The problem is in
the runtime library, not in the one used at compile time, and there is
no way to know the runtime version - not for libraries before 9.0.

Even if I could have the option to write "if version < 9 then use our
parser, else use libpq's", we should then track who allocated the
memory returned by the function to correctly free it (PQunescapeBytea
allocates its own memory to be released with PQfreemem, and there is
no "PQmalloc" exposed we could use to make my buffer appear like a
libpq's one): so the result would have amounted to such an ugly and
convoluted code that I simply prefer to have my own parser.

-- Daniele

In response to

Responses

Browse psycopg by date

  From Date Subject
Next Message Karsten Hilbert 2011-03-27 18:51:25 Re: Stuff for 2.4.1
Previous Message Daniele Varrazzo 2011-03-27 18:25:20 Re: Stuff for 2.4.1