1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-11-05 04:30:41 +03:00

Add pgLsnFromWalSegment().

Provides the reverse operation for pgLsnToWalSegment().
This commit is contained in:
David Steele
2020-07-08 12:25:39 -04:00
parent a27ff7c335
commit dd9e14b628
4 changed files with 35 additions and 2 deletions

View File

@@ -627,6 +627,23 @@ pgLsnToWalSegment(uint32_t timeline, uint64_t lsn, unsigned int walSegmentSize)
strNewFmt("%08X%08X%08X", timeline, (unsigned int)(lsn >> 32), (unsigned int)(lsn & 0xFFFFFFFF) / walSegmentSize));
}
uint64_t
pgLsnFromWalSegment(const String *walSegment, unsigned int walSegmentSize)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(STRING, walSegment);
FUNCTION_TEST_PARAM(UINT, walSegmentSize);
FUNCTION_TEST_END();
ASSERT(walSegment != NULL);
ASSERT(strSize(walSegment) == 24);
ASSERT(walSegmentSize > 0);
FUNCTION_TEST_RETURN(
(cvtZToUInt64Base(strPtr(strSubN(walSegment, 8, 8)), 16) << 32) +
(cvtZToUInt64Base(strPtr(strSubN(walSegment, 16, 8)), 16) * walSegmentSize));
}
/**********************************************************************************************************************************/
StringList *
pgLsnRangeToWalSegmentList(