On Wed, Feb 11, 2004 at 09:42:00AM +0100, Bart Lateur wrote: > On Tue, 10 Feb 2004 18:10:42 -0500, Andrew Pimlott wrote: > > >Is there any way to prevent the following from warning "Issuing > >rollback() for database handle being DESTROY'd without explicit > >disconnect()."? > > > > use DBI; > > > > my $dbh = DBI->connect('dbi:Pg:dbname=...', undef, undef, > > { RaiseError => 1, AutoCommit => 0 }); > > $dbh->commit(); > > You can do an explicit disconnect(). > > In many cases, you can just do that without thinking about it, by doing > it like this: > > END { > $dbh->disconnect if $dbh; > } > > which also does its job in case of a die().
Yeap. > Without testing, I doubt that this will work satisfactorily in mod_perl > and similar setups. For mod_perl you can register a suitable callback. The warning as it's a significant satefy feature, however it can be turned off, along with various other warnings, by $dbh->{Warn} = 0, but I don't recommend that. Tim. p.s. The plan is to have a way for a driver to indicate if it's in a transaction and, for drivers that can, use that to skip the warning.