MySQL 8.0.37
Source Code Documentation
binary_log Namespace Reference

The namespace contains classes representing events that can occur in a replication stream. More...

Namespaces

namespace  codecs
 
namespace  gtids
 
namespace  transaction
 

Classes

class  Append_block_event
 This event is created to contain the file data. More...
 
class  Begin_load_query_event
 Event for the first block of file to be loaded, its only difference from Append_block event is that this event creates or truncates existing file before writing data. More...
 
class  Binary_log_event
 This is the abstract base class for binary log events. More...
 
class  Delete_file_event
 DELETE_FILE_EVENT occurs when the LOAD DATA failed on the master. More...
 
class  Delete_rows_event
 Log row deletions. More...
 
class  Event_reader
 Event_reader class purpose is to avoid out-of-buffer reads when deserializing binary log events and increase robustness when dealing with corrupted event buffers. More...
 
class  Execute_load_query_event
 Event responsible for LOAD DATA execution, it similar to Query_event but before executing the query it substitutes original filename in LOAD DATA query with name of temporary file. More...
 
class  Format_description_event
 For binlog version 4. More...
 
class  Gtid_event
 GTID stands for Global Transaction IDentifier It is composed of two parts: More...
 
struct  gtid_info
 Structure to hold the members declared in the class Gtid_log_event those member are objects of classes defined in server(rpl_gtid.h). More...
 
struct  Hash_Uuid
 
class  Heartbeat_event
 Replication event to ensure to replica that source is alive. More...
 
class  Heartbeat_event_v2
 Replication event to ensure to replica that source is alive. More...
 
class  Ignorable_event
 Base class for ignorable log events. More...
 
class  Incident_event
 Class representing an incident, an occurrence out of the ordinary, that happened on the master. More...
 
class  Intvar_event
 An Intvar_event will be created just before a Query_event, if the query uses one of the variables LAST_INSERT_ID or INSERT_ID. More...
 
struct  Log_event_basic_info
 Struct to pass basic information about a event: type, query, is it ignorable. More...
 
class  Log_event_footer
 The footer, in the current version of the MySQL server, only contains the checksum algorithm descriptor. More...
 
class  Log_event_header
 The Common-Header always has the same form and length within one version of MySQL. More...
 
class  Previous_gtids_event
 
class  Query_event
 A Query_event is created for each query that modifies the database, unless the query is logged row-based. More...
 
class  Rand_event
 Logs random seed used by the next RAND(), and by PASSWORD() in 4.1.0. More...
 
class  Rotate_event
 When a binary log file exceeds a size limit, a ROTATE_EVENT is written at the end of the file that points to the next file in the sequence. More...
 
class  Rows_event
 Common base class for all row-containing binary log events. More...
 
class  Rows_query_event
 Rows query event type, which is a subclass of the Ignorable_event, to record the original query for the rows events in RBR. More...
 
class  Stop_event
 A stop event is written to the log files under these circumstances: More...
 
class  Table_map_event
 In row-based mode, every row operation event is preceded by a Table_map_event which maps a table definition to a number. More...
 
class  Transaction_context_event
 This class is used to combine the information of the ongoing transaction including the write set and other information of the thread executing the transaction. More...
 
class  Transaction_payload_event
 Event that encloses all the events of a transaction. More...
 
class  Unknown_event
 An unknown event should never occur. More...
 
class  Update_rows_event
 Log row updates with a before image. More...
 
class  User_var_event
 Written every time a statement uses a user variable; precedes other events for the statement. More...
 
struct  Uuid
 This is a POD. More...
 
class  View_change_event
 This class is used to add view change markers in the binary log when a member of the group enters or leaves the group. More...
 
class  Write_rows_event
 Log row insertions. More...
 
class  XA_prepare_event
 An XA_prepare event is generated for a XA prepared transaction. More...
 
class  Xid_event
 An XID event is generated for a commit of a transaction that modifies one or more tables of an XA-capable storage engine. More...
 

Enumerations

enum  Log_event_type {
  UNKNOWN_EVENT = 0 , START_EVENT_V3 = 1 , QUERY_EVENT = 2 , STOP_EVENT = 3 ,
  ROTATE_EVENT = 4 , INTVAR_EVENT = 5 , SLAVE_EVENT = 7 , APPEND_BLOCK_EVENT = 9 ,
  DELETE_FILE_EVENT = 11 , RAND_EVENT = 13 , USER_VAR_EVENT = 14 , FORMAT_DESCRIPTION_EVENT = 15 ,
  XID_EVENT = 16 , BEGIN_LOAD_QUERY_EVENT = 17 , EXECUTE_LOAD_QUERY_EVENT = 18 , TABLE_MAP_EVENT = 19 ,
  WRITE_ROWS_EVENT_V1 = 23 , UPDATE_ROWS_EVENT_V1 = 24 , DELETE_ROWS_EVENT_V1 = 25 , INCIDENT_EVENT = 26 ,
  HEARTBEAT_LOG_EVENT = 27 , IGNORABLE_LOG_EVENT = 28 , ROWS_QUERY_LOG_EVENT = 29 , WRITE_ROWS_EVENT = 30 ,
  UPDATE_ROWS_EVENT = 31 , DELETE_ROWS_EVENT = 32 , GTID_LOG_EVENT = 33 , ANONYMOUS_GTID_LOG_EVENT = 34 ,
  PREVIOUS_GTIDS_LOG_EVENT = 35 , TRANSACTION_CONTEXT_EVENT = 36 , VIEW_CHANGE_EVENT = 37 , XA_PREPARE_LOG_EVENT = 38 ,
  PARTIAL_UPDATE_ROWS_EVENT = 39 , TRANSACTION_PAYLOAD_EVENT = 40 , HEARTBEAT_LOG_EVENT_V2 = 41 , ENUM_END_EVENT
}
 Enumeration type for the different types of log events. More...
 
enum  enum_binlog_checksum_alg { BINLOG_CHECKSUM_ALG_OFF = 0 , BINLOG_CHECKSUM_ALG_CRC32 = 1 , BINLOG_CHECKSUM_ALG_ENUM_END , BINLOG_CHECKSUM_ALG_UNDEF = 255 }
 Enumeration spcifying checksum algorithm used to encode a binary log event. More...
 
enum  enum_load_dup_handling { LOAD_DUP_ERROR = 0 , LOAD_DUP_IGNORE , LOAD_DUP_REPLACE }
 Elements of this enum describe how LOAD DATA handles duplicates. More...
 

Functions

uint32_t checksum_crc32 (uint32_t crc, const unsigned char *pos, size_t length)
 Calculate a long checksum for a memoryblock. More...
 
template<class T >
available_buffer (const char *buf_start, const char *buf_current, T buf_len)
 
template<class T >
bool valid_buffer_range (T jump, const char *buf_start, const char *buf_current, T buf_len)
 Check if jump value is within buffer limits. More...
 
bool operator== (const Uuid &a, const Uuid &b)
 
static void parse_signedness (std::vector< bool > &vec, Event_reader &reader_obj, unsigned int length)
 Parses SIGNEDNESS field. More...
 
static void parse_default_charset (Table_map_event::Optional_metadata_fields::Default_charset &default_charset, Event_reader &reader_obj, unsigned int length)
 Parses DEFAULT_CHARSET field. More...
 
static void parse_column_charset (std::vector< unsigned int > &vec, Event_reader &reader_obj, unsigned int length)
 Parses COLUMN_CHARSET field. More...
 
static void parse_column_name (std::vector< std::string > &vec, Event_reader &reader_obj, unsigned int length)
 Parses COLUMN_NAME field. More...
 
static void parse_set_str_value (std::vector< Table_map_event::Optional_metadata_fields::str_vector > &vec, Event_reader &reader_obj, unsigned int length)
 Parses SET_STR_VALUE/ENUM_STR_VALUE field. More...
 
static void parse_geometry_type (std::vector< unsigned int > &vec, Event_reader &reader_obj, unsigned int length)
 Parses GEOMETRY_TYPE field. More...
 
static void parse_simple_pk (std::vector< Table_map_event::Optional_metadata_fields::uint_pair > &vec, Event_reader &reader_obj, unsigned int length)
 Parses SIMPLE_PRIMARY_KEY field. More...
 
static void parse_pk_with_prefix (std::vector< Table_map_event::Optional_metadata_fields::uint_pair > &vec, Event_reader &reader_obj, unsigned int length)
 Parses PRIMARY_KEY_WITH_PREFIX field. More...
 
static void parse_column_visibility (std::vector< bool > *vec, Event_reader &reader_obj, unsigned int length)
 Parses column visibility attribute. More...
 
static void copy_str_and_move (Log_event_header::Byte **dst, const char **src, size_t len)
 Utility function for the Query_event constructor. More...
 

Variables

constexpr size_t max_log_event_size = 1024 * 1024 * 1024
 The maximum value for MAX_ALLOWED_PACKET. More...
 
const uint64_t INVALID_XID = 0xffffffffffffffffULL
 The following constant represents the maximum of MYSQL_XID domain. More...
 

Detailed Description

The namespace contains classes representing events that can occur in a replication stream.

Enumeration Type Documentation

◆ enum_binlog_checksum_alg

Enumeration spcifying checksum algorithm used to encode a binary log event.

Enumerator
BINLOG_CHECKSUM_ALG_OFF 

Events are without checksum though its generator is checksum-capable New Master (NM).

BINLOG_CHECKSUM_ALG_CRC32 

CRC32 of zlib algorithm.

BINLOG_CHECKSUM_ALG_ENUM_END 

the cut line: valid alg range is [1, 0x7f]

BINLOG_CHECKSUM_ALG_UNDEF 

Special value to tag undetermined yet checksum or events from checksum-unaware servers.

◆ enum_load_dup_handling

Elements of this enum describe how LOAD DATA handles duplicates.

Enumerator
LOAD_DUP_ERROR 
LOAD_DUP_IGNORE 
LOAD_DUP_REPLACE 

◆ Log_event_type

Enumeration type for the different types of log events.

Enumerator
UNKNOWN_EVENT 

Every time you add a type, you have to.

  • Assign it a number explicitly. Otherwise it will cause trouble if a event type before is deprecated and removed directly from the enum.
  • Fix Format_description_event::Format_description_event().
START_EVENT_V3 
QUERY_EVENT 
STOP_EVENT 
ROTATE_EVENT 
INTVAR_EVENT 
SLAVE_EVENT 
APPEND_BLOCK_EVENT 
DELETE_FILE_EVENT 
RAND_EVENT 
USER_VAR_EVENT 
FORMAT_DESCRIPTION_EVENT 
XID_EVENT 
BEGIN_LOAD_QUERY_EVENT 
EXECUTE_LOAD_QUERY_EVENT 
TABLE_MAP_EVENT 
WRITE_ROWS_EVENT_V1 

The V1 event numbers are used from 5.1.16 until mysql-5.6.

UPDATE_ROWS_EVENT_V1 
DELETE_ROWS_EVENT_V1 
INCIDENT_EVENT 

Something out of the ordinary happened on the master.

HEARTBEAT_LOG_EVENT 

Heartbeat event to be send by master at its idle time to ensure master's online status to slave.

IGNORABLE_LOG_EVENT 

In some situations, it is necessary to send over ignorable data to the slave: data that a slave can handle in case there is code for handling it, but which can be ignored if it is not recognized.

ROWS_QUERY_LOG_EVENT 
WRITE_ROWS_EVENT 

Version 2 of the Row events.

UPDATE_ROWS_EVENT 
DELETE_ROWS_EVENT 
GTID_LOG_EVENT 
ANONYMOUS_GTID_LOG_EVENT 
PREVIOUS_GTIDS_LOG_EVENT 
TRANSACTION_CONTEXT_EVENT 
VIEW_CHANGE_EVENT 
XA_PREPARE_LOG_EVENT 
PARTIAL_UPDATE_ROWS_EVENT 

Extension of UPDATE_ROWS_EVENT, allowing partial values according to binlog_row_value_options.

TRANSACTION_PAYLOAD_EVENT 
HEARTBEAT_LOG_EVENT_V2 
ENUM_END_EVENT 

Add new events here - right above this comment! Existing events (except ENUM_END_EVENT) should never change their numbers.

Function Documentation

◆ available_buffer()

template<class T >
T binary_log::available_buffer ( const char *  buf_start,
const char *  buf_current,
buf_len 
)

◆ checksum_crc32()

uint32_t binary_log::checksum_crc32 ( uint32_t  crc,
const unsigned char *  pos,
size_t  length 
)
inline

Calculate a long checksum for a memoryblock.

Parameters
crcstart value for crc
pospointer to memory block
lengthlength of the block
Returns
checksum for a memory block

◆ copy_str_and_move()

static void binary_log::copy_str_and_move ( Log_event_header::Byte **  dst,
const char **  src,
size_t  len 
)
static

Utility function for the Query_event constructor.

The function copies n bytes from the source string and moves the destination pointer by the number of bytes copied.

Parameters
dstPointer to the buffer into which the string is to be copied
srcSource string
lenThe number of bytes to be copied

◆ operator==()

bool binary_log::operator== ( const Uuid a,
const Uuid b 
)
inline

◆ parse_column_charset()

static void binary_log::parse_column_charset ( std::vector< unsigned int > &  vec,
Event_reader reader_obj,
unsigned int  length 
)
static

Parses COLUMN_CHARSET field.

Parameters
[out]vecstores collation numbers extracted from field.
[in]reader_objthe Event_reader object containing the serialized field.
[in]lengthlength of the field

◆ parse_column_name()

static void binary_log::parse_column_name ( std::vector< std::string > &  vec,
Event_reader reader_obj,
unsigned int  length 
)
static

Parses COLUMN_NAME field.

Parameters
[out]vecstores column names extracted from field.
[in]reader_objthe Event_reader object containing the serialized field.
[in]lengthlength of the field

◆ parse_column_visibility()

static void binary_log::parse_column_visibility ( std::vector< bool > *  vec,
Event_reader reader_obj,
unsigned int  length 
)
static

Parses column visibility attribute.

Parameters
[out]vecStores the column visibility extracted from the field.
[in]reader_objthe Event_reader object containing the serialized field.
[in]lengthlength of the field

◆ parse_default_charset()

static void binary_log::parse_default_charset ( Table_map_event::Optional_metadata_fields::Default_charset default_charset,
Event_reader reader_obj,
unsigned int  length 
)
static

Parses DEFAULT_CHARSET field.

Parameters
[out]default_charsetstores collation numbers extracted from field.
[in]reader_objthe Event_reader object containing the serialized field.
[in]lengthlength of the field

◆ parse_geometry_type()

static void binary_log::parse_geometry_type ( std::vector< unsigned int > &  vec,
Event_reader reader_obj,
unsigned int  length 
)
static

Parses GEOMETRY_TYPE field.

Parameters
[out]vecstores geometry column's types extracted from field.
[in]reader_objthe Event_reader object containing the serialized field.
[in]lengthlength of the field

◆ parse_pk_with_prefix()

static void binary_log::parse_pk_with_prefix ( std::vector< Table_map_event::Optional_metadata_fields::uint_pair > &  vec,
Event_reader reader_obj,
unsigned int  length 
)
static

Parses PRIMARY_KEY_WITH_PREFIX field.

Parameters
[out]vecstores primary key's column information extracted from field. Each column has an index and a prefix which are stored as a unit_pair.
[in]reader_objthe Event_reader object containing the serialized field.
[in]lengthlength of the field

◆ parse_set_str_value()

static void binary_log::parse_set_str_value ( std::vector< Table_map_event::Optional_metadata_fields::str_vector > &  vec,
Event_reader reader_obj,
unsigned int  length 
)
static

Parses SET_STR_VALUE/ENUM_STR_VALUE field.

Parameters
[out]vecstores SET/ENUM column's string values extracted from field. Each SET/ENUM column's string values are stored into a string separate vector. All of them are stored in 'vec'.
[in]reader_objthe Event_reader object containing the serialized field.
[in]lengthlength of the field

◆ parse_signedness()

static void binary_log::parse_signedness ( std::vector< bool > &  vec,
Event_reader reader_obj,
unsigned int  length 
)
static

Parses SIGNEDNESS field.

Parameters
[out]vecstores the signedness flags extracted from field.
[in]reader_objthe Event_reader object containing the serialized field.
[in]lengthlength of the field

◆ parse_simple_pk()

static void binary_log::parse_simple_pk ( std::vector< Table_map_event::Optional_metadata_fields::uint_pair > &  vec,
Event_reader reader_obj,
unsigned int  length 
)
static

Parses SIMPLE_PRIMARY_KEY field.

Parameters
[out]vecstores primary key's column information extracted from field. Each column has an index and a prefix which are stored as a unit_pair. prefix is always 0 for SIMPLE_PRIMARY_KEY field.
[in]reader_objthe Event_reader object containing the serialized field.
[in]lengthlength of the field

◆ valid_buffer_range()

template<class T >
bool binary_log::valid_buffer_range ( jump,
const char *  buf_start,
const char *  buf_current,
buf_len 
)

Check if jump value is within buffer limits.

Parameters
jumpNumber of positions we want to advance.
buf_startPointer to buffer start
buf_currentPointer to the current position on buffer.
buf_lenBuffer length.
Return values
TrueIf jump value is within buffer limits.
FalseOtherwise.

Variable Documentation

◆ INVALID_XID

const uint64_t binary_log::INVALID_XID = 0xffffffffffffffffULL

The following constant represents the maximum of MYSQL_XID domain.

The maximum XID value practically is never supposed to grow beyond UINT64 range.

◆ max_log_event_size

constexpr size_t binary_log::max_log_event_size = 1024 * 1024 * 1024
constexpr

The maximum value for MAX_ALLOWED_PACKET.

This is also the maxmium size of binlog events, and dump threads always use this value for max_allowed_packet.