pg_combinebackup: When reconstructing, avoid double slash in filename.
This function is always called with a relative_path that ends in a slash, 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, and adjust the comments. While this is not a critical bug, the duplicate slash is visible in error messages, which could create confusion, so back-patch to v17. This is also better in that it keeps the code consistent across branches. Patch by me, reviewed by Bertrand Drouvot and Amul Sul. Discussion: http://postgr.es/m/CA+TgmoaD7dBYPqe7kMtO0dyto7rd0rUh7joh=JPUSaFszKY6Pg@mail.gmail.com
This commit is contained in:
parent
e1cc4d9067
commit
d9da4abc75
@ -77,8 +77,9 @@ static void read_block(rfile *s, off_t off, uint8 *buffer);
|
|||||||
*
|
*
|
||||||
* relative_path should be the path to the directory containing this file,
|
* relative_path should be the path to the directory containing this file,
|
||||||
* relative to the root of the backup (NOT relative to the root of the
|
* relative to the root of the backup (NOT relative to the root of the
|
||||||
* tablespace). bare_file_name should be the name of the file within that
|
* tablespace). It must always end with a trailing slash. bare_file_name
|
||||||
* directory, without "INCREMENTAL.".
|
* should be the name of the file within that directory, without
|
||||||
|
* "INCREMENTAL.".
|
||||||
*
|
*
|
||||||
* n_prior_backups is the number of prior backups, and prior_backup_dirs is
|
* n_prior_backups is the number of prior backups, and prior_backup_dirs is
|
||||||
* an array of pathnames where those backups can be found.
|
* an array of pathnames where those backups can be found.
|
||||||
@ -111,6 +112,10 @@ reconstruct_from_incremental_file(char *input_filename,
|
|||||||
rfile *copy_source = NULL;
|
rfile *copy_source = NULL;
|
||||||
pg_checksum_context checksum_ctx;
|
pg_checksum_context checksum_ctx;
|
||||||
|
|
||||||
|
/* Sanity check the relative_path. */
|
||||||
|
Assert(relative_path[0] != '\0');
|
||||||
|
Assert(relative_path[strlen(relative_path) - 1] == '/');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Every block must come either from the latest version of the file or
|
* Every block must come either from the latest version of the file or
|
||||||
* from one of the prior backups.
|
* from one of the prior backups.
|
||||||
@ -174,11 +179,11 @@ reconstruct_from_incremental_file(char *input_filename,
|
|||||||
* Look for the full file in the previous backup. If not found, then
|
* Look for the full file in the previous backup. If not found, then
|
||||||
* look for an incremental file instead.
|
* look for an incremental file instead.
|
||||||
*/
|
*/
|
||||||
snprintf(source_filename, MAXPGPATH, "%s/%s/%s",
|
snprintf(source_filename, MAXPGPATH, "%s/%s%s",
|
||||||
prior_backup_dirs[sidx], relative_path, bare_file_name);
|
prior_backup_dirs[sidx], relative_path, bare_file_name);
|
||||||
if ((s = make_rfile(source_filename, true)) == NULL)
|
if ((s = make_rfile(source_filename, true)) == NULL)
|
||||||
{
|
{
|
||||||
snprintf(source_filename, MAXPGPATH, "%s/%s/INCREMENTAL.%s",
|
snprintf(source_filename, MAXPGPATH, "%s/%sINCREMENTAL.%s",
|
||||||
prior_backup_dirs[sidx], relative_path, bare_file_name);
|
prior_backup_dirs[sidx], relative_path, bare_file_name);
|
||||||
s = make_incremental_rfile(source_filename);
|
s = make_incremental_rfile(source_filename);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user