diff options
author | Michael Paquier <michael@paquier.xyz> | 2024-08-30 10:42:21 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2024-08-30 10:42:21 +0900 |
commit | 2065ddf5e34ce098f549c4279ee3ab33c188a764 (patch) | |
tree | 1b14e002d791ea030843a3e590ba6db67d9a8ab4 /src/backend/replication/logical/reorderbuffer.c | |
parent | a83a944e9fdd573802c82d961126ba07bfb65f98 (diff) | |
download | postgresql-2065ddf5e34ce098f549c4279ee3ab33c188a764.tar.gz postgresql-2065ddf5e34ce098f549c4279ee3ab33c188a764.zip |
Define PG_REPLSLOT_DIR for path pg_replslot/ in data folder
This commit replaces most of the hardcoded values of "pg_replslot" by a
new PG_REPLSLOT_DIR #define. This makes the style more consistent with
the existing PG_STAT_TMP_DIR, for example. More places will follow a
similar change.
Author: Bertrand Drouvot
Reviewed-by: Ashutosh Bapat, Yugo Nagata, Michael Paquier
Discussion: https://postgr.es/m/ZryVvjqS9SnV1GPP@ip-10-97-1-34.eu-west-3.compute.internal
Diffstat (limited to 'src/backend/replication/logical/reorderbuffer.c')
-rw-r--r-- | src/backend/replication/logical/reorderbuffer.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index d1c4258844f..45b622396e6 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -4595,9 +4595,9 @@ ReorderBufferCleanupSerializedTXNs(const char *slotname) DIR *spill_dir; struct dirent *spill_de; struct stat statbuf; - char path[MAXPGPATH * 2 + 12]; + char path[MAXPGPATH * 2 + sizeof(PG_REPLSLOT_DIR)]; - sprintf(path, "pg_replslot/%s", slotname); + sprintf(path, "%s/%s", PG_REPLSLOT_DIR, slotname); /* we're only handling directories here, skip if it's not ours */ if (lstat(path, &statbuf) == 0 && !S_ISDIR(statbuf.st_mode)) @@ -4610,14 +4610,14 @@ ReorderBufferCleanupSerializedTXNs(const char *slotname) if (strncmp(spill_de->d_name, "xid", 3) == 0) { snprintf(path, sizeof(path), - "pg_replslot/%s/%s", slotname, + "%s/%s/%s", PG_REPLSLOT_DIR, slotname, spill_de->d_name); if (unlink(path) != 0) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not remove file \"%s\" during removal of pg_replslot/%s/xid*: %m", - path, slotname))); + errmsg("could not remove file \"%s\" during removal of %s/%s/xid*: %m", + path, PG_REPLSLOT_DIR, slotname))); } } FreeDir(spill_dir); @@ -4636,7 +4636,8 @@ ReorderBufferSerializedPath(char *path, ReplicationSlot *slot, TransactionId xid XLogSegNoOffsetToRecPtr(segno, 0, wal_segment_size, recptr); - snprintf(path, MAXPGPATH, "pg_replslot/%s/xid-%u-lsn-%X-%X.spill", + snprintf(path, MAXPGPATH, "%s/%s/xid-%u-lsn-%X-%X.spill", + PG_REPLSLOT_DIR, NameStr(MyReplicationSlot->data.name), xid, LSN_FORMAT_ARGS(recptr)); } @@ -4651,8 +4652,8 @@ StartupReorderBuffer(void) DIR *logical_dir; struct dirent *logical_de; - logical_dir = AllocateDir("pg_replslot"); - while ((logical_de = ReadDir(logical_dir, "pg_replslot")) != NULL) + logical_dir = AllocateDir(PG_REPLSLOT_DIR); + while ((logical_de = ReadDir(logical_dir, PG_REPLSLOT_DIR)) != NULL) { if (strcmp(logical_de->d_name, ".") == 0 || strcmp(logical_de->d_name, "..") == 0) |