Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/bin/common/pgsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,19 @@ pgsql_retry_open_connection(PGSQL *pgsql)
*
* PQping does not check authentication, so we might still fail
* to connect to the server.
*
* The previous attempt (the initial one made by
* pgsql_open_connection, or a failed previous iteration of this
* loop) left a PGconn behind: release it before we overwrite the
* pointer, otherwise we leak the client-side PGconn on
* every retry.
*/
if (pgsql->connection != NULL)
{
PQfinish(pgsql->connection);
pgsql->connection = NULL;
}

pgsql->connection = PQconnectdb(pgsql->connectionString);

if (PQstatus(pgsql->connection) == CONNECTION_OK)
Expand Down