1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-07-01 05:24:49 +02:00

[Issue #351] fix data type for header offset

This commit is contained in:
Grigory Smolkin
2021-03-25 16:45:24 +03:00
parent 59dc864483
commit 1647d11456
3 changed files with 15 additions and 13 deletions

View File

@ -2456,7 +2456,7 @@ write_backup_filelist(pgBackup *backup, parray *files, const char *root,
{ {
len += sprintf(line+len, ",\"n_headers\":\"%i\"", file->n_headers); len += sprintf(line+len, ",\"n_headers\":\"%i\"", file->n_headers);
len += sprintf(line+len, ",\"hdr_crc\":\"%u\"", file->hdr_crc); len += sprintf(line+len, ",\"hdr_crc\":\"%u\"", file->hdr_crc);
len += sprintf(line+len, ",\"hdr_off\":\"%li\"", file->hdr_off); len += sprintf(line+len, ",\"hdr_off\":\"%llu\"", file->hdr_off);
len += sprintf(line+len, ",\"hdr_size\":\"%i\"", file->hdr_size); len += sprintf(line+len, ",\"hdr_size\":\"%i\"", file->hdr_size);
} }

View File

@ -2160,7 +2160,7 @@ get_data_file_headers(HeaderMap *hdr_map, pgFile *file, uint32 backup_version, b
if (fseek(in, file->hdr_off, SEEK_SET)) if (fseek(in, file->hdr_off, SEEK_SET))
{ {
elog(strict ? ERROR : WARNING, "Cannot seek to position %lu in page header map \"%s\": %s", elog(strict ? ERROR : WARNING, "Cannot seek to position %llu in page header map \"%s\": %s",
file->hdr_off, hdr_map->path, strerror(errno)); file->hdr_off, hdr_map->path, strerror(errno));
goto cleanup; goto cleanup;
} }
@ -2177,7 +2177,7 @@ get_data_file_headers(HeaderMap *hdr_map, pgFile *file, uint32 backup_version, b
if (fread(zheaders, 1, file->hdr_size, in) != file->hdr_size) if (fread(zheaders, 1, file->hdr_size, in) != file->hdr_size)
{ {
elog(strict ? ERROR : WARNING, "Cannot read header file at offset: %li len: %i \"%s\": %s", elog(strict ? ERROR : WARNING, "Cannot read header file at offset: %llu len: %i \"%s\": %s",
file->hdr_off, file->hdr_size, hdr_map->path, strerror(errno)); file->hdr_off, file->hdr_size, hdr_map->path, strerror(errno));
goto cleanup; goto cleanup;
} }
@ -2208,7 +2208,7 @@ get_data_file_headers(HeaderMap *hdr_map, pgFile *file, uint32 backup_version, b
if (hdr_crc != file->hdr_crc) if (hdr_crc != file->hdr_crc)
{ {
elog(strict ? ERROR : WARNING, "Header map for file \"%s\" crc mismatch \"%s\" " elog(strict ? ERROR : WARNING, "Header map for file \"%s\" crc mismatch \"%s\" "
"offset: %lu, len: %lu, current: %u, expected: %u", "offset: %llu, len: %lu, current: %u, expected: %u",
file->rel_path, hdr_map->path, file->hdr_off, read_len, hdr_crc, file->hdr_crc); file->rel_path, hdr_map->path, file->hdr_off, read_len, hdr_crc, file->hdr_crc);
goto cleanup; goto cleanup;
} }
@ -2268,7 +2268,7 @@ write_page_headers(BackupPageHeader2 *headers, pgFile *file, HeaderMap *hdr_map,
{ {
elog(LOG, "Creating page header map \"%s\"", map_path); elog(LOG, "Creating page header map \"%s\"", map_path);
hdr_map->fp = fopen(map_path, 'a'); hdr_map->fp = fopen(map_path, "a");
if (hdr_map->fp == NULL) if (hdr_map->fp == NULL)
elog(ERROR, "Cannot open header file \"%s\": %s", elog(ERROR, "Cannot open header file \"%s\": %s",
map_path, strerror(errno)); map_path, strerror(errno));
@ -2297,7 +2297,7 @@ write_page_headers(BackupPageHeader2 *headers, pgFile *file, HeaderMap *hdr_map,
file->rel_path, z_len); file->rel_path, z_len);
} }
elog(VERBOSE, "Writing headers for file \"%s\" offset: %li, len: %i, crc: %u", elog(VERBOSE, "Writing headers for file \"%s\" offset: %llu, len: %i, crc: %u",
file->rel_path, file->hdr_off, z_len, file->hdr_crc); file->rel_path, file->hdr_off, z_len, file->hdr_crc);
if (fwrite(zheaders, 1, z_len, hdr_map->fp) != z_len) if (fwrite(zheaders, 1, z_len, hdr_map->fp) != z_len)

View File

@ -208,6 +208,8 @@ do { \
FIN_TRADITIONAL_CRC32(crc); \ FIN_TRADITIONAL_CRC32(crc); \
} while (0) } while (0)
#define pg_off_t unsigned long long
/* Information about single file (or dir) in backup */ /* Information about single file (or dir) in backup */
typedef struct pgFile typedef struct pgFile
@ -249,8 +251,8 @@ typedef struct pgFile
/* Coordinates in header map */ /* Coordinates in header map */
int n_headers; /* number of blocks in the data file in backup */ int n_headers; /* number of blocks in the data file in backup */
pg_crc32 hdr_crc; /* CRC value of header file: name_hdr */ pg_crc32 hdr_crc; /* CRC value of header file: name_hdr */
off_t hdr_off; /* offset in header map */ pg_off_t hdr_off; /* offset in header map */
int hdr_size; /* offset in header map */ int hdr_size; /* length of headers */
} pgFile; } pgFile;
typedef struct page_map_entry typedef struct page_map_entry
@ -406,11 +408,11 @@ typedef struct PGNodeInfo
/* structure used for access to block header map */ /* structure used for access to block header map */
typedef struct HeaderMap typedef struct HeaderMap
{ {
char path[MAXPGPATH]; char path[MAXPGPATH];
char path_tmp[MAXPGPATH]; /* used only in merge */ char path_tmp[MAXPGPATH]; /* used only in merge */
FILE *fp; /* used only for writing */ FILE *fp; /* used only for writing */
char *buf; /* buffer */ char *buf; /* buffer */
off_t offset; /* current position in fp */ pg_off_t offset; /* current position in fp */
pthread_mutex_t mutex; pthread_mutex_t mutex;
} HeaderMap; } HeaderMap;