postgres.git / summary / log / commit / refs
commit 3064f0e25fc728385c873e776b0bf08a3f3ea09c
Author: Peter Eisentraut <peter_e@gmx.net>
Date: Wed Nov 01 14:20:05 2017 +0000
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>
src/bin/pg_basebackup/pg_basebackup.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c
index 17b8a8bbe12..888ef43ed04 100644
--- a/src/bin/pg_basebackup/pg_basebackup.c
+++ b/src/bin/pg_basebackup/pg_basebackup.c
@@ -201,6 +201,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);
@@ -1120,9 +1125,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;
[parent: d2e6bd13a072]