Skip to content

Commit 03a3fb8

Browse files
committed
PGPRO-1646: Use int64 for write_size
1 parent 1da749a commit 03a3fb8

File tree

6 files changed

+12
-10
lines changed

6 files changed

+12
-10
lines changed

src/backup.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ remote_copy_file(PGconn *conn, pgFile* file)
357357
elog(ERROR, "final receive failed: status %d ; %s",PQresultStatus(res), PQerrorMessage(conn));
358358
}
359359

360-
file->write_size = (int) file->read_size;
360+
file->write_size = (int64) file->read_size;
361361
FIN_CRC32C(file->crc);
362362

363363
fclose(out);
@@ -438,7 +438,7 @@ remote_backup_files(void *arg)
438438
/* receive the data from stream and write to backup file */
439439
remote_copy_file(file_backup_conn, file);
440440

441-
elog(VERBOSE, "File \"%s\". Copied %d bytes",
441+
elog(VERBOSE, "File \"%s\". Copied " INT64_FORMAT " bytes",
442442
file->path, file->write_size);
443443
PQfinish(file_backup_conn);
444444
}
@@ -2115,7 +2115,7 @@ backup_files(void *arg)
21152115
continue;
21162116
}
21172117

2118-
elog(VERBOSE, "File \"%s\". Copied %d bytes",
2118+
elog(VERBOSE, "File \"%s\". Copied "INT64_FORMAT " bytes",
21192119
file->path, file->write_size);
21202120
}
21212121
else

src/data.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
843843
file->read_size += read_len;
844844
}
845845

846-
file->write_size = (int) file->read_size;
846+
file->write_size = (int64) file->read_size;
847847
/* finish CRC calculation and store into pgFile */
848848
FIN_CRC32C(crc);
849849
file->crc = crc;

src/dir.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -821,8 +821,9 @@ print_file_list(FILE *out, const parray *files, const char *root)
821821
if (root && strstr(path, root) == path)
822822
path = GetRelativePath(path, root);
823823

824-
fprintf(out, "{\"path\":\"%s\", \"size\":\"%d\",\"mode\":\"%u\","
825-
"\"is_datafile\":\"%u\", \"is_cfs\":\"%u\", \"crc\":\"%u\","
824+
fprintf(out, "{\"path\":\"%s\", \"size\":\"" INT64_FORMAT "\", "
825+
"\"mode\":\"%u\", \"is_datafile\":\"%u\", "
826+
"\"is_cfs\":\"%u\", \"crc\":\"%u\", "
826827
"\"compress_alg\":\"%s\"",
827828
path, file->write_size, file->mode,
828829
file->is_datafile ? 1 : 0, file->is_cfs ? 1 : 0, file->crc,
@@ -1032,7 +1033,7 @@ dir_read_file_list(const char *root, const char *file_txt)
10321033

10331034
file = pgFileInit(filepath);
10341035

1035-
file->write_size = (int) write_size;
1036+
file->write_size = (int64) write_size;
10361037
file->mode = (mode_t) mode;
10371038
file->is_datafile = is_datafile ? true : false;
10381039
file->is_cfs = is_cfs ? true : false;

src/pg_probackup.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ typedef struct pgFile
8888
size_t size; /* size of the file */
8989
size_t read_size; /* size of the portion read (if only some pages are
9090
backed up, it's different from size) */
91-
int write_size; /* size of the backed-up file. BYTES_INVALID means
91+
int64 write_size; /* size of the backed-up file. BYTES_INVALID means
9292
that the file existed but was not backed up
9393
because not modified since last backup. */
94+
/* we need int64 here to store '-1' value */
9495
pg_crc32 crc; /* CRC value of the file, regular file only */
9596
char *linked; /* path of the linked file */
9697
bool is_datafile; /* true if the file is PostgreSQL data file */

src/restore.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ restore_files(void *arg)
777777

778778
/* print size of restored file */
779779
if (file->write_size != BYTES_INVALID)
780-
elog(LOG, "Restored file %s : %d bytes",
780+
elog(LOG, "Restored file %s : " INT64_FORMAT " bytes",
781781
file->path, file->write_size);
782782
}
783783

src/validate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ pgBackupValidateFiles(void *arg)
189189

190190
if (file->write_size != st.st_size)
191191
{
192-
elog(WARNING, "Invalid size of backup file \"%s\" : %d. Expected %lu",
192+
elog(WARNING, "Invalid size of backup file \"%s\" : " INT64_FORMAT ". Expected %lu",
193193
file->path, file->write_size, (unsigned long) st.st_size);
194194
arguments->corrupted = true;
195195
break;

0 commit comments

Comments
 (0)