aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2017-11-01 10:20:05 -0400
committerPeter Eisentraut <peter_e@gmx.net>2017-11-01 10:20:05 -0400
commit067a2259fd2d7050ecf13a82a96e9a95bf8b3785 (patch)
treef64fe6a4c1abe640edc4c9f4fde900e1beb5b6f7 /src
parent63d6b97fd904232e7c7a8a2b9c52a3cc7eb47bef (diff)
downloadpostgresql-067a2259fd2d7050ecf13a82a96e9a95bf8b3785.tar.gz
postgresql-067a2259fd2d7050ecf13a82a96e9a95bf8b3785.zip
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: nb <nbedxp@gmail.com> Author: Michael Paquier <michael.paquier@gmail.com> Reviewed-by: Ashutosh Sharma <ashu.coek88@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_basebackup/pg_basebackup.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c
index dac7299ff48..a8715d912d5 100644
--- a/src/bin/pg_basebackup/pg_basebackup.c
+++ b/src/bin/pg_basebackup/pg_basebackup.c
@@ -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;