MySQL 8.0.40
Source Code Documentation
binary_log::Log_event_footer Class Reference

The footer, in the current version of the MySQL server, only contains the checksum algorithm descriptor. More...

#include <binlog_event.h>

Public Member Functions

 Log_event_footer ()
 
 Log_event_footer (Event_reader &reader, Log_event_type event_type, const Format_description_event *fde)
 This ctor will create a new object of Log_event_footer, and will adjust the event reader buffer size with respect to CRC usage. More...
 
 Log_event_footer (enum_binlog_checksum_alg checksum_alg_arg)
 

Static Public Member Functions

static enum_binlog_checksum_alg get_checksum_alg (Event_reader &reader)
 Wrapper to call get_checksum_alg(const char *, ulong) function based on the event reader object (which knows both buffer and buffer length). More...
 
static enum_binlog_checksum_alg get_checksum_alg (const char *buf, unsigned long len)
 The method returns the checksum algorithm used to checksum the binary log from a Format Description Event serialized buffer. More...
 
static bool event_checksum_test (unsigned char *buf, unsigned long event_len, enum_binlog_checksum_alg alg)
 Tests the checksum algorithm used for the binary log, and asserts in case if the checksum algorithm is invalid. More...
 

Public Attributes

enum_binlog_checksum_alg checksum_alg
 

Detailed Description

The footer, in the current version of the MySQL server, only contains the checksum algorithm descriptor.

The descriptor is contained in the FDE of the binary log. This is common for all the events contained in that binary log, and defines the algorithm used to checksum the events contained in the binary log.

The footer contains the following:

Common-Footer
Name Format

Description

checkusm_alg enum_checksum_alg

Algorithm used to checksum the events contained in the binary log

Note
checksum value is not generated with the event. On master's side, it is calculated right before writing the event into the binary log. The data_written field of the event is adjusted (+BINLOG_CHECKSUM_LEN) to consider the checksum value as part of the event. On reading the event, if the Format Description Event (FDE) used when serializing the event tells that the events have checksum information, the checksum value can be retrieved from a particular offset of the serialized event buffer (event length - BINLOG_CHECKSUM_LEN) and checked for corruption by computing a new value over the event buffer. It is not required after that. Therefore, the checksum value is not required to be stored in the instance as a class member.

Constructor & Destructor Documentation

◆ Log_event_footer() [1/3]

binary_log::Log_event_footer::Log_event_footer ( )
inline

◆ Log_event_footer() [2/3]

binary_log::Log_event_footer::Log_event_footer ( Event_reader reader,
Log_event_type  event_type,
const Format_description_event fde 
)

This ctor will create a new object of Log_event_footer, and will adjust the event reader buffer size with respect to CRC usage.

Parameters
readerthe Event_reader containing the serialized event (including header, event data and optional checksum information).
event_typethe type of the event the footer belongs to.
fdeAn FDE event, used to get information about CRC.

◆ Log_event_footer() [3/3]

binary_log::Log_event_footer::Log_event_footer ( enum_binlog_checksum_alg  checksum_alg_arg)
inlineexplicit

Member Function Documentation

◆ event_checksum_test()

bool binary_log::Log_event_footer::event_checksum_test ( unsigned char *  event_buf,
unsigned long  event_len,
enum_binlog_checksum_alg  alg 
)
static

Tests the checksum algorithm used for the binary log, and asserts in case if the checksum algorithm is invalid.

Parameters
event_bufpoint to the buffer containing serialized event
event_lenlength of the event accounting possible checksum alg
algchecksum algorithm used for the binary log
Return values
trueif test fails
falseas success

◆ get_checksum_alg() [1/2]

enum_binlog_checksum_alg binary_log::Log_event_footer::get_checksum_alg ( const char *  buf,
unsigned long  len 
)
static

The method returns the checksum algorithm used to checksum the binary log from a Format Description Event serialized buffer.

The method returns the checksum algorithm used to checksum the binary log.

For MySQL server versions < 5.6, the algorithm is undefined.

Parameters
bufbuffer holding serialized FD event.
lenlength of the event buffer.
Return values
BINLOG_CHECKSUM_ALG_UNDEForiginator is checksum-unaware (effectively no checksum).
BINLOG_CHECKSUM_ALG_OFFno checksum.
otherthe actual checksum algorithm descriptor.

For MySQL server versions < 5.6, the algorithm is undefined. For the higher versions, the type is decoded from the FORMAT_DESCRIPTION_EVENT.

Parameters
bufbuffer holding serialized FD event
lennetto (possible checksum is stripped off) length of the event buf
Returns
the version-safe checksum alg descriptor where zero designates no checksum, 255 - the orginator is checksum-unaware (effectively no checksum) and the actual [1-254] range alg descriptor.

◆ get_checksum_alg() [2/2]

enum_binlog_checksum_alg binary_log::Log_event_footer::get_checksum_alg ( Event_reader reader)
static

Wrapper to call get_checksum_alg(const char *, ulong) function based on the event reader object (which knows both buffer and buffer length).

Parameters
[in]readerThe Event_reader object associated to the event buffer of the FD event.
Return values
BINLOG_CHECKSUM_ALG_UNDEForiginator is checksum-unaware (effectively no checksum).
BINLOG_CHECKSUM_ALG_OFFno checksum.
otherthe actual checksum algorithm descriptor.

Member Data Documentation

◆ checksum_alg

enum_binlog_checksum_alg binary_log::Log_event_footer::checksum_alg
Master side:
The value is set by caller of FD(Format Description) constructor
In the FD case it's propagated into the last byte
of post_header_len[].
Slave side:
On the slave side the value is assigned from post_header_len[last]
of the last seen FD event.

TODO(WL#7546): Revisit this comment when encoder is moved in libbinlogevent


The documentation for this class was generated from the following files: