MySQL 8.0.40
Source Code Documentation
checksum.cc File Reference

Buffer pool checksum functions, also linked from /extra/innochecksum.cc. More...

#include <sys/types.h>
#include <zlib.h>
#include "buf0buf.h"
#include "buf0types.h"
#include "fil0fil.h"
#include "fil0types.h"
#include "log0log.h"
#include "mach0data.h"
#include "my_dbug.h"
#include "page0size.h"
#include "srv0srv.h"
#include "univ.i"
#include "ut0crc32.h"
#include "ut0rnd.h"

Functions

uint32_t buf_calc_page_crc32 (const byte *page, bool use_legacy_big_endian)
 Calculates the CRC32 checksum of a page. More...
 
uint32_t buf_calc_page_new_checksum (const byte *page)
 Calculates a page checksum which is stored to the page when it is written to a file. More...
 
uint32_t buf_calc_page_old_checksum (const byte *page)
 In versions < 4.0.14 and < 4.1.1 there was a bug that the checksum only looked at the first few bytes of the page. More...
 
const char * buf_checksum_algorithm_name (srv_checksum_algorithm_t algo)
 Return a printable string describing the checksum algorithm. More...
 
void buf_page_lsn_check (bool check_lsn, const byte *read_buf)
 Do lsn checks on a page during innodb recovery. More...
 
std::ostream & operator<< (std::ostream &out, const page_id_t &page_id)
 Print the given page_id_t object. More...
 

Variables

ulong srv_checksum_algorithm = SRV_CHECKSUM_ALGORITHM_INNODB
 the macro MYSQL_SYSVAR_ENUM() requires "long unsigned int" and if we use srv_checksum_algorithm_t here then we get a compiler error: ha_innodb.cc:12251: error: cannot convert 'srv_checksum_algorithm_t*' to 'long unsigned int*' in initialization More...
 
static bool legacy_big_endian_checksum = false
 set if we have found pages matching legacy big endian checksum More...
 

Detailed Description

Buffer pool checksum functions, also linked from /extra/innochecksum.cc.

Created Aug 11, 2011 Vasil Dimov

Function Documentation

◆ buf_calc_page_crc32()

uint32_t buf_calc_page_crc32 ( const byte page,
bool  use_legacy_big_endian 
)

Calculates the CRC32 checksum of a page.

The value is stored to the page when it is written to a file and also checked for a match when reading from the file. When reading we allow both normal CRC32 and CRC-legacy-big-endian variants. Note that we must be careful to calculate the same value on 32-bit and 64-bit architectures.

Parameters
[in]pagebuffer page (UNIV_PAGE_SIZE bytes)
[in]use_legacy_big_endianif true then use big endian byteorder when converting byte strings to integers
Returns
checksum

◆ buf_calc_page_new_checksum()

uint32_t buf_calc_page_new_checksum ( const byte page)

Calculates a page checksum which is stored to the page when it is written to a file.

Note that we must be careful to calculate the same value on 32-bit and 64-bit architectures.

Returns
checksum
Parameters
pagein: buffer page

◆ buf_calc_page_old_checksum()

uint32_t buf_calc_page_old_checksum ( const byte page)

In versions < 4.0.14 and < 4.1.1 there was a bug that the checksum only looked at the first few bytes of the page.

This calculates that old checksum. NOTE: we must first store the new formula checksum to FIL_PAGE_SPACE_OR_CHKSUM before calculating and storing this old checksum because this takes that field as an input!

Returns
checksum
Parameters
pagein: buffer page

◆ buf_checksum_algorithm_name()

const char * buf_checksum_algorithm_name ( srv_checksum_algorithm_t  algo)

Return a printable string describing the checksum algorithm.

Returns
algorithm name
Parameters
algoin: algorithm

◆ buf_page_lsn_check()

void buf_page_lsn_check ( bool  check_lsn,
const byte read_buf 
)
inline

Do lsn checks on a page during innodb recovery.

Parameters
[in]check_lsnif recv_lsn_checks_on & check_lsn perform lsn check
[in]read_bufbuffer containing the page.

◆ operator<<()

std::ostream & operator<< ( std::ostream &  out,
const page_id_t page_id 
)

Print the given page_id_t object.

Parameters
[in,out]outthe output stream
[in]page_idthe page_id_t object to be printed
Returns
the output stream

Variable Documentation

◆ legacy_big_endian_checksum

bool legacy_big_endian_checksum = false
static

set if we have found pages matching legacy big endian checksum

◆ srv_checksum_algorithm

ulong srv_checksum_algorithm = SRV_CHECKSUM_ALGORITHM_INNODB

the macro MYSQL_SYSVAR_ENUM() requires "long unsigned int" and if we use srv_checksum_algorithm_t here then we get a compiler error: ha_innodb.cc:12251: error: cannot convert 'srv_checksum_algorithm_t*' to 'long unsigned int*' in initialization