Subject: | Strange things with transactions and BLOBS. |
Hello. Here list of my software:
FreeBSD 5.1-RELEASE;
Perl/v5.8.6;
postgresql-7.3.4_1;
p5-DBI-1.48;
p5-DBD-Pg-1.43;
I try to export (open doesn't work too) BLOB from my database. I wrote
use DBI;
use DBD::Pg;
$dbh = DBI->connect("dbi:Pg:dbname=market", "pgsql", "", {AutoCommit => 0});
$ret = $dbh->func(886829, "/tmp/temporary_file", 'lo_export');
and got
ERROR: lo_lseek: invalid large obj descriptor (0)
in my postgres log.
Then i tried to write
use DBI;
use DBD::Pg;
$dbh = DBI->connect("dbi:Pg:dbname=market", "pgsql", "", {AutoCommit => 1});
$dbh->begin_work;
$ret = $dbh->func(886829, "/tmp/temporary_file", 'lo_export');
with the same result.
Several hours of experiments and I found that lo_creat works. So if I wrote
use DBI;
use DBD::Pg;
$dbh = DBI->connect("dbi:Pg:dbname=market", "pgsql", "", {AutoCommit => 0});
$dbh->func($dbh->{pg_INV_READ}, 'lo_creat');
$ret = $dbh->func(886829, "/tmp/temporary_file", 'lo_export');
i got my BLOB.
I read sources and find, that 'lo_create' begins transaction, and other functions not. Is there a bug or there is some other ways to begin transaction with 'lo_open' or 'lo_export'?