libpq lo_open errors when first action in connection

From: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: libpq lo_open errors when first action in connection
Date: 2005-05-13 02:39:25
Message-ID: 847778b18516dd1c0c001a6a2938b73e@biglumber.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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.

Here is a small sample code in Perl that demonstrates:

#!perl

use DBI; use strict; use warnings;

my $dbh = DBI->connect($ENV{DBI_DSN}, $ENV{DBI_USER}, '',
{AutoCommit=>0, RaiseError=>1});

# If the below line is commented out, this test will fail:
$dbh->do("SELECT 123");

my $W = $dbh->{pg_INV_WRITE};
my $object = $dbh->func($W, 'lo_creat');
my $handle = $dbh->func($object, $W, 'lo_open');
printf "This test %s!\n", defined $handle ? "worked" : "did not work";
$dbh->disconnect;

Thanks,
- --
Greg Sabino Mullane greg(at)turnstep(dot)com
PGP Key: 0x14964AC8 200505121009
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iD8DBQFCg2nKvJuQZxSWSsgRAoqxAJ4+jdYo+BrxHb0smXzU2FzOzPODHwCg/hZB
oHcq8t479a5OKaURCl8Kl5U=
=rmbL
-----END PGP SIGNATURE-----

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2005-05-13 03:09:53 Re: PostgreSQL running out of file handles
Previous Message Robert Treat 2005-05-13 02:06:39 Re: Views, views, views: Summary of Arguments