Fix redundant error messages in client tools
authorPeter Eisentraut
Sat, 7 Nov 2020 21:15:52 +0000 (22:15 +0100)
committerPeter Eisentraut
Sat, 7 Nov 2020 22:03:51 +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/libpq_fetch.c
src/bin/psql/startup.c

index c08003e7f2c75e209bef60f7dd4fa4d961c2221e..ad282ceb5dd9eb640992d55c084099c7ac01fbeb 100644 (file)
@@ -199,8 +199,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 bf4dfc23b963dde43cf4d4d806b3a985fd2aa643..f4706e9a95f44cdd7d85d2d315f86f2ad11b8c83 100644 (file)
@@ -47,8 +47,7 @@ libpqConnect(const char *connstr)
 
    conn = PQconnectdb(connstr);
    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 3302bd4dd327cc1e9a69e60e92ee27245acef752..392b96eb862da4cfd6c71bb5b475e986213c2a14 100644 (file)
@@ -296,7 +296,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);
    }