1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-30 21:42:05 +03:00

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.
This commit is contained in:
Heikki Linnakangas
2015-05-08 21:58:57 +03:00
parent 16c73e773b
commit 179cdd0981
5 changed files with 31 additions and 29 deletions

View File

@ -3577,8 +3577,7 @@ RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr PriorRedoPtr, XLogRecPtr endptr)
while ((xlde = ReadDir(xldir, XLOGDIR)) != NULL)
{
/* Ignore files that are not XLOG segments */
if (strlen(xlde->d_name) != 24 ||
strspn(xlde->d_name, "0123456789ABCDEF") != 24)
if (!IsXLogFileName(xlde->d_name))
continue;
/*
@ -3650,8 +3649,7 @@ RemoveNonParentXlogFiles(XLogRecPtr switchpoint, TimeLineID newTLI)
while ((xlde = ReadDir(xldir, XLOGDIR)) != NULL)
{
/* Ignore files that are not XLOG segments */
if (strlen(xlde->d_name) != 24 ||
strspn(xlde->d_name, "0123456789ABCDEF") != 24)
if (!IsXLogFileName(xlde->d_name))
continue;
/*
@ -3839,10 +3837,7 @@ CleanupBackupHistory(void)
while ((xlde = ReadDir(xldir, XLOGDIR)) != NULL)
{
if (strlen(xlde->d_name) > 24 &&
strspn(xlde->d_name, "0123456789ABCDEF") == 24 &&
strcmp(xlde->d_name + strlen(xlde->d_name) - strlen(".backup"),
".backup") == 0)
if (IsBackupHistoryFileName(xlde->d_name))
{
if (XLogArchiveCheckDone(xlde->d_name))
{