diff options
| author | Robert Haas | 2022-10-21 12:21:55 +0000 |
|---|---|---|
| committer | Robert Haas | 2022-10-21 12:45:08 +0000 |
| commit | 0bf2cd1602b12fef2af74e1bd8b097cf8319ee66 (patch) | |
| tree | d0d1e2ea0e373e597903b3825c5514b6c314d3e5 /src/include | |
| parent | 1eed947f9852de4bd378aa0f5006a4bb8db67c09 (diff) | |
pg_basebackup: Fix cross-platform tablespace relocation.
Specifically, when pg_basebackup is invoked with -Tx=y, don't error
out if x could plausibly be an absolute path either on Windows or on
non-Windows systems. We don't know whether the remote system is
running the same OS as the local system, so it's not appropriate to
assume that our local rule about absolute pathnames is the same as
the rule on the remote system.
Patch by me, reviewed by Tom Lane, Andrew Dunstan, and
Davinder Singh.
Discussion: http://postgr.es/m/CA+TgmoY+jC3YiskomvYKDPK3FbrmsDU7_8+wMHt02HOdJeRb0g@mail.gmail.com
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/port.h | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/include/port.h b/src/include/port.h index d4c94a4411d..0c3c8d14e76 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -75,28 +75,32 @@ extern void get_parent_directory(char *path); extern char **pgfnames(const char *path); extern void pgfnames_cleanup(char **filenames); -/* - * is_absolute_path - * - * By making this a macro we avoid needing to include path.c in libpq. - */ -#ifndef WIN32 -#define IS_DIR_SEP(ch) ((ch) == '/') - -#define is_absolute_path(filename) \ +#define IS_NONWINDOWS_DIR_SEP(ch) ((ch) == '/') +#define is_nonwindows_absolute_path(filename) \ ( \ - IS_DIR_SEP((filename)[0]) \ + IS_NONWINDOWS_DIR_SEP((filename)[0]) \ ) -#else -#define IS_DIR_SEP(ch) ((ch) == '/' || (ch) == '\\') +#define IS_WINDOWS_DIR_SEP(ch) ((ch) == '/' || (ch) == '\\') /* See path_is_relative_and_below_cwd() for how we handle 'E:abc'. */ -#define is_absolute_path(filename) \ +#define is_windows_absolute_path(filename) \ ( \ - IS_DIR_SEP((filename)[0]) || \ + IS_WINDOWS_DIR_SEP((filename)[0]) || \ (isalpha((unsigned char) ((filename)[0])) && (filename)[1] == ':' && \ - IS_DIR_SEP((filename)[2])) \ + IS_WINDOWS_DIR_SEP((filename)[2])) \ ) + +/* + * is_absolute_path and IS_DIR_SEP + * + * By using macros here we avoid needing to include path.c in libpq. + */ +#ifndef WIN32 +#define IS_DIR_SEP(ch) IS_NONWINDOWS_DIR_SEP(ch) +#define is_absolute_path(filename) is_nonwindows_absolute_path(filename) +#else +#define IS_DIR_SEP(ch) IS_WINDOWS_DIR_SEP(ch) +#define is_absolute_path(filename) is_windows_absolute_path(filename) #endif /* Portable locale initialization (in exec.c) */ |
