Subject: | commit method returns false |
DBD::Pg 1.40 as well as CVS as of Mar 25 2005 returns a false value in response to $dbh->commit(), but no error is available in $dbh->errstr. It should return true if the commit was sucessful, or return false and set errstr if the commit was unsucessful.
Code which uses the common idiom "$dbh->commit or die $dbh->errstr" winds up emitting the cryptic error message "Use of uninitialized value in die". A test case suitable for inclusion in t/ is attached as 08commit.t.
Reproduced on Debian sid, Perl 5.8.4-6, Pg 7.4.7-3, DBI 1.46-6. From the reports I've been getting from my users this doesn't seem to be specific to one OS or Pg version.
This is a regression from 1.32 and should be fixed for 1.41.
#!perl -w
use Test::More;
use DBI;
use strict;
$| = 1;
if (defined $ENV{DBI_DSN}) {
plan tests => 2;
} else {
plan skip_all => 'Cannot run test unless DBI_DSN is defined. See the REA
DME file';
}
my $dbh = DBI->connect($ENV{DBI_DSN}, $ENV{DBI_USER}, $ENV{DBI_PASS},
{RaiseError => 1, PrintError => 0, AutoCommit => 0});
ok( defined $dbh, "Connect to database for commit test");
ok( $dbh->commit, '$dbh->commit returns true')
or diag($dbh->errstr);
$dbh->disconnect();