From: | Ken Causey <ken(at)premiernet(dot)net> |
---|---|
To: | pgsql-interfaces(at)postgresql(dot)org |
Subject: | Problem with Large Object Interface of pgsql_perl5 |
Date: | 2000-03-31 16:18:55 |
Message-ID: | 3.0.1.32.20000331101855.016db34c@premiernet.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-interfaces |
I'm using PostgreSQL 6.5.3, Perl 5.005_03, and pgsql_perl5 1.8.0 on
Linux (intel).
Running this program:
#!/usr/bin/perl
use strict;
package Main;
use Pg;
my $db_name='excised';
my $db_user='excised';
my $db_passwd='excised';
# Connect to the database server
my $dbconn = Pg::connectdb("dbname=$db_name user=$db_user
password=$db_passwd");
if($dbconn->status ne PGRES_CONNECTION_OK){
# We failed to get a connection, exit with error
my $error=$dbconn->errorMessage;
print "Error on connection: $error\n";
exit;
}
print "Database connection opened\n";
my $newoid = $dbconn->lo_creat(PGRES_INV_WRITE|PGRES_INV_READ);
if($newoid == PGRES_InvalidOid){
my $error = $dbconn->errorMessage;
print "Error on lo_creat: $error\n";
exit;
}
print "LO created\n";
my $fd = $dbconn->lo_open($newoid,PGRES_INV_WRITE);
if($fd == -1){
# Error on opening new oid
my $error = $dbconn->errorMessage;
print "Error on lo_open (oid = $newoid): $error\n";
# Try to unlink the oid
$dbconn->lo_unlink($newoid);
exit;
}
print "LO opened\n";
my $content = 'This is a test of the emergency broadcasting system, in the
event of a real emergency...';
my $numbytes=$dbconn->lo_write($fd,$content,length($content));
if($numbytes != length($content)){
my $rightnum=length($content);
my $error = $dbconn->errorMessage;
print "Error on lo_write ($numbytes != $rightnum): $error\n";
# Try to unlink the oid
$dbconn->lo_close($fd);
$dbconn->lo_unlink($newoid);
exit;
}
print "LO written\n";
$dbconn->lo_close($fd);
$dbconn->lo_unlink($newoid);
I get this output:
Database connection opened
LO created
Error on lo_open (oid = 46401): ERROR: lo_lseek: invalid large obj
descriptor (0)
Can anyone tell me what I'm doing wrong?
All help is greatly appreciated.
Ken Causey
PremierNET, Inc.
From | Date | Subject | |
---|---|---|---|
Next Message | Guido Goldstein | 2000-03-31 17:16:37 | Re: How do I change the default editor in psql |
Previous Message | Lamar Owen | 2000-03-31 16:13:54 | Re: What is the default port for postmaster? |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2000-03-31 18:11:18 | Re: Problem with Large Object Interface of pgsql_perl5 |
Previous Message | Thomas Lockhart | 2000-03-31 15:15:33 | Re: pgAdmin v7.0.0 Released |