the connection; also restructure the libpq connection code. This patch also removes the unused variable postmasterPID and fixes a libpq structure leak that was in the testing loop.