mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-12 10:04:14 +02:00
Remove invalid const in pgPageChecksum() parameter.
pgPageChecksum() must modify the page header in order to calculate the checksum. The modification is temporary but make it clear that it happens by removing the const. Also make a note about our non-entirely-kosher usage of a const Buffer in the PageChecksum filter. This is safe as currently coded but at the least we need to be aware of what is going on.
This commit is contained in:
parent
4ab8943ca8
commit
77853d3c13
@ -6,14 +6,14 @@ MODULE = pgBackRest::LibC PACKAGE = pgBackRest::LibC
|
||||
|
||||
U16
|
||||
pgPageChecksum(page, blockNo)
|
||||
const char *page
|
||||
unsigned char *page
|
||||
U32 blockNo
|
||||
CODE:
|
||||
RETVAL = 0;
|
||||
|
||||
ERROR_XS_BEGIN()
|
||||
{
|
||||
RETVAL = pgPageChecksum((const unsigned char *)page, blockNo);
|
||||
RETVAL = pgPageChecksum(page, blockNo);
|
||||
}
|
||||
ERROR_XS_END();
|
||||
OUTPUT:
|
||||
|
@ -95,6 +95,10 @@ pageChecksumProcess(THIS_VOID, const Buffer *input)
|
||||
{
|
||||
for (unsigned int pageIdx = 0; pageIdx < pageTotal; pageIdx++)
|
||||
{
|
||||
// Get a non-const pointer which is required by pgPageChecksumTest() below. ??? This is not entirely kosher since we are
|
||||
// being passed a const buffer and we should deinitely not be modifying the contents. When pgPageChecksumTest() returns
|
||||
// the data should be the same, but there's no question that some munging occurs. Should we make a copy of the page
|
||||
// before passing it into pgPageChecksumTest()?
|
||||
unsigned char *pagePtr = bufPtr(input) + (pageIdx * PG_PAGE_SIZE_DEFAULT);
|
||||
unsigned int pageNo = this->pageNoOffset + pageIdx;
|
||||
size_t pageSize = this->align || pageIdx < pageTotal - 1 ? PG_PAGE_SIZE_DEFAULT : pageRemainder;
|
||||
|
@ -101,7 +101,7 @@ do { \
|
||||
} while (0)
|
||||
|
||||
static uint32_t
|
||||
pageChecksumBlock(const unsigned char *page)
|
||||
pageChecksumBlock(unsigned char *page)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM_P(UCHARDATA, page);
|
||||
@ -141,7 +141,7 @@ The checksum includes the block number (to detect the case where a page is someh
|
||||
(excluding the checksum itself), and the page data.
|
||||
***********************************************************************************************************************************/
|
||||
uint16_t
|
||||
pgPageChecksum(const unsigned char *page, unsigned int blockNo)
|
||||
pgPageChecksum(unsigned char *page, unsigned int blockNo)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM_P(UCHARDATA, page);
|
||||
@ -184,7 +184,7 @@ pageChecksumTest - test if checksum is valid for a single page
|
||||
***********************************************************************************************************************************/
|
||||
bool
|
||||
pgPageChecksumTest(
|
||||
const unsigned char *page, unsigned int blockNo, unsigned int pageSize, uint32_t ignoreWalId, uint32_t ignoreWalOffset)
|
||||
unsigned char *page, unsigned int blockNo, unsigned int pageSize, uint32_t ignoreWalId, uint32_t ignoreWalOffset)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM_P(UCHARDATA, page);
|
||||
|
@ -9,9 +9,9 @@ Checksum Implementation for Data Pages
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
***********************************************************************************************************************************/
|
||||
uint16_t pgPageChecksum(const unsigned char *page, unsigned int blockNo);
|
||||
uint16_t pgPageChecksum(unsigned char *page, unsigned int blockNo);
|
||||
uint64_t pgPageLsn(const unsigned char *page);
|
||||
bool pgPageChecksumTest(
|
||||
const unsigned char *page, unsigned int blockNo, unsigned int pageSize, uint32_t ignoreWalId, uint32_t ignoreWalOffset);
|
||||
unsigned char *page, unsigned int blockNo, unsigned int pageSize, uint32_t ignoreWalId, uint32_t ignoreWalOffset);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user