From: | root <andrea(at)ssto-dtcb(dot)interbusiness(dot)it> |
---|---|
To: | pgsql-interfaces(at)postgresql(dot)org |
Subject: | lo_read error ??? |
Date: | 1999-05-20 15:47:58 |
Message-ID: | 37442EAE.3D4A35C2@ssto-dtcb.interbusiness.it |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
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(at)ssto-dtcb(dot)interbusiness(dot)it
From | Date | Subject | |
---|---|---|---|
Next Message | root | 1999-05-20 15:55:45 | lo_read error ??? |
Previous Message | Thomas Lockhart | 1999-05-20 15:12:15 | Re: [INTERFACES] JDBC from RPM? |