pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feed From: root <andrea@ssto-dtcb.interbusiness.it>
To: pgsql-interfaces@postgresql.org
Subject: lo_read error ???
Date: Thu, 20 May 1999 17:47:58 +0200
Message-ID: <37442EAE.3D4A35C2@ssto-dtcb.interbusiness.it> (raw )
Hi to all,
I'm trying to use large objects this way:
-----------------------
#!/usr/bin/perl
$ENV{'PGDATESTYLE'} = "European";
use CGI;
use Pg;
$base = new CGI;
$fax = $base->url_param('fax');
$page = $base->url_param('page');
$conn = Pg::connectdb("dbname=www host=localhost");
$select = $conn->exec("SELECT faxpage FROM faxric where codfax='$fax'");
$faxpage = $select->fetchrow();
$faxpage_fd = $conn->lo_open($faxpage, PGRES_INV_READ);
if ($faxpage_fd < 0) {
print $base->header('text/plain'),
"Errore aprendo file su db";
exit;
}
print $base->header(-type=>'image/gif');
while(($ret = $conn->lo_read($faxpage_fd, $buf, 1024)) >0 ) {
print "$buf";
}
$ret = $conn->lo_close($faxpage_fd);
------------------------
and I get only an icon, but not the image
so I modified the script ...
------------------------
#!/usr/bin/perl
$ENV{'PGDATESTYLE'} = "European";
use CGI;
use Pg;
$base = new CGI;
$fax = $base->url_param('fax');
$page = $base->url_param('page');
$conn = Pg::connectdb("dbname=www host=localhost");
$select = $conn->exec("SELECT faxpage FROM faxric where codfax='$fax'");
$faxpage = $select->fetchrow();
$faxpage_fd = $conn->lo_open($faxpage, PGRES_INV_READ);
if ($faxpage_fd < 0) {
print $base->header('text/plain'),
"Errore aprendo file su db";
exit;
}
print $base->header(-type=>'text/plain');
while(($ret = $conn->lo_read($faxpage_fd, $buf, 1024)) >0 ) {
$test = length $buf;
print "$ret -- $test\n";
}
$ret = $conn->lo_close($faxpage_fd);
------------------------
and I get this output:
1024 -- 11
1024 -- 179
1024 -- 172
1024 -- 187
1024 -- 120
1024 -- 232
1024 -- 182
1024 -- 98
1024 -- 15
1024 -- 129
1024 -- 241
1024 -- 315
1024 -- 221
1024 -- 1002
1024 -- 13
190 -- 110
------------------------
why $buf do not contain all characters that lo_read() return ???
system is Linux RedHat 6.0, whit Postgres 6.4.2
(I've also tryed to compile it myself, but nothing change)
large objects are gif images
------------------------
Many tanks in advance to all.
Andrea Partinico
andrea@ssto-dtcb.interbusiness.it
view thread (3+ messages) latest in thread
Message-ID: <37442EAE.3D4A35C2@ssto-dtcb.interbusiness.it>
Permalink: ../37442EAE.3D4A35C2@ssto-dtcb.interbusiness.it/
Also on: postgresql.org/message-id/37442EAE.3D4A35C2@ssto-dtcb.interbusiness.it
copy link · copy postgr.es
reply Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: andrea@ssto-dtcb.interbusiness.it
Subject: Re: lo_read error ???
In-Reply-To: <37442EAE.3D4A35C2@ssto-dtcb.interbusiness.it>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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