Re: libpq lo_open errors when first action in connection

From: Alvaro Herrera <alvherre(at)surnet(dot)cl>
To: Greg Sabino Mullane <greg(at)turnstep(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: libpq lo_open errors when first action in connection
Date: 2005-05-13 03:16:46
Message-ID: 20050513031646.GB28148@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, May 13, 2005 at 02:39:25AM -0000, Greg Sabino Mullane wrote:

> I'm having some problems with lo_open inside of DBD::Pg (which
> uses libpq) and need help in debugging the problem. The problem
> is that a call to lo_open works perfectly, *unless* it is the
> first thing that this connection to the database has done, in
> which case it returns a -1 (which comes back to perl as undef).
> To be more specific, I need to issue a "SELECT 123;" (or anything
> else via PQexec) before the call will succeeed. All the parameters
> to lo_open look normal and identical whether PQexec has been called
> or not, and lo_creat always works just fine. It has to be PQexec*,
> a prepare alone will not do the trick.

The problem is that LO descriptors are only valid for the duration of
the transaction. So your "select 123" opens a transaction, and
autocommit = 0 makes it not close until after the function is called.
If you don't send the query first, both function calls happen in
different transactions.

I think you should make the func() method open a transaction, just like
a query does.

--
Alvaro Herrera (<alvherre[a]surnet.cl>)
La web junta la gente porque no importa que clase de mutante sexual seas,
tienes millones de posibles parejas. Pon "buscar gente que tengan sexo con
ciervos incendiándose", y el computador dirá "especifique el tipo de ciervo"
(Jason Alexander)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-05-13 03:20:35 Re: PostgreSQL running out of file handles
Previous Message Christopher Kings-Lynne 2005-05-13 03:16:35 Re: PostgreSQL running out of file handles