1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-18 04:29:09 +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

@@ -188,23 +188,11 @@ FindStreamingStart(uint32 *tli)
/*
* Check if the filename looks like an xlog file, or a .partial file.
* Xlog files are always 24 characters, and .partial files are 32
* characters.
*/
if (strlen(dirent->d_name) == 24)
{
if (strspn(dirent->d_name, "0123456789ABCDEF") != 24)
continue;
if (IsXLogFileName(dirent->d_name))
ispartial = false;
}
else if (strlen(dirent->d_name) == 32)
{
if (strspn(dirent->d_name, "0123456789ABCDEF") != 24)
continue;
if (strcmp(&dirent->d_name[24], ".partial") != 0)
continue;
else if (IsPartialXLogFileName(dirent->d_name))
ispartial = true;
}
else
continue;