diff options
Diffstat (limited to 'src/bin/pg_rewind/libpq_fetch.c')
-rw-r--r-- | src/bin/pg_rewind/libpq_fetch.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/src/bin/pg_rewind/libpq_fetch.c b/src/bin/pg_rewind/libpq_fetch.c index d06e2774325..11ec045b8ec 100644 --- a/src/bin/pg_rewind/libpq_fetch.c +++ b/src/bin/pg_rewind/libpq_fetch.c @@ -24,6 +24,7 @@ #include "libpq-fe.h" #include "catalog/pg_type_d.h" #include "fe_utils/connect.h" +#include "fe_utils/logging.h" #include "port/pg_bswap.h" static PGconn *conn = NULL; @@ -52,7 +53,8 @@ libpqConnect(const char *connstr) pg_fatal("could not connect to server: %s", PQerrorMessage(conn)); - pg_log(PG_PROGRESS, "connected to server\n"); + if (showprogress) + pg_log_info("connected to server"); res = PQexec(conn, ALWAYS_SECURE_SEARCH_PATH_SQL); if (PQresultStatus(res) != PGRES_TUPLES_OK) @@ -68,7 +70,7 @@ libpqConnect(const char *connstr) */ str = run_simple_query("SELECT pg_is_in_recovery()"); if (strcmp(str, "f") != 0) - pg_fatal("source server must not be in recovery mode\n"); + pg_fatal("source server must not be in recovery mode"); pg_free(str); /* @@ -78,7 +80,7 @@ libpqConnect(const char *connstr) */ str = run_simple_query("SHOW full_page_writes"); if (strcmp(str, "on") != 0) - pg_fatal("full_page_writes must be enabled in the source server\n"); + pg_fatal("full_page_writes must be enabled in the source server"); pg_free(str); /* @@ -113,7 +115,7 @@ run_simple_query(const char *sql) /* sanity check the result set */ if (PQnfields(res) != 1 || PQntuples(res) != 1 || PQgetisnull(res, 0, 0)) - pg_fatal("unexpected result set from query\n"); + pg_fatal("unexpected result set from query"); result = pg_strdup(PQgetvalue(res, 0, 0)); @@ -136,7 +138,7 @@ libpqGetCurrentXlogInsertLocation(void) val = run_simple_query("SELECT pg_current_wal_insert_lsn()"); if (sscanf(val, "%X/%X", &hi, &lo) != 2) - pg_fatal("unrecognized result \"%s\" for current WAL insert location\n", val); + pg_fatal("unrecognized result \"%s\" for current WAL insert location", val); result = ((uint64) hi) << 32 | lo; @@ -191,7 +193,7 @@ libpqProcessFileList(void) /* sanity check the result set */ if (PQnfields(res) != 4) - pg_fatal("unexpected result set while fetching file list\n"); + pg_fatal("unexpected result set while fetching file list"); /* Read result to local variables */ for (i = 0; i < PQntuples(res); i++) @@ -241,10 +243,10 @@ receiveFileChunks(const char *sql) if (PQsendQueryParams(conn, sql, 0, NULL, NULL, NULL, NULL, 1) != 1) pg_fatal("could not send query: %s", PQerrorMessage(conn)); - pg_log(PG_DEBUG, "getting file chunks\n"); + pg_log_debug("getting file chunks"); if (PQsetSingleRowMode(conn) != 1) - pg_fatal("could not set libpq connection to single row mode\n"); + pg_fatal("could not set libpq connection to single row mode"); while ((res = PQgetResult(conn)) != NULL) { @@ -271,13 +273,13 @@ receiveFileChunks(const char *sql) /* sanity check the result set */ if (PQnfields(res) != 3 || PQntuples(res) != 1) - pg_fatal("unexpected result set size while fetching remote files\n"); + pg_fatal("unexpected result set size while fetching remote files"); if (PQftype(res, 0) != TEXTOID || PQftype(res, 1) != INT8OID || PQftype(res, 2) != BYTEAOID) { - pg_fatal("unexpected data types in result set while fetching remote files: %u %u %u\n", + pg_fatal("unexpected data types in result set while fetching remote files: %u %u %u", PQftype(res, 0), PQftype(res, 1), PQftype(res, 2)); } @@ -285,17 +287,17 @@ receiveFileChunks(const char *sql) PQfformat(res, 1) != 1 && PQfformat(res, 2) != 1) { - pg_fatal("unexpected result format while fetching remote files\n"); + pg_fatal("unexpected result format while fetching remote files"); } if (PQgetisnull(res, 0, 0) || PQgetisnull(res, 0, 1)) { - pg_fatal("unexpected null values in result while fetching remote files\n"); + pg_fatal("unexpected null values in result while fetching remote files"); } if (PQgetlength(res, 0, 1) != sizeof(int64)) - pg_fatal("unexpected result length while fetching remote files\n"); + pg_fatal("unexpected result length while fetching remote files"); /* Read result set to local variables */ memcpy(&chunkoff, PQgetvalue(res, 0, 1), sizeof(int64)); @@ -319,8 +321,7 @@ receiveFileChunks(const char *sql) */ if (PQgetisnull(res, 0, 2)) { - pg_log(PG_DEBUG, - "received null value for chunk for file \"%s\", file has been deleted\n", + pg_log_debug("received null value for chunk for file \"%s\", file has been deleted", filename); remove_target_file(filename, true); pg_free(filename); @@ -333,7 +334,7 @@ receiveFileChunks(const char *sql) * translatable strings. */ snprintf(chunkoff_str, sizeof(chunkoff_str), INT64_FORMAT, chunkoff); - pg_log(PG_DEBUG, "received chunk for file \"%s\", offset %s, size %d\n", + pg_log_debug("received chunk for file \"%s\", offset %s, size %d", filename, chunkoff_str, chunksize); open_target_file(filename, false); @@ -367,7 +368,7 @@ libpqGetFile(const char *filename, size_t *filesize) /* sanity check the result set */ if (PQntuples(res) != 1 || PQgetisnull(res, 0, 0)) - pg_fatal("unexpected result set while fetching remote file \"%s\"\n", + pg_fatal("unexpected result set while fetching remote file \"%s\"", filename); /* Read result to local variables */ @@ -378,7 +379,7 @@ libpqGetFile(const char *filename, size_t *filesize) PQclear(res); - pg_log(PG_DEBUG, "fetched file \"%s\", length %d\n", filename, len); + pg_log_debug("fetched file \"%s\", length %d", filename, len); if (filesize) *filesize = len; |