From: Rogan Hamby Date: Tue, 20 Mar 2018 16:20:25 +0000 (-0400) Subject: some failover to connect directly by socket if full TCP settings aren't found X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=commitdiff_plain;h=8ac648a9a0d7bf9f2df03ec8fc952d088fe0d740 some failover to connect directly by socket if full TCP settings aren't found --- diff --git a/mig-bin/Mig.pm b/mig-bin/Mig.pm index 46aa1d1..f1b97f2 100644 --- a/mig-bin/Mig.pm +++ b/mig-bin/Mig.pm @@ -19,14 +19,20 @@ use Env qw( ); sub db_connect { - my $dbh = DBI->connect( + my $dbh; + if ($PGHOST) { + $dbh = DBI->connect( "dbi:Pg:host=$PGHOST;dbname=$PGDATABASE;port=$PGPORT" ,$PGUSER ,undef - ) || die "Unable to connect to $PGHOST:$PGPORT:$PGDATABASE:$PGUSER : $!\n"; + ) || die "Unable to connect to $PGHOST:$PGPORT:$PGDATABASE:$PGUSER : $!\n"; + } else { + $dbh = DBI->connect("dbi:Pg:dbname=$PGDATABASE", "", "") || die "Unable to connect to $PGDATABASE : $!\n"; + } $dbh->do("SET search_path TO $MIGSCHEMA, evergreen, pg_catalog, public"); return $dbh; } + sub db_disconnect { my $dbh = shift; $dbh->disconnect;