MySQL 9.1.0
Source Code Documentation
mysql::binlog::event::Binary_log_event Class Referenceabstract

This is the abstract base class for binary log events. More...

#include <binlog_event.h>

Inheritance diagram for mysql::binlog::event::Binary_log_event:
[legend]

Public Types

enum  enum_post_header_length {
  QUERY_HEADER_MINIMAL_LEN = (4 + 4 + 1 + 2) , QUERY_HEADER_LEN = (QUERY_HEADER_MINIMAL_LEN + 2) , STOP_HEADER_LEN = 0 , START_V3_HEADER_LEN = (2 + ST_SERVER_VER_LEN + 4) ,
  ROTATE_HEADER_LEN = 8 , INTVAR_HEADER_LEN = 0 , APPEND_BLOCK_HEADER_LEN = 4 , DELETE_FILE_HEADER_LEN = 4 ,
  RAND_HEADER_LEN = 0 , USER_VAR_HEADER_LEN = 0 , FORMAT_DESCRIPTION_HEADER_LEN = (START_V3_HEADER_LEN + 1 + LOG_EVENT_TYPES) , XID_HEADER_LEN = 0 ,
  BEGIN_LOAD_QUERY_HEADER_LEN = APPEND_BLOCK_HEADER_LEN , ROWS_HEADER_LEN_V1 = 8 , TABLE_MAP_HEADER_LEN = 8 , EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN = (4 + 4 + 4 + 1) ,
  EXECUTE_LOAD_QUERY_HEADER_LEN , INCIDENT_HEADER_LEN = 2 , HEARTBEAT_HEADER_LEN = 0 , IGNORABLE_HEADER_LEN = 0 ,
  ROWS_HEADER_LEN_V2 = 10 , TRANSACTION_CONTEXT_HEADER_LEN = 18 , VIEW_CHANGE_HEADER_LEN = 52 , XA_PREPARE_HEADER_LEN = 0 ,
  TRANSACTION_PAYLOAD_HEADER_LEN = 0
}
 The lengths for the fixed data part of each event. More...
 

Public Member Functions

virtual ~Binary_log_event ()=0
 
 Binary_log_event (const Binary_log_event &)=default
 
 Binary_log_event (Binary_log_event &&)=default
 
Binary_log_eventoperator= (const Binary_log_event &)=default
 
Binary_log_eventoperator= (Binary_log_event &&)=default
 
enum Log_event_type get_event_type () const
 Helper method. More...
 
const Log_event_headerheader () const
 Return a const pointer to the header of the log event. More...
 
Log_event_headerheader ()
 Return a non-const pointer to the header of the log event. More...
 
const Log_event_footerfooter () const
 Return a const pointer to the footer of the log event. More...
 
Log_event_footerfooter ()
 Return a non-const pointer to the footer of the log event. More...
 
Event_readerreader ()
 Returns a reference to the event Event_reader object. More...
 

Static Public Attributes

static const int LOG_EVENT_TYPES = (ENUM_END_EVENT - 1)
 

Protected Member Functions

 Binary_log_event (Log_event_type type_code)
 This constructor is used to initialize the type_code of header object m_header. More...
 
 Binary_log_event (const char **buf, const Format_description_event *fde)
 This constructor will create a new object of Log_event_header and initialize the variable m_header, which in turn will be used to initialize Log_event's member common_header. More...
 

Private Attributes

Event_reader m_reader
 
Log_event_header m_header
 
Log_event_footer m_footer
 

Detailed Description

This is the abstract base class for binary log events.

Binary Format

Any Binary_log_event saved on disk consists of the following four components.

  • Common-Header
  • Post-Header
  • Body
  • Footer

Common header has the same format and length in a given MySQL version. It is documented here.

The Body may be of different format and length even for different events of the same type. The binary formats of Post-Header and Body are documented separately in each subclass.

Footer is common to all the events in a given MySQL version. It is documented here.

  • Some events, used for RBR use a special format for efficient representation of unsigned integers, called Packed Integer. A Packed Integer has the capacity of storing up to 8-byte integers, while small integers still can use 1, 3, or 4 bytes. The value of the first byte determines how to read the number, according to the following table:
Format of Packed Integer
First byte

Format

0-250

The first byte is the number (in the range 0-250), and no more bytes are used.

252

Two more bytes are used. The number is in the range 251-0xffff.

253

Three more bytes are used. The number is in the range 0xffff-0xffffff.

254

Eight more bytes are used. The number is in the range 0xffffff-0xffffffffffffffff.

  • Strings are stored in various formats. The format of each string is documented separately.

Member Enumeration Documentation

◆ enum_post_header_length

The lengths for the fixed data part of each event.

This is an enum that provides post-header lengths for all events.

Enumerator
QUERY_HEADER_MINIMAL_LEN 
QUERY_HEADER_LEN 
STOP_HEADER_LEN 
START_V3_HEADER_LEN 
ROTATE_HEADER_LEN 
INTVAR_HEADER_LEN 
APPEND_BLOCK_HEADER_LEN 
DELETE_FILE_HEADER_LEN 
RAND_HEADER_LEN 
USER_VAR_HEADER_LEN 
FORMAT_DESCRIPTION_HEADER_LEN 
XID_HEADER_LEN 
BEGIN_LOAD_QUERY_HEADER_LEN 
ROWS_HEADER_LEN_V1 
TABLE_MAP_HEADER_LEN 
EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN 
EXECUTE_LOAD_QUERY_HEADER_LEN 
INCIDENT_HEADER_LEN 
HEARTBEAT_HEADER_LEN 
IGNORABLE_HEADER_LEN 
ROWS_HEADER_LEN_V2 
TRANSACTION_CONTEXT_HEADER_LEN 
VIEW_CHANGE_HEADER_LEN 
XA_PREPARE_HEADER_LEN 
TRANSACTION_PAYLOAD_HEADER_LEN 

Constructor & Destructor Documentation

◆ Binary_log_event() [1/4]

mysql::binlog::event::Binary_log_event::Binary_log_event ( Log_event_type  type_code)
inlineexplicitprotected

This constructor is used to initialize the type_code of header object m_header.

We set the type code to ENUM_END_EVENT so that the decoder asserts if event type has not been modified by the sub classes

◆ Binary_log_event() [2/4]

mysql::binlog::event::Binary_log_event::Binary_log_event ( const char **  buf,
const Format_description_event fde 
)
protected

This constructor will create a new object of Log_event_header and initialize the variable m_header, which in turn will be used to initialize Log_event's member common_header.

It will also advance the Event_reader cursor after decoding the header (it is done through the constructor of Log_event_header) and will be pointing to the start of event data.

Parameters
bufContains the serialized event.
fdeAn FDE event used to get checksum information of non FDE events.

◆ ~Binary_log_event()

mysql::binlog::event::Binary_log_event::~Binary_log_event ( )
pure virtualdefault

◆ Binary_log_event() [3/4]

mysql::binlog::event::Binary_log_event::Binary_log_event ( const Binary_log_event )
default

◆ Binary_log_event() [4/4]

mysql::binlog::event::Binary_log_event::Binary_log_event ( Binary_log_event &&  )
default

Member Function Documentation

◆ footer() [1/2]

Log_event_footer * mysql::binlog::event::Binary_log_event::footer ( )
inline

Return a non-const pointer to the footer of the log event.

◆ footer() [2/2]

const Log_event_footer * mysql::binlog::event::Binary_log_event::footer ( ) const
inline

Return a const pointer to the footer of the log event.

◆ get_event_type()

enum Log_event_type mysql::binlog::event::Binary_log_event::get_event_type ( ) const
inline

Helper method.

◆ header() [1/2]

Log_event_header * mysql::binlog::event::Binary_log_event::header ( )
inline

Return a non-const pointer to the header of the log event.

◆ header() [2/2]

const Log_event_header * mysql::binlog::event::Binary_log_event::header ( ) const
inline

Return a const pointer to the header of the log event.

◆ operator=() [1/2]

Binary_log_event & mysql::binlog::event::Binary_log_event::operator= ( Binary_log_event &&  )
default

◆ operator=() [2/2]

Binary_log_event & mysql::binlog::event::Binary_log_event::operator= ( const Binary_log_event )
default

◆ reader()

Event_reader & mysql::binlog::event::Binary_log_event::reader ( )
inline

Returns a reference to the event Event_reader object.

Member Data Documentation

◆ LOG_EVENT_TYPES

const int mysql::binlog::event::Binary_log_event::LOG_EVENT_TYPES = (ENUM_END_EVENT - 1)
static

◆ m_footer

Log_event_footer mysql::binlog::event::Binary_log_event::m_footer
private

◆ m_header

Log_event_header mysql::binlog::event::Binary_log_event::m_header
private

◆ m_reader

Event_reader mysql::binlog::event::Binary_log_event::m_reader
private

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