X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=DB.pm;h=522d1ff634570ede6d32d3b8b16ad289c6e50d2b;hb=1c26c582d691615ce061bf1327225733619740ab;hp=76cb9dd7773390112df42fabc26f7b52573afc49;hpb=8fe7db805251b8b4bc2f1558e8a7216c63892a33;p=ND.git diff --git a/DB.pm b/DB.pm index 76cb9dd..522d1ff 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;