diff options
author | Michael Paquier | 2023-07-30 06:26:25 +0000 |
---|---|---|
committer | Michael Paquier | 2023-07-30 06:26:25 +0000 |
commit | bf227926d22b5cffba4b6724df0eb239a7037cbd (patch) | |
tree | ce46264b70e75181eb1fbde58a91615215677217 /src/bin/pg_rewind/libpq_source.c | |
parent | b68e356a680ee1155b0dc612a89655e98320121a (diff) |
Fix pg_rewind with in-place tablespaces when source is remote
libpq_source.c would consider any result returned by
pg_tablespace_location() as a symlink, resulting in run-time errors like
that:
pg_rewind: error: file "pg_tblspc/NN" is of different type in source and target
In-place tablespaces are directories located in pg_tblspc/, returned as
relative paths instead of absolute paths, so rely on that to make the
difference with a normal tablespace and an in-place one. If the path is
relative, the tablespace is handled as a directory. If the path is
absolute, consider it as a symlink.
In-place tablespaces are only intended for development purposes, so like
363e8f9 no backpatch is done. A test is added in pg_rewind with an
in-place tablespace and some data in it.
Author: Rui Zhao, Michael Paquier
Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/bin/pg_rewind/libpq_source.c')
-rw-r--r-- | src/bin/pg_rewind/libpq_source.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/bin/pg_rewind/libpq_source.c b/src/bin/pg_rewind/libpq_source.c index 0d8e9ee2d1a..417c74cfefc 100644 --- a/src/bin/pg_rewind/libpq_source.c +++ b/src/bin/pg_rewind/libpq_source.c @@ -298,7 +298,16 @@ libpq_traverse_files(rewind_source *source, process_file_callback_t callback) link_target = PQgetvalue(res, i, 3); if (link_target[0]) - type = FILE_TYPE_SYMLINK; + { + /* + * In-place tablespaces are directories located in pg_tblspc/ with + * relative paths. + */ + if (is_absolute_path(link_target)) + type = FILE_TYPE_SYMLINK; + else + type = FILE_TYPE_DIRECTORY; + } else if (isdir) type = FILE_TYPE_DIRECTORY; else |