From f69e780d37b6d737f803f2d3e7f671953c239c7e Mon Sep 17 00:00:00 2001 From: stalkerg Date: Tue, 6 Sep 2016 16:30:54 +0300 Subject: [PATCH] Fix checksums for segno > 0 --- backup.c | 14 ++++++++++++++ data.c | 5 +++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/backup.c b/backup.c index eddf13e6..2ff79ad0 100644 --- a/backup.c +++ b/backup.c @@ -1106,6 +1106,20 @@ add_files(parray *files, const char *root, bool add_root, bool is_pgdata) continue; file->is_datafile = true; + { + int find_dot; + char *text_segno; + for(find_dot = path_len-1; file->path[find_dot] != '.' && find_dot >= 0; find_dot--); + if (find_dot <= 0) + continue; + + text_segno = file->path + find_dot + 1; + /* in future we will need check all chars */ + if (!isdigit(text_segno[0])) + continue; + + file->segno = (int) strtol(text_segno, NULL, 10); + } } parray_concat(files, list_file); } diff --git a/data.c b/data.c index de3b7d85..20b674c5 100644 --- a/data.c +++ b/data.c @@ -185,8 +185,9 @@ backup_data_file(const char *from_root, const char *to_root, elog(ERROR, "File: %s blknum %u have wrong page header.", file->path, blknum); } + if(current.checksum_version && - pg_checksum_page(page.data, header.block) != ((PageHeader) page.data)->pd_checksum) + pg_checksum_page(page.data, file->segno * RELSEG_SIZE + blknum) != ((PageHeader) page.data)->pd_checksum) { if (try_checksum) { @@ -307,7 +308,7 @@ backup_data_file(const char *from_root, const char *to_root, } if(current.checksum_version && - pg_checksum_page(page.data, header.block) != ((PageHeader) page.data)->pd_checksum) + pg_checksum_page(page.data, file->segno * RELSEG_SIZE + blknum) != ((PageHeader) page.data)->pd_checksum) { if (try_checksum) elog(WARNING, "File: %s blknum %u have wrong checksum, try again", file->path, blknum);