Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6c24801

Browse files
committed
pg_combinebackup: When reconstructing, avoid double slash in filename.
This function is always called with a relative_path that ends in aslash, so there's no need to insert a second one. So, don't. Instead,add an assertion to verify that nothing gets broken in the future, andadjust the comments.While this is not a critical bug, the duplicate slash is visible inerror messages, which could create confusion, so back-patch to v17.This is also better in that it keeps the code consistent acrossbranches.Patch by me, reviewed by Bertrand Drouvot and Amul Sul.Discussion:http://postgr.es/m/CA+TgmoaD7dBYPqe7kMtO0dyto7rd0rUh7joh=JPUSaFszKY6Pg@mail.gmail.com
1 parent7ac744e commit6c24801

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

‎src/bin/pg_combinebackup/reconstruct.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ static void read_block(rfile *s, off_t off, uint8 *buffer);
7777
*
7878
* relative_path should be the path to the directory containing this file,
7979
* relative to the root of the backup (NOT relative to the root of the
80-
* tablespace). bare_file_name should be the name of the file within that
81-
* directory, without "INCREMENTAL.".
80+
* tablespace). It must always end with a trailing slash. bare_file_name
81+
* should be the name of the file within that directory, without
82+
* "INCREMENTAL.".
8283
*
8384
* n_prior_backups is the number of prior backups, and prior_backup_dirs is
8485
* an array of pathnames where those backups can be found.
@@ -111,6 +112,10 @@ reconstruct_from_incremental_file(char *input_filename,
111112
rfile*copy_source=NULL;
112113
pg_checksum_contextchecksum_ctx;
113114

115+
/* Sanity check the relative_path. */
116+
Assert(relative_path[0]!='\0');
117+
Assert(relative_path[strlen(relative_path)-1]=='/');
118+
114119
/*
115120
* Every block must come either from the latest version of the file or
116121
* from one of the prior backups.
@@ -174,11 +179,11 @@ reconstruct_from_incremental_file(char *input_filename,
174179
* Look for the full file in the previous backup. If not found, then
175180
* look for an incremental file instead.
176181
*/
177-
snprintf(source_filename,MAXPGPATH,"%s/%s/%s",
182+
snprintf(source_filename,MAXPGPATH,"%s/%s%s",
178183
prior_backup_dirs[sidx],relative_path,bare_file_name);
179184
if ((s=make_rfile(source_filename, true))==NULL)
180185
{
181-
snprintf(source_filename,MAXPGPATH,"%s/%s/INCREMENTAL.%s",
186+
snprintf(source_filename,MAXPGPATH,"%s/%sINCREMENTAL.%s",
182187
prior_backup_dirs[sidx],relative_path,bare_file_name);
183188
s=make_incremental_rfile(source_filename);
184189
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp