X-Git-Url: https://ruin.nu/git/?p=ND.git;a=blobdiff_plain;f=DB.pm;h=0f87ee162cc7b8bbb838cfb81f17209e2ae7fcce;hp=102ae7fa686c5f96ec686b0858d212d5b42ee216;hb=6987c1cc86ec91f7d3bf7d46b8745e89d31a5772;hpb=143528bffc63de7c3c3edd5ccdeec04b6871b452 diff --git a/DB.pm b/DB.pm index 102ae7f..0f87ee1 100644 --- a/DB.pm +++ b/DB.pm @@ -11,15 +11,15 @@ our @EXPORT = qw/DB/; sub DB { #Use domain sockets by default - my $dbh = DBI->connect_cached("dbi:Pg:dbname=ndawn", "ndawn", "", {AutoCommit => 1, RaiseError => 1, pg_enable_utf8 => 1}); + my $dbh = DBI->connect_cached("dbi:Pg:dbname=ndawn", "ndawn", "", {AutoCommit => 0, RaiseError => 1, PrintError => 0, pg_enable_utf8 => 1}); + #Easy to also use /etc/postgresql/pg_services.conf - #my $dbh = DBI->connect_cached("dbi:Pg:service=ndawn","", "", {AutoCommit => 1}); - { - no warnings; - local $dbh->{Warn} = 0; - $dbh->do('ABORT; RESET ALL; SET SESSION AUTHORIZATION DEFAULT; DEALLOCATE ALL'); - } + #my $dbh = DBI->connect_cached("dbi:Pg:service=ndawn","", "", {AutoCommit => 0, RaiseError => 1, pg_enable_utf8 => 1}); + $dbh->rollback; + #Need to set autocommit after, to be able to rollback old incomplete transactions. + $dbh->{AutoCommit} = 1; return $dbh; -}; +} + 1;