!908 代码回退

Merge pull request !908 from chenxiaobin/rewind
This commit is contained in:
opengauss-bot
2021-06-15 14:55:55 +08:00
committed by Gitee
3 changed files with 11 additions and 12 deletions

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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));