Received: from host28.ssto-dtcb.interbusiness.it ([194.243.126.28]) by hub.org (8.9.3/8.9.3) with ESMTP id LAA77542 for ; Thu, 20 May 1999 11:53:29 -0400 (EDT) (envelope-from andrea@ssto-dtcb.interbusiness.it) Received: from ssto-dtcb.interbusiness.it ([10.76.10.43]) by host28.ssto-dtcb.interbusiness.it (8.8.3/8.8.3) with ESMTP id RAA03198 for ; Thu, 20 May 1999 17:52:56 +0200 Sender: root@host28.ssto-dtcb.interbusiness.it Message-ID: <37442EAE.3D4A35C2@ssto-dtcb.interbusiness.it> Date: Thu, 20 May 1999 17:47:58 +0200 From: root Reply-To: andrea@ssto-dtcb.interbusiness Organization: Telecom Italia X-Mailer: Mozilla 4.51 [en] (X11; I; Linux 2.2.5-15 i686) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-interfaces@postgresql.org Subject: lo_read error ??? Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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