Re: libpq lo_open errors when first action in connection - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: libpq lo_open errors when first action in connection
Date
Msg-id 20050513031646.GB28148@surnet.cl
Whole thread Raw
In response to libpq lo_open errors when first action in connection  ("Greg Sabino Mullane" <greg@turnstep.com>)
Responses Re: libpq lo_open errors when first action in connection  ("Greg Sabino Mullane" <greg@turnstep.com>)
List 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)


pgsql-hackers by date:

Previous
From: Christopher Kings-Lynne
Date:
Subject: Re: PostgreSQL running out of file handles
Next
From: Tom Lane
Date:
Subject: Re: PostgreSQL running out of file handles