diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2015-05-08 21:58:57 +0300 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2015-05-08 21:58:57 +0300 |
commit | 179cdd098196338880bdbb39c39a788abdad4dd8 (patch) | |
tree | ba94b277b326f1599d2835f0fe50b791016dd532 /src/bin/pg_resetxlog/pg_resetxlog.c | |
parent | 16c73e773bc5f2eee6a71c5ec311b8691bf9e832 (diff) |
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/bin/pg_resetxlog/pg_resetxlog.c')
-rw-r--r-- | src/bin/pg_resetxlog/pg_resetxlog.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/bin/pg_resetxlog/pg_resetxlog.c b/src/bin/pg_resetxlog/pg_resetxlog.c index 4a225757368..393d5801540 100644 --- a/src/bin/pg_resetxlog/pg_resetxlog.c +++ b/src/bin/pg_resetxlog/pg_resetxlog.c @@ -906,14 +906,18 @@ FindEndOfXLOG(void) while (errno = 0, (xlde = readdir(xldir)) != NULL) { - if (strlen(xlde->d_name) == 24 && - strspn(xlde->d_name, "0123456789ABCDEF") == 24) + if (IsXLogFileName(xlde->d_name)) { unsigned int tli, log, seg; XLogSegNo segno; + /* + * Note: We don't use XLogFromFileName here, because we want + * to use the segment size from the control file, not the size + * the pg_resetxlog binary was compiled with + */ sscanf(xlde->d_name, "%08X%08X%08X", &tli, &log, &seg); segno = ((uint64) log) * segs_per_xlogid + seg; |