MySQL  8.0.18
Source Code Documentation
binlog_event.h File Reference

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

#include <stdlib.h>
#include <sys/types.h>
#include <zlib.h>
#include <climits>
#include <cstdio>
#include <iostream>
#include "debug_vars.h"
#include "event_reader.h"
#include "my_io.h"
#include <sys/times.h>

Go to the source code of this file.

Classes

class  binary_log::Log_event_footer
 The footer, in the current version of the MySQL server, only contains the checksum algorithm descriptor. More...
 
class  binary_log::Log_event_header
 The Common-Header always has the same form and length within one version of MySQL. More...
 
class  binary_log::Binary_log_event
 This is the abstract base class for binary log events. More...
 
class  binary_log::Unknown_event
 An unknown event should never occur. More...
 

Namespaces

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

Macros

#define SYSTEM_CHARSET_MBMAXLEN   3
 
#define NAME_CHAR_LEN   64 /* Field/table name length */
 
#define NAME_LEN   (NAME_CHAR_LEN * SYSTEM_CHARSET_MBMAXLEN)
 
#define ST_SERVER_VER_SPLIT_LEN   3
 
#define BIN_LOG_HEADER_SIZE   4U
 
#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...
 
#define OVER_MAX_DBS_IN_EVENT_MTS   254
 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...
 
#define MAX_SIZE_LOG_EVENT_STATUS
 Max number of possible extra bytes in a replication event compared to a packet (i.e. More...
 
#define MAX_COMMIT_TIMESTAMP_VALUE   (1ULL << 55)
 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 LOG_EVENT_BINLOG_IN_USE_F   0x1
 
#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 EVENT_TYPE_OFFSET   4
 
#define SERVER_ID_OFFSET   5
 
#define EVENT_LEN_OFFSET   9
 
#define LOG_POS_OFFSET   13
 
#define FLAGS_OFFSET   17
 
#define ST_BINLOG_VER_OFFSET   0
 start event post-header (for v3 and v4) More...
 
#define ST_SERVER_VER_OFFSET   2
 
#define ST_CREATED_OFFSET   (ST_SERVER_VER_OFFSET + ST_SERVER_VER_LEN)
 
#define ST_COMMON_HEADER_LEN_OFFSET   (ST_CREATED_OFFSET + 4)
 
#define LOG_EVENT_HEADER_LEN   19U /* the fixed header length */
 
#define LOG_EVENT_MINIMAL_HEADER_LEN   19U
 Fixed header length, where 4.x and 5.0 agree. More...
 
#define CHECKSUM_CRC32_SIGNATURE_LEN   4
 
#define BINLOG_CHECKSUM_LEN   CHECKSUM_CRC32_SIGNATURE_LEN
 defined statically while there is just one alg implemented More...
 
#define BINLOG_CHECKSUM_ALG_DESC_LEN   1 /* 1 byte checksum alg descriptor */
 
#define LOG_EVENT_HEADER_SIZE   20
 

Enumerations

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

Functions

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...
 
uint32_t binary_log::checksum_crc32 (uint32_t crc, const unsigned char *pos, size_t length)
 Calculate a long checksum for a memoryblock. More...
 

Variables

const int64_t SEQ_UNINIT = 0
 Uninitialized timestamp value (for either last committed or sequence number). More...
 
const int64_t UNDEFINED_COMMIT_TIMESTAMP = MAX_COMMIT_TIMESTAMP_VALUE
 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
 

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

◆ BINLOG_CHECKSUM_ALG_DESC_LEN

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

◆ BINLOG_CHECKSUM_LEN

#define BINLOG_CHECKSUM_LEN   CHECKSUM_CRC32_SIGNATURE_LEN

defined statically while there is just one alg implemented

◆ CHECKSUM_CRC32_SIGNATURE_LEN

#define CHECKSUM_CRC32_SIGNATURE_LEN   4

◆ EVENT_LEN_OFFSET

#define EVENT_LEN_OFFSET   9

◆ EVENT_TYPE_OFFSET

#define EVENT_TYPE_OFFSET   4

◆ FLAGS_OFFSET

#define FLAGS_OFFSET   17

◆ LOG_EVENT_BINLOG_IN_USE_F

#define LOG_EVENT_BINLOG_IN_USE_F   0x1

◆ LOG_EVENT_HEADER_LEN

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

◆ LOG_EVENT_HEADER_SIZE

#define LOG_EVENT_HEADER_SIZE   20

◆ LOG_EVENT_MINIMAL_HEADER_LEN

#define LOG_EVENT_MINIMAL_HEADER_LEN   19U

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.

◆ LOG_POS_OFFSET

#define LOG_POS_OFFSET   13

◆ SERVER_ID_OFFSET

#define SERVER_ID_OFFSET   5

◆ ST_BINLOG_VER_OFFSET

#define ST_BINLOG_VER_OFFSET   0

start event post-header (for v3 and v4)

◆ ST_COMMON_HEADER_LEN_OFFSET

#define ST_COMMON_HEADER_LEN_OFFSET   (ST_CREATED_OFFSET + 4)

◆ ST_CREATED_OFFSET

#define ST_CREATED_OFFSET   (ST_SERVER_VER_OFFSET + ST_SERVER_VER_LEN)

◆ ST_SERVER_VER_LEN

#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

◆ ST_SERVER_VER_OFFSET

#define ST_SERVER_VER_OFFSET   2