Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit dd12b53

Browse files
committed
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>
1 parent e4381c0 commit dd12b53

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/bin/pg_basebackup/pg_basebackup.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,11 @@ tablespace_list_append(const char *arg)
295295
exit(1);
296296
}
297297

298+
/*
299+
* Comparisons done with these values should involve similarly
300+
* canonicalized path values. This is particularly sensitive on Windows
301+
* where path values may not necessarily use Unix slashes.
302+
*/
298303
canonicalize_path(cell->old_dir);
299304
canonicalize_path(cell->new_dir);
300305

@@ -1283,9 +1288,14 @@ static const char *
12831288
get_tablespace_mapping(const char *dir)
12841289
{
12851290
TablespaceListCell *cell;
1291+
char canon_dir[MAXPGPATH];
1292+
1293+
/* Canonicalize path for comparison consistency */
1294+
strlcpy(canon_dir, dir, sizeof(canon_dir));
1295+
canonicalize_path(canon_dir);
12861296

12871297
for (cell = tablespace_dirs.head; cell; cell = cell->next)
1288-
if (strcmp(dir, cell->old_dir) == 0)
1298+
if (strcmp(canon_dir, cell->old_dir) == 0)
12891299
return cell->new_dir;
12901300

12911301
return dir;

0 commit comments

Comments
 (0)