1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-19 15:49:24 +03:00

libpq error message refactoring, part 2

This applies the new APIs to the code.

Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: https://www.postgresql.org/message-id/flat/7c0232ef-7b44-68db-599d-b327d0640a77@enterprisedb.com
This commit is contained in:
Peter Eisentraut
2022-11-15 11:50:04 +01:00
parent 0873b2d354
commit a9e9a9f32b
12 changed files with 463 additions and 774 deletions

View File

@@ -570,8 +570,7 @@ pqReadData(PGconn *conn)
if (conn->sock == PGINVALID_SOCKET)
{
appendPQExpBufferStr(&conn->errorMessage,
libpq_gettext("connection not open\n"));
libpq_append_conn_error(conn, "connection not open");
return -1;
}
@@ -749,10 +748,9 @@ retry4:
* means the connection has been closed. Cope.
*/
definitelyEOF:
appendPQExpBufferStr(&conn->errorMessage,
libpq_gettext("server closed the connection unexpectedly\n"
"\tThis probably means the server terminated abnormally\n"
"\tbefore or while processing the request.\n"));
libpq_append_conn_error(conn, "server closed the connection unexpectedly\n"
"\tThis probably means the server terminated abnormally\n"
"\tbefore or while processing the request.");
/* Come here if lower-level code already set a suitable errorMessage */
definitelyFailed:
@@ -1002,8 +1000,7 @@ pqWaitTimed(int forRead, int forWrite, PGconn *conn, time_t finish_time)
if (result == 0)
{
appendPQExpBufferStr(&conn->errorMessage,
libpq_gettext("timeout expired\n"));
libpq_append_conn_error(conn, "timeout expired");
return 1;
}
@@ -1047,8 +1044,7 @@ pqSocketCheck(PGconn *conn, int forRead, int forWrite, time_t end_time)
return -1;
if (conn->sock == PGINVALID_SOCKET)
{
appendPQExpBufferStr(&conn->errorMessage,
libpq_gettext("invalid socket\n"));
libpq_append_conn_error(conn, "invalid socket");
return -1;
}
@@ -1070,9 +1066,7 @@ pqSocketCheck(PGconn *conn, int forRead, int forWrite, time_t end_time)
{
char sebuf[PG_STRERROR_R_BUFLEN];
appendPQExpBuffer(&conn->errorMessage,
libpq_gettext("%s() failed: %s\n"),
"select",
libpq_append_conn_error(conn, "%s() failed: %s", "select",
SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
}