Fix redundant error messages in client tools
authorPeter Eisentraut <peter@eisentraut.org>
Sat, 7 Nov 2020 21:15:52 +0000 (22:15 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Sat, 7 Nov 2020 22:03:54 +0000 (23:03 +0100)
A few client tools duplicate error messages already provided by libpq.

Discussion: https://www.postgresql.org/message-id/flat/3e937641-88a1-e697-612e-99bba4b8e5e4%40enterprisedb.com

src/bin/pg_basebackup/streamutil.c
src/bin/pg_rewind/pg_rewind.c
src/bin/psql/startup.c

index be653ebb2d94a94f19bb6f51795718a73aa570c5..da577a7f8f4852d958b7c98368a6ab4955af974e 100644 (file)
@@ -200,8 +200,7 @@ GetConnection(void)
 
    if (PQstatus(tmpconn) != CONNECTION_OK)
    {
-       pg_log_error("could not connect to server: %s",
-                    PQerrorMessage(tmpconn));
+       pg_log_error("%s", PQerrorMessage(tmpconn));
        PQfinish(tmpconn);
        free(values);
        free(keywords);
index 421a45ef5b11c2e32c9bc1ec8d668d34c9be033d..52e3fc40e85b287a96d38ce42c3da939ac901c98 100644 (file)
@@ -282,8 +282,7 @@ main(int argc, char **argv)
        conn = PQconnectdb(connstr_source);
 
        if (PQstatus(conn) == CONNECTION_BAD)
-           pg_fatal("could not connect to server: %s",
-                    PQerrorMessage(conn));
+           pg_fatal("%s", PQerrorMessage(conn));
 
        if (showprogress)
            pg_log_info("connected to server");
index e8d35a108f3658927e0dfc1571e2d9f3b02ad22d..586fcb33661cde5d9c27ccaf591f6272e9ff68c0 100644 (file)
@@ -295,7 +295,7 @@ main(int argc, char *argv[])
 
    if (PQstatus(pset.db) == CONNECTION_BAD)
    {
-       pg_log_error("could not connect to server: %s", PQerrorMessage(pset.db));
+       pg_log_error("%s", PQerrorMessage(pset.db));
        PQfinish(pset.db);
        exit(EXIT_BADCONN);
    }