From the docs:
According to the DBI specification the default for AutoCommit is a true value. In this mode, any change to the database becomes valid immediately. Any
BEGIN,COMMITorROLLBACKstatements will be rejected. DBD::Pg implements AutoCommit by issuing aBEGINstatement immediately before executing a statement, and aCOMMITafterwards.
My test script:
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
my $dbh = DBI->connect("dbi:Pg:dbname=test");
print "AutoCommit = $dbh->{AutoCommit}\n";
$dbh->do('INSERT INTO foo(x) VALUES (1)');
Script output:
AutoCommit = 1
And my logs (with log_statement = 'all'):
2012-03-05 20:21:02 CST rootLOG: statement: INSERT INTO foo(x) VALUES (1)
(forgive me for testing my script as root!)
Where’s the BEGIN and COMMIT I was promised by the DBD::Pg docs?
I have concluded, through my own testing, that this is a bug in the DBD::Pg documentation. Accordingly, I have filed Bug #82356 with CPAN, which was resolved Feb 8, 2013.