X-Git-Url: https://ruin.nu/git/?p=ND.git;a=blobdiff_plain;f=DB.pm;h=522d1ff634570ede6d32d3b8b16ad289c6e50d2b;hp=53db830c0f30b2f38012dee396b48e40f54b4880;hb=HEAD;hpb=b2d8b311939cec8d428cdeee57bdb7c83d837d92 diff --git a/DB.pm b/DB.pm index 53db830..522d1ff 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}); + 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;