lo_read error ???
От | root |
---|---|
Тема | lo_read error ??? |
Дата | |
Msg-id | 37442EAE.3D4A35C2@ssto-dtcb.interbusiness.it обсуждение исходный текст |
Список | 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@ssto-dtcb.interbusiness.it
В списке pgsql-interfaces по дате отправления: