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 21:42:17 +0000 (22:42 +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 6f9473bc55d6b9436ce730758d94b2c826e915a5..e6b062f316d851b591f75e0f86833b9e855b893d 100644 (file)
@@ -201,8 +201,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 0dae75b86287c9318197003690c44eafbb9c2bea..97b1017a49980a2ffb51ef90c9dffdc8abdf3043 100644 (file)
@@ -49,8 +49,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 e4c0a7eacbfc73f3409da168d173836b5e6c6f78..67653ae75f88fbb8a762099795dec58288ee7c1c 100644 (file)
@@ -300,7 +300,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);
    }