Skip to content

Commit f69e780

Browse files
committed
Fix checksums for segno > 0
1 parent 55686d3 commit f69e780

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

backup.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,20 @@ add_files(parray *files, const char *root, bool add_root, bool is_pgdata)
11061106
continue;
11071107

11081108
file->is_datafile = true;
1109+
{
1110+
int find_dot;
1111+
char *text_segno;
1112+
for(find_dot = path_len-1; file->path[find_dot] != '.' && find_dot >= 0; find_dot--);
1113+
if (find_dot <= 0)
1114+
continue;
1115+
1116+
text_segno = file->path + find_dot + 1;
1117+
/* in future we will need check all chars */
1118+
if (!isdigit(text_segno[0]))
1119+
continue;
1120+
1121+
file->segno = (int) strtol(text_segno, NULL, 10);
1122+
}
11091123
}
11101124
parray_concat(files, list_file);
11111125
}

data.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,9 @@ backup_data_file(const char *from_root, const char *to_root,
185185
elog(ERROR, "File: %s blknum %u have wrong page header.", file->path, blknum);
186186
}
187187

188+
188189
if(current.checksum_version &&
189-
pg_checksum_page(page.data, header.block) != ((PageHeader) page.data)->pd_checksum)
190+
pg_checksum_page(page.data, file->segno * RELSEG_SIZE + blknum) != ((PageHeader) page.data)->pd_checksum)
190191
{
191192
if (try_checksum)
192193
{
@@ -307,7 +308,7 @@ backup_data_file(const char *from_root, const char *to_root,
307308
}
308309

309310
if(current.checksum_version &&
310-
pg_checksum_page(page.data, header.block) != ((PageHeader) page.data)->pd_checksum)
311+
pg_checksum_page(page.data, file->segno * RELSEG_SIZE + blknum) != ((PageHeader) page.data)->pd_checksum)
311312
{
312313
if (try_checksum)
313314
elog(WARNING, "File: %s blknum %u have wrong checksum, try again", file->path, blknum);

0 commit comments

Comments
 (0)