MySQL 8.3.0
Source Code Documentation
binlog_event.h File Reference

Contains the classes representing events occurring in the replication stream. More...

#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <zlib.h>
#include <climits>
#include <cstdio>
#include <iostream>
#include "my_checksum.h"
#include "my_io.h"
#include "mysql/binlog/event/debug_vars.h"
#include "mysql/binlog/event/event_decoding_error.h"
#include "mysql/binlog/event/event_reader.h"
#include <sys/times.h>

Go to the source code of this file.


struct  mysql::binlog::event::Log_event_type_helper
 Event type helpers, enclosed in the structure. More...
struct  mysql::binlog::event::Log_event_basic_info
 Struct to pass basic information about a event: type, query, is it ignorable. More...
class  mysql::binlog::event::Log_event_footer
 The footer, in the current version of the MySQL server, only contains the checksum algorithm descriptor. More...
class  mysql::binlog::event::Log_event_header
 The Common-Header always has the same form and length within one version of MySQL. More...
class  mysql::binlog::event::Binary_log_event
 This is the abstract base class for binary log events. More...
class  mysql::binlog::event::Unknown_event
 An unknown event should never occur. More...


namespace  mysql::binlog::event
 The namespace contains classes representing events that can occur in a replication stream.
namespace  mysql
namespace  mysql::binlog


#define NAME_CHAR_LEN   64 /* Field/table name length */
#define BINLOG_VERSION   4
 binlog_version 3 is MySQL 4.x; 4 is MySQL 5.0.0. More...
#define MAX_DBS_IN_EVENT_MTS   16
 The maximum number of updated databases that a status of Query-log-event can carry. More...
 When the actual number of databases exceeds MAX_DBS_IN_EVENT_MTS the value of OVER_MAX_DBS_IN_EVENT_MTS is is put into the mts_accessed_dbs status. More...
 Maximum length of time zone name that we support (Time zone name is char(64) in db). More...
 Max number of possible extra bytes in a replication event compared to a packet (i.e. More...
 We use 7 bytes, 1 bit being used as a flag. More...
#define LOG_EVENT_IGNORABLE_F   0x80
 Setting this flag will mark an event as Ignorable. More...
#define ST_SERVER_VER_LEN   50
 The length of the array server_version, which is used to store the version of MySQL server. More...
#define SERVER_ID_OFFSET   5
#define EVENT_LEN_OFFSET   9
#define LOG_POS_OFFSET   13
#define FLAGS_OFFSET   17
 start event post-header (for v3 and v4) More...
#define LOG_EVENT_HEADER_LEN   19U /* the fixed header length */
 Fixed header length, where 4.x and 5.0 agree. More...
 defined statically while there is just one alg implemented More...
#define BINLOG_CHECKSUM_ALG_DESC_LEN   1 /* 1 byte checksum alg descriptor */


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


void do_server_version_split (const char *version, unsigned char split_versions[3])
 In case the variable is updated, make sure to update it in $MYSQL_SOURCE_DIR/my_io.h. More...
uint32_t do_server_version_int (const char *version)
 Transforms the server version from 'XX.YY.ZZ-suffix' into an integer in the format XXYYZZ. More...
unsigned long version_product (const unsigned char *version_split)
 Calculate the version product from the numeric pieces representing the server version: For a server version X.Y.Zabc (X,Y,Z numbers, a not a digit), the input is {X,Y,Z}. More...
const std::string & mysql::binlog::event::get_event_type_as_string (Log_event_type type)
 Get the event type as string object. More...
uint32_t mysql::binlog::event::checksum_crc32 (uint32_t crc, const unsigned char *pos, size_t length)
 Calculate a long checksum for a memoryblock. More...


const int64_t SEQ_UNINIT = 0
 Uninitialized timestamp value (for either last committed or sequence number). More...
 Used to determine whether the original_commit_timestamp is already known or if it still needs to be determined when computing it. More...
const uint32_t UNDEFINED_SERVER_VERSION = 999999
const uint32_t UNKNOWN_SERVER_VERSION = 0
const unsigned char checksum_version_split [3]
 Replication event checksum is introduced in the following "checksum-home" version. More...
const unsigned long checksum_version_product
constexpr size_t mysql::binlog::event::max_log_event_size = 1024 * 1024 * 1024
 The maximum value for MAX_ALLOWED_PACKET. More...

Detailed Description

Contains the classes representing events occurring in the replication stream.

Each event is represented as a byte sequence with logical divisions as event header, event specific data and event footer. The header and footer are common to all the events and are represented as two different subclasses.

Macro Definition Documentation


#define BINLOG_CHECKSUM_ALG_DESC_LEN   1 /* 1 byte checksum alg descriptor */



defined statically while there is just one alg implemented




#define EVENT_LEN_OFFSET   9




#define FLAGS_OFFSET   17




#define LOG_EVENT_HEADER_LEN   19U /* the fixed header length */





Fixed header length, where 4.x and 5.0 agree.

That is, 5.0 may have a longer header (it will for sure when we have the unique event's ID), but at least the first 19 bytes are the same in 4.x and 5.0. So when we have the unique event's ID, LOG_EVENT_HEADER_LEN will be something like 26, but LOG_EVENT_MINIMAL_HEADER_LEN will remain 19.


#define LOG_POS_OFFSET   13


#define SERVER_ID_OFFSET   5



start event post-header (for v3 and v4)






#define ST_SERVER_VER_LEN   50

The length of the array server_version, which is used to store the version of MySQL server.

We could have used SERVER_VERSION_LENGTH, but this introduces an obscure dependency - if somebody decided to change SERVER_VERSION_LENGTH this would break the replication protocol both of these are used to initialize the array server_version SERVER_VERSION_LENGTH is used for global array server_version and ST_SERVER_VER_LEN for the Start_event_v3 member server_version