Skip to content

Commit 896a0c4

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 4ffd3fe commit 896a0c4

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
@@ -3658,6 +3658,13 @@ PQconnectPoll(PGconn *conn)
36583658
/* We can release the address list now. */
36593659
release_conn_addrinfo(conn);
36603660

3661+
/*
3662+
* Contents of conn->errorMessage are no longer interesting
3663+
* (and it seems some clients expect it to be empty after a
3664+
* successful connection).
3665+
*/
3666+
resetPQExpBuffer(&conn->errorMessage);
3667+
36613668
/* We are open for business! */
36623669
conn->status = CONNECTION_OK;
36633670
return PGRES_POLLING_OK;

0 commit comments

Comments
 (0)