pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Perl 5 Interface on 6.5 and lo_creat/lo_open problem
3+ messages / 2 participants
[nested] [flat]

* Perl 5 Interface on 6.5 and lo_creat/lo_open problem
@ 1999-06-23 23:31 Kristofer Munn <kmunn@munn.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Kristofer Munn @ 1999-06-23 23:31 UTC (permalink / raw)
  To: pgsql-interfaces

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 






^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Perl 5 Interface on 6.5 and lo_creat/lo_open problem
@ 1999-06-30 21:17 Matt Magoffin <mmagoffi@borders.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Matt Magoffin @ 1999-06-30 21:17 UTC (permalink / raw)
  To: kmunn@munn.com; +Cc: pgsql-interfaces

I am having the same problem with 6.5 on my LinuxPPC R5 (i.e. RH 6) box, 
that is I can create and delete large objects, but can't open them to read
the contents. Did you ever find a solution for this problem?

-- M@

   < <  <   senor mateo
            borders.com jefe interactivo
            (0.11) 734.477.1130

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Perl 5 Interface on 6.5 and lo_creat/lo_open problem
@ 1999-06-30 22:08 Kristofer Munn <kmunn@munn.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Kristofer Munn @ 1999-06-30 22:08 UTC (permalink / raw)
  To: Matt Magoffin <mmagoffi@borders.com>; +Cc: pgsql-interfaces

I was informed that as of 6.5 the requirement for wrapping large object
actions in a transaction is required.  I put a "BEGIN TRANSACTION" and
"COMMIT TRANSACTION" around my function which reads and writes my LOs and
everything worked like a charm.

- K

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




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~1999-06-30 22:08 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-06-23 23:31 Perl 5 Interface on 6.5 and lo_creat/lo_open problem Kristofer Munn <kmunn@munn.com>
1999-06-30 21:17 Re: Perl 5 Interface on 6.5 and lo_creat/lo_open problem Matt Magoffin <mmagoffi@borders.com>
1999-06-30 22:08 Re: Perl 5 Interface on 6.5 and lo_creat/lo_open problem Kristofer Munn <kmunn@munn.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox