From a6e46957f5a675975d0c8dc02b9b254036cdeeec Mon Sep 17 00:00:00 2001 From: chenxiaobin <1025221611@qq.com> Date: Fri, 16 Apr 2021 10:59:02 +0800 Subject: [PATCH] rollback --- src/bin/pg_basebackup/pg_basebackup.cpp | 2 +- src/bin/pg_ctl/backup.cpp | 2 +- src/bin/pg_rewind/fetch.cpp | 19 +++++++++---------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/bin/pg_basebackup/pg_basebackup.cpp b/src/bin/pg_basebackup/pg_basebackup.cpp index cb1235522..82a9cae5d 100644 --- a/src/bin/pg_basebackup/pg_basebackup.cpp +++ b/src/bin/pg_basebackup/pg_basebackup.cpp @@ -938,7 +938,7 @@ static void ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum) /* * All files are padded up to 512 bytes */ - if (current_len_left < 0 || current_len_left > LLONG_MAX - 511) { + if (current_len_left < 0 || current_len_left > INT_MAX - 511) { pg_log(stderr, _("%s: the file '%s' is too big or file size is invalid\n"), progname, copybuf); disconnect_and_exit(1); } diff --git a/src/bin/pg_ctl/backup.cpp b/src/bin/pg_ctl/backup.cpp index 9289d6bd1..52268fd9b 100644 --- a/src/bin/pg_ctl/backup.cpp +++ b/src/bin/pg_ctl/backup.cpp @@ -814,7 +814,7 @@ static void ReceiveAndUnpackTarFile(PGconn* conn, PGresult* res, int rownum) /* * All files are padded up to 512 bytes */ - if (current_len_left < 0 || current_len_left > LLONG_MAX - 511) { + if (current_len_left < 0 || current_len_left > INT_MAX - 511) { pg_log(PG_WARNING, _("current_len_left is invalid\n")); disconnect_and_exit(1); } diff --git a/src/bin/pg_rewind/fetch.cpp b/src/bin/pg_rewind/fetch.cpp index 38b86b792..9a80abde5 100644 --- a/src/bin/pg_rewind/fetch.cpp +++ b/src/bin/pg_rewind/fetch.cpp @@ -25,7 +25,6 @@ #include "common/fe_memutils.h" #include "catalog/catalog.h" #include "catalog/pg_type.h" -#include "miscadmin.h" PGconn* conn = NULL; char source_slot_name[NAMEDATALEN] = {0}; @@ -315,7 +314,7 @@ BuildErrorCode fetchSourceFileList() * the received parts. The result set is expected to be of format: * * path text -- path in the data directory, e.g "base/1/123" - * begin int8 -- offset within the file + * begin int4 -- offset within the file * chunk bytea -- file content * ---- */ @@ -339,7 +338,7 @@ static BuildErrorCode receiveFileChunks(const char* sql, FILE* file) while ((res = PQgetResult(conn)) != NULL) { char* filename = NULL; int filenamelen; - int64 chunkoff; + int chunkoff; int chunksize; int chunkspace; char* chunk = NULL; @@ -363,7 +362,7 @@ static BuildErrorCode receiveFileChunks(const char* sql, FILE* file) PG_CHECKBUILD_AND_FREE_PGRESULT_RETURN(res); } - if (PQftype(res, 0) != TEXTOID && PQftype(res, 1) != INT8OID && PQftype(res, 2) != BYTEAOID && + if (PQftype(res, 0) != TEXTOID && PQftype(res, 1) != INT4OID && PQftype(res, 2) != BYTEAOID && PQftype(res, 3) != INT4OID) { pg_fatal("unexpected data types in result set while fetching remote files: %u %u %u %u\n", PQftype(res, 0), @@ -383,15 +382,15 @@ static BuildErrorCode receiveFileChunks(const char* sql, FILE* file) PG_CHECKBUILD_AND_FREE_PGRESULT_RETURN(res); } - if (PQgetlength(res, 0, 1) != sizeof(int64)) { + if (PQgetlength(res, 0, 1) != sizeof(int32)) { pg_fatal("unexpected result length while fetching remote files\n"); PG_CHECKBUILD_AND_FREE_PGRESULT_RETURN(res); } /* Read result set to local variables */ - errorno = memcpy_s(&chunkoff, sizeof(int64), PQgetvalue(res, 0, 1), sizeof(int64)); + errorno = memcpy_s(&chunkoff, sizeof(int32), PQgetvalue(res, 0, 1), sizeof(int32)); securec_check_c(errorno, "\0", "\0"); - chunkoff = (int64)ntohl64((uint64)chunkoff); + chunkoff = ntohl(chunkoff); chunksize = PQgetlength(res, 0, 2); filenamelen = PQgetlength(res, 0, 0); @@ -422,9 +421,9 @@ static BuildErrorCode receiveFileChunks(const char* sql, FILE* file) continue; } - pg_log(PG_DEBUG, "received chunk for file \"%s\", offset " INT64_FORMAT ", size %d\n", + pg_log(PG_DEBUG, "received chunk for file \"%s\", offset %d, size %d\n", filename, chunkoff, chunksize); - fprintf(file, "received chunk for file \"%s\", offset " INT64_FORMAT ", size %d\n", + fprintf(file, "received chunk for file \"%s\", offset %d, size %d\n", filename, chunkoff, chunksize); open_target_file(filename, false); @@ -536,7 +535,7 @@ BuildErrorCode executeFileMap(filemap_t* map, FILE* file) * First create a temporary table, and load it with the blocks that we * need to fetch. */ - sql = "CREATE TEMPORARY TABLE fetchchunks(path text, begin int8, len int4);"; + sql = "CREATE TEMPORARY TABLE fetchchunks(path text, begin int4, len int4);"; res = PQexec(conn, sql); if (PQresultStatus(res) != PGRES_COMMAND_OK) { pg_fatal("could not create temporary table: %s", PQresultErrorMessage(res));