Skip to content

Commit 067a225

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 63d6b97 commit 067a225

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
@@ -298,6 +298,11 @@ tablespace_list_append(const char *arg)
298298
exit(1);
299299
}
300300

301+
/*
302+
* Comparisons done with these values should involve similarly
303+
* canonicalized path values. This is particularly sensitive on Windows
304+
* where path values may not necessarily use Unix slashes.
305+
*/
301306
canonicalize_path(cell->old_dir);
302307
canonicalize_path(cell->new_dir);
303308

@@ -1303,9 +1308,14 @@ static const char *
13031308
get_tablespace_mapping(const char *dir)
13041309
{
13051310
TablespaceListCell *cell;
1311+
char canon_dir[MAXPGPATH];
1312+
1313+
/* Canonicalize path for comparison consistency */
1314+
strlcpy(canon_dir, dir, sizeof(canon_dir));
1315+
canonicalize_path(canon_dir);
13061316

13071317
for (cell = tablespace_dirs.head; cell; cell = cell->next)
1308-
if (strcmp(dir, cell->old_dir) == 0)
1318+
if (strcmp(canon_dir, cell->old_dir) == 0)
13091319
return cell->new_dir;
13101320

13111321
return dir;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy