Perl 5 Interface on 6.5 and lo_creat/lo_open problem

From: Kristofer Munn <kmunn(at)munn(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Perl 5 Interface on 6.5 and lo_creat/lo_open problem
Date: 1999-06-23 22:20:16
Message-ID: Pine.LNX.4.04.9906231753260.4302-100000@dec.munn.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Is anyone else having any problems with the Perl Interface wrt Large
Objects under 6.5?

I compiled and installed 6.5 on an Intel/Linux/RedHat 6.0 machine that had
previously had 6.4.2 and imported existing data from the old database.
Perl scripts which were working under the previous version are now failing
when trying to open a newly created large object. A line appears in the
error log:

Jun 23 17:40:47 www logger: ERROR: lo_lseek: invalid large obj descriptor (0)

While the code being executed is a function call write_blob below. The
scaffolding internally tells me it is unable to open oid XXXXXX for
writing where XXXXXX is the newly "created" oid #.

sub write_blob {
my($oid, $blob) = @_;

print "write_blob($oid, '$blob');\n" if $debug;
if ($blob eq "") {
if ($oid > 0) {
$conn->lo_unlink($oid);
}
print "No blob to write\n" if $debug;
return "NULL";
}
if ($oid == 0) {
$oid = $conn->lo_creat(PGRES_INV_WRITE | PGRES_INV_READ);
if ($oid == PGRES_InvalidOid) {
print "Unable to get new oid.\n" if $debug;
return "NULL";
}
}
my($lobj_fd) = $conn->lo_open($oid, PGRES_INV_WRITE);
if ($lobj_fd == -1) {
print "Unable to open oid $oid for writing.\n" if $debug;
return "NULL";
}

if ($conn->lo_write($lobj_fd, $blob, length($blob)) == -1) {
$conn->lo_close($lobj_fd);
$conn->lo_unlink($oid);
print "Unable to write blob into open oid $oid.\n" if $debug;
return "NULL";
}
$conn->lo_close($lobj_fd);

print "write_blob successful\n" if $debug;

return $oid;
}

I reverted to 6.4.2 and the scripts worked again. Back to 6.5 - no dice.

- K

Kristofer Munn * http://www.munn.com/~kmunn/ * ICQ# 352499 * AIM: KrMunn

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 1999-06-23 23:03:53 Re: [HACKERS] money data type and conversions]
Previous Message D'Arcy J.M. Cain 1999-06-23 20:54:12 Re: [HACKERS] money data type and conversions]