Commit 067a2259 authored by Peter Eisentraut's avatar Peter Eisentraut

pg_basebackup: Fix comparison handling of tablespace mappings on Windows

A candidate path needs to be canonicalized before being checked against
the mappings, because the mappings are also canonicalized.  This is
especially relevant on Windows
Reported-by: default avatarnb <nbedxp@gmail.com>
Author: Michael Paquier <michael.paquier@gmail.com>
Reviewed-by: default avatarAshutosh Sharma <ashu.coek88@gmail.com>
parent 63d6b97f
......@@ -298,6 +298,11 @@ tablespace_list_append(const char *arg)
exit(1);
}
/*
* Comparisons done with these values should involve similarly
* canonicalized path values. This is particularly sensitive on Windows
* where path values may not necessarily use Unix slashes.
*/
canonicalize_path(cell->old_dir);
canonicalize_path(cell->new_dir);
......@@ -1303,9 +1308,14 @@ static const char *
get_tablespace_mapping(const char *dir)
{
TablespaceListCell *cell;
char canon_dir[MAXPGPATH];
/* Canonicalize path for comparison consistency */
strlcpy(canon_dir, dir, sizeof(canon_dir));
canonicalize_path(canon_dir);
for (cell = tablespace_dirs.head; cell; cell = cell->next)
if (strcmp(dir, cell->old_dir) == 0)
if (strcmp(canon_dir, cell->old_dir) == 0)
return cell->new_dir;
return dir;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment