Skip to content

Commit 138531f

Browse files
committed
Clear conn->errorMessage at successful completion of PQconnectdb().
Commits ffa2e46 and 52a1022 caused libpq's connection-establishment functions to usually leave a nonempty string in the connection's errorMessage buffer, even after a successful connection. While that was intentional on my part, more sober reflection says that it wasn't a great idea: the string would be a bit confusing. Also this broke at least one application that checked for connection success by examining the errorMessage, instead of using PQstatus() as documented. Let's clear the buffer at success exit, restoring the pre-v14 behavior. Discussion: https://postgr.es/m/4170264.1620321747@sss.pgh.pa.us
1 parent 1882d6c commit 138531f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/interfaces/libpq/fe-connect.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3654,6 +3654,13 @@ PQconnectPoll(PGconn *conn)
36543654
/* We can release the address list now. */
36553655
release_conn_addrinfo(conn);
36563656

3657+
/*
3658+
* Contents of conn->errorMessage are no longer interesting
3659+
* (and it seems some clients expect it to be empty after a
3660+
* successful connection).
3661+
*/
3662+
resetPQExpBuffer(&conn->errorMessage);
3663+
36573664
/* We are open for business! */
36583665
conn->status = CONNECTION_OK;
36593666
return PGRES_POLLING_OK;

0 commit comments

Comments
 (0)