diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index a7b7cc6bf7f..4daf985ab83 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -1999,9 +1999,9 @@ BaseBackup(char *compression_algorithm, char *compression_detail, if (PQresultStatus(res) != PGRES_TUPLES_OK) pg_fatal("could not initiate base backup: %s", PQerrorMessage(conn)); - if (PQntuples(res) != 1) - pg_fatal("server returned unexpected response to BASE_BACKUP command; got %d rows and %d fields, expected %d rows and %d fields", - PQntuples(res), PQnfields(res), 1, 2); + if (PQntuples(res) != 1 || PQnfields(res) < 1) + pg_fatal("server returned unexpected response to BASE_BACKUP command; got %d rows and %d fields, expected %d rows and %d or more fields", + PQntuples(res), PQnfields(res), 1, 1); strlcpy(xlogstart, PQgetvalue(res, 0, 0), sizeof(xlogstart)); @@ -2030,8 +2030,9 @@ BaseBackup(char *compression_algorithm, char *compression_detail, if (PQresultStatus(res) != PGRES_TUPLES_OK) pg_fatal("could not get backup header: %s", PQerrorMessage(conn)); - if (PQntuples(res) < 1) - pg_fatal("no data returned from server"); + if (PQntuples(res) < 1 || PQnfields(res) < 3) + pg_fatal("could not get backup header: got %d rows and %d fields, expected %d or more rows and %d or more fields", + PQntuples(res), PQnfields(res), 1, 3); /* * Sum up the total size, for progress reporting @@ -2172,8 +2173,9 @@ BaseBackup(char *compression_algorithm, char *compression_detail, if (PQresultStatus(res) != PGRES_TUPLES_OK) pg_fatal("backup failed: %s", PQerrorMessage(conn)); - if (PQntuples(res) != 1) - pg_fatal("no write-ahead log end position returned from server"); + if (PQntuples(res) != 1 || PQnfields(res) < 1) + pg_fatal("could not get write-ahead log end position: got %d rows and %d fields, expected %d rows and %d or more fields", + PQntuples(res), PQnfields(res), 1, 1); strlcpy(xlogend, PQgetvalue(res, 0, 0), sizeof(xlogend)); if (verbose && includewal != NO_WAL) pg_log_info("write-ahead log end point: %s", xlogend);