/**************************************************//**
@file buf/buf0checksum.cc
Buffer pool checksum functions, also linked from /extra/innochecksum.cc
Created Aug 11, 2011 Vasil Dimov
*******************************************************/
#ifndef UNIV_INNOCHECKSUM # include "srv0srv.h" #endif/* !UNIV_INNOCHECKSUM */
/** Calculate the CRC32 checksum of a page. The value is stored to the page whenitiswrittentoafileandalsocheckedforamatchwhenreadingfrom thefile.Notethatwemustbecarefultocalculatethesamevalueonall architectures. @param[in]pagebufferpage(srv_page_sizebytes)
@return CRC-32C */
uint32_t buf_calc_page_crc32(const byte *page) noexcept
{ /* Note: innodb_checksum_algorithm=crc32 could and should have includedtheentirepageinthechecksum,andCRC-32values shouldbecombinedwiththeCRC-32function,notwith exclusiveOR.Westicktothecurrentalgorithminorderto
remain compatible with old data files. */ return my_crc32c(0, page + FIL_PAGE_OFFSET,
FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION
- FIL_PAGE_OFFSET)
^ my_crc32c(0, page + FIL_PAGE_DATA,
srv_page_size
- (FIL_PAGE_DATA + FIL_PAGE_END_LSN_OLD_CHKSUM));
}
switch (len & 0x7) { case7:
fold= ut_fold_ulint_pair(fold, *str++); /* fall through */ case6:
fold= ut_fold_ulint_pair(fold, *str++); /* fall through */ case5:
fold= ut_fold_ulint_pair(fold, *str++); /* fall through */ case4:
fold= ut_fold_ulint_pair(fold, *str++); /* fall through */ case3:
fold= ut_fold_ulint_pair(fold, *str++); /* fall through */ case2:
fold= ut_fold_ulint_pair(fold, *str++); /* fall through */ case1:
fold= ut_fold_ulint_pair(fold, *str++);
} return fold;
}
/** Calculate a checksum which is stored to the page when it is written toafile.Notethatwemustbecarefultocalculatethesamevalueon 32-bitand64-bitarchitectures. @param[in]pagefilepage(srv_page_sizebytes)
@return checksum */
uint32_t buf_calc_page_new_checksum(const byte *page) noexcept
{
ulint checksum;
/* Since the field FIL_PAGE_FILE_FLUSH_LSN, and in versions <= 4.1.x FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID,arewrittenoutsidethebufferpool tothefirstpagesofdatafiles,wehavetoskiptheminthepage checksumcalculation. WemustalsoskipthefieldFIL_PAGE_SPACE_OR_CHKSUMwherethe checksumisstored,andalsothelast8bytesofpagebecause
there we store the old formula checksum. */
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.