aboutsummaryrefslogtreecommitdiff
path: root/src/backend/replication/basebackup.c
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2015-05-08 21:58:57 +0300
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2015-05-08 21:58:57 +0300
commit179cdd098196338880bdbb39c39a788abdad4dd8 (patch)
treeba94b277b326f1599d2835f0fe50b791016dd532 /src/backend/replication/basebackup.c
parent16c73e773bc5f2eee6a71c5ec311b8691bf9e832 (diff)
downloadpostgresql-179cdd098196338880bdbb39c39a788abdad4dd8.tar.gz
postgresql-179cdd098196338880bdbb39c39a788abdad4dd8.zip
Add macros to check if a filename is a WAL segment or other such file.
We had many instances of the strlen + strspn combination to check for that. This makes the code a bit easier to read.
Diffstat (limited to 'src/backend/replication/basebackup.c')
-rw-r--r--src/backend/replication/basebackup.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
index 3563fd997fd..de103c6f5b7 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -350,17 +350,14 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
while ((de = ReadDir(dir, "pg_xlog")) != NULL)
{
/* Does it look like a WAL segment, and is it in the range? */
- if (strlen(de->d_name) == 24 &&
- strspn(de->d_name, "0123456789ABCDEF") == 24 &&
+ if (IsXLogFileName(de->d_name) &&
strcmp(de->d_name + 8, firstoff + 8) >= 0 &&
strcmp(de->d_name + 8, lastoff + 8) <= 0)
{
walFileList = lappend(walFileList, pstrdup(de->d_name));
}
/* Does it look like a timeline history file? */
- else if (strlen(de->d_name) == 8 + strlen(".history") &&
- strspn(de->d_name, "0123456789ABCDEF") == 8 &&
- strcmp(de->d_name + 8, ".history") == 0)
+ else if (IsTLHistoryFileName(de->d_name))
{
historyFileList = lappend(historyFileList, pstrdup(de->d_name));
}