pg_dump: Move connection-setup code to a separate function.
pg_dump: Move connection-setup code to a separate function.

Parallel dump will need to repeat these steps for each new connection,
so it's better to have this logic in its own function.

Extracted (with some changes) from a much larger patch
by Joachim Wieland.

postmind-net/postgres-xl,techdragon/Postgres-XL,xinzweb/gpdb,ovr/postgres-xl,Postgres-XL/Postgres-XL,greenplum-db/gpdb,greenplum-db/gpdb,arcivanov/postgres-xl,oberstet/postgres-xl,xinzweb/gpdb,tpostgres-projects/tPostgres,snaga/postgres-xl,oberstet/postgres-xl,arcivanov/postgres-xl,greenplum-db/gpdb,arcivanov/postgres-xl,adam8157/gpdb,ashwinstar/gpdb,greenplum-db/gpdb,ashwinstar/gpdb,adam8157/gpdb,postmind-net/postgres-xl,arcivanov/postgres-xl,arcivanov/postgres-xl,greenplum-db/gpdb,50wu/gpdb,snaga/postgres-xl,lisakowen/gpdb,yazun/postgres-xl,ashwinstar/gpdb,adam8157/gpdb,jmcatamney/gpdb,postmind-net/postgres-xl,tpostgres-projects/tPostgres,jmcatamney/gpdb,techdragon/Postgres-XL,pavanvd/postgres-xl,adam8157/gpdb,oberstet/postgres-xl,xinzweb/gpdb,kmjungersen/PostgresXL,lisakowen/gpdb,lisakowen/gpdb,50wu/gpdb,50wu/gpdb,50wu/gpdb,xinzweb/gpdb,Postgres-XL/Postgres-XL,techdragon/Postgres-XL,xinzweb/gpdb,adam8157/gpdb,pavanvd/postgres-xl,zeroae/postgres-xl,ashwinstar/gpdb,50wu/gpdb,kmjungersen/PostgresXL,ashwinstar/gpdb,lisakowen/gpdb,lisakowen/gpdb,ovr/postgres-xl,adam8157/gpdb,greenplum-db/gpdb,lisakowen/gpdb,pavanvd/postgres-xl,tpostgres-projects/tPostgres,snaga/postgres-xl,jmcatamney/gpdb,postmind-net/postgres-xl,yazun/postgres-xl,yazun/postgres-xl,50wu/gpdb,techdragon/Postgres-XL,greenplum-db/gpdb,xinzweb/gpdb,zeroae/postgres-xl,jmcatamney/gpdb,50wu/gpdb,tpostgres-projects/tPostgres,ovr/postgres-xl,ashwinstar/gpdb,kmjungersen/PostgresXL,zeroae/postgres-xl,yazun/postgres-xl,snaga/postgres-xl,Postgres-XL/Postgres-XL,jmcatamney/gpdb,adam8157/gpdb,zeroae/postgres-xl,tpostgres-projects/tPostgres,jmcatamney/gpdb,greenplum-db/gpdb,pavanvd/postgres-xl,kmjungersen/PostgresXL,postmind-net/postgres-xl,techdragon/Postgres-XL,oberstet/postgres-xl,lisakowen/gpdb,ovr/postgres-xl,jmcatamney/gpdb,xinzweb/gpdb,arcivanov/postgres-xl,Postgres-XL/Postgres-XL,yazun/postgres-xl,kmjungersen/PostgresXL,pavanvd/postgres-xl,Postgres-XL/Postgres-XL,ashwinstar/gpdb,50wu/gpdb,zeroae/postgres-xl,adam8157/gpdb,jmcatamney/gpdb,xinzweb/gpdb,snaga/postgres-xl,oberstet/postgres-xl,lisakowen/gpdb,ashwinstar/gpdb,ovr/postgres-xl