X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;ds=sidebyside;f=DB.pm;h=0f87ee162cc7b8bbb838cfb81f17209e2ae7fcce;hb=f2a8fe893c12b768d32f0ddfd5f975ee2db6799d;hp=76cb9dd7773390112df42fabc26f7b52573afc49;hpb=8fe7db805251b8b4bc2f1558e8a7216c63892a33;p=ND.git diff --git a/DB.pm b/DB.pm index 76cb9dd..0f87ee1 100644 --- a/DB.pm +++ b/DB.pm @@ -11,11 +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}); + 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}); - $dbh->rollback if $dbh->{Executed} || !$dbh->{AutoCommit}; + #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;