Large objects error - expected a 'V' from the backend - Mailing list pgsql-hackers

From Chris Bitmead
Subject Large objects error - expected a 'V' from the backend
Date
Msg-id 36FF5CC4.E1917CDB@bigfoot.com
Whole thread Raw
List pgsql-hackers
Hi all,

I'm using postgres 6.3.2 as built by RedHat 5.2.

Every time one of my programs tries to read the _2nd_ large object it
gets an error. Well actually, closing the descriptor on the 1st large
object fails as does retrieving the 2nd large object. The error is....

PQfn: expected a 'V' from the backend. Got 'N' instead

I have got a code extract below. It is simply a perl program using
Pg-0.91 that opens the database and tries to read two large objects
given on the command line.

What is the best bet for getting around this? Is upgrading to a later
version of postgres likely to help? Has anyone seen this before?

The large objects I'm using aren't very large. Only a few hundred bytes.

Are large objects well supported? Are they considered very stable to
use?

Here is the code....

package techmod;
require Exporter;

use DBI;
use Pg;

sub pgdbconnect
{       $pgdbh ||= Pg::connectdb("dbname=httpd");       die unless $pgdbh;       $pgdbh->trace(STDOUT);       return
$pgdbh;
}


sub getlarge
{   my ($name,$lobjId)=@_;   my $buf;   my $mode = PGRES_INV_READ;   if (0 <= ($lobj_fd = $pgdbh->lo_open($lobjId,
$mode)))      {       print "open\n";       while (0 < ($nbytes = $pgdbh->lo_read($lobj_fd, $b, 100000)))           {
       $buf = $buf . $b;           }       if ($nbytes < 0)               { print "read fail\n", $pgdbh->errorMessage;
}      if ($pgdbh->lo_close($lobj_fd) < 0)               { print "close fail\n", $pgdbh->errorMessage; }       }
else      {               print "notopen $lobjId\n", $pgdbh->errorMessage;       }   return $buf;
 
}

#!/usr/bin/perl
use techmod;
techmod->pgdbconnect();
$lobjId=$ARGV[0];
print techmod->getlarge($lobjId);
print techmod->getlarge($ARGV[1]);

Here is an extract from the trace.

To backend> F 
To backend (4#)> 954
To backend (4#)> 2
To backend (4#)> 4
To backend (4#)> 0
To backend (4#)> 4
To backend (4#)> 100000
>From backend> V
>From backend> G
>From backend (#4)> 33
>From backend (33)> This is some data stored in a large object.

>From backend> 0
To backend> F 
To backend (4#)> 954
To backend (4#)> 2
To backend (4#)> 4
To backend (4#)> 0
To backend (4#)> 4
To backend (4#)> 100000
>From backend> V
>From backend> G
>From backend (#4)> 0
>From backend (0)> 
>From backend> 0
To backend> F 
To backend (4#)> 953
To backend (4#)> 1
To backend (4#)> 4
To backend (4#)> 0
>From backend> N
close fail
PQfn: expected a 'V' from the backend. Got 'N' insteadThis is some data
stored in a large object
To backend> F 
To backend (4#)> 952
To backend (4#)> 2
To backend (4#)> 4
To backend (4#)> 21008
To backend (4#)> 4
To backend (4#)> 262144
>From backend> N
notopen 21008
PQfn: expected a 'V' from the backend. Got 'N' instead

-- 
Chris Bitmead
http://www.bigfoot.com/~chris.bitmead
mailto:chris.bitmead@bigfoot.com


pgsql-hackers by date:

Previous
From: Dmitry Samersoff
Date:
Subject: incorrect const usage
Next
From: Peter Galbavy
Date:
Subject: Re: [HACKERS] signal weirdness