33#ifndef MYSQL_BINLOG_EVENT_BINLOG_EVENT_H
34#define MYSQL_BINLOG_EVENT_BINLOG_EVENT_H
69#ifndef SYSTEM_CHARSET_MBMAXLEN
70#define SYSTEM_CHARSET_MBMAXLEN 3
73#define NAME_CHAR_LEN 64
76#define NAME_LEN (NAME_CHAR_LEN * SYSTEM_CHARSET_MBMAXLEN)
79#ifndef ST_SERVER_VER_SPLIT_LEN
80#define ST_SERVER_VER_SPLIT_LEN 3
87#ifndef BIN_LOG_HEADER_SIZE
88#define BIN_LOG_HEADER_SIZE 4U
98#define BINLOG_VERSION 4
109#define MAX_DBS_IN_EVENT_MTS 16
116#define OVER_MAX_DBS_IN_EVENT_MTS 254
122#define MAX_TIME_ZONE_NAME_LENGTH (NAME_LEN + 1)
129#define MAX_SIZE_LOG_EVENT_STATUS \
130 (1U + 4 + 1U + 8 + 1U + 1 + \
131 255 + 1U + 4 + 1U + \
133 MAX_TIME_ZONE_NAME_LENGTH + 1U + \
139 (MAX_DBS_IN_EVENT_MTS * (1 + NAME_LEN)) \
140 + 1U + 3 + 1U + 1 + \
153#define MAX_COMMIT_TIMESTAMP_VALUE (1ULL << 55)
164#define LOG_EVENT_IGNORABLE_F 0x80
185 unsigned char split_versions[3]) {
188 unsigned long number;
189 for (
unsigned int i = 0; i <= 2; i++) {
190 number = strtoul(
p, &
r, 10);
195 if (number < 256 && (*
r ==
'.' || i != 0))
196 split_versions[i] =
static_cast<unsigned char>(number);
198 split_versions[0] = 0;
199 split_versions[1] = 0;
200 split_versions[2] = 0;
217 unsigned char version_split[3];
219 const uint32_t ret =
static_cast<uint32_t
>(version_split[0]) * 10000 +
220 static_cast<uint32_t
>(version_split[1]) * 100 +
221 static_cast<uint32_t
>(version_split[2]);
235 return ((version_split[0] * 256 + version_split[1]) * 256 + version_split[2]);
273#define LOG_EVENT_BINLOG_IN_USE_F 0x1
417#define ST_SERVER_VER_LEN 50
423#define EVENT_TYPE_OFFSET 4
424#define SERVER_ID_OFFSET 5
425#define EVENT_LEN_OFFSET 9
426#define LOG_POS_OFFSET 13
427#define FLAGS_OFFSET 17
430#define ST_BINLOG_VER_OFFSET 0
431#define ST_SERVER_VER_OFFSET 2
432#define ST_CREATED_OFFSET (ST_SERVER_VER_OFFSET + ST_SERVER_VER_LEN)
433#define ST_COMMON_HEADER_LEN_OFFSET (ST_CREATED_OFFSET + 4)
435#define LOG_EVENT_HEADER_LEN 19U
449#define LOG_EVENT_MINIMAL_HEADER_LEN 19U
471#define CHECKSUM_CRC32_SIGNATURE_LEN 4
476#define BINLOG_CHECKSUM_LEN CHECKSUM_CRC32_SIGNATURE_LEN
477#define BINLOG_CHECKSUM_ALG_DESC_LEN 1
478#define LOG_EVENT_HEADER_SIZE 20
930 virtual void print_event_info(std::ostream &info) = 0;
934 virtual void print_long_info(std::ostream &info) = 0;
999 void print_event_info(std::ostream &info)
override;
1000 void print_long_info(std::ostream &info)
override;
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
#define ST_SERVER_VER_LEN
The length of the array server_version, which is used to store the version of MySQL server.
Definition: binlog_event.h:417
This is the abstract base class for binary log events.
Definition: binlog_event.h:851
enum_post_header_length
The lengths for the fixed data part of each event.
Definition: binlog_event.h:864
@ QUERY_HEADER_LEN
Definition: binlog_event.h:868
@ APPEND_BLOCK_HEADER_LEN
Definition: binlog_event.h:874
@ IGNORABLE_HEADER_LEN
Definition: binlog_event.h:888
@ TRANSACTION_CONTEXT_HEADER_LEN
Definition: binlog_event.h:890
@ STOP_HEADER_LEN
Definition: binlog_event.h:869
@ FORMAT_DESCRIPTION_HEADER_LEN
Definition: binlog_event.h:878
@ XID_HEADER_LEN
Definition: binlog_event.h:879
@ ROWS_HEADER_LEN_V1
Definition: binlog_event.h:881
@ BEGIN_LOAD_QUERY_HEADER_LEN
Definition: binlog_event.h:880
@ RAND_HEADER_LEN
Definition: binlog_event.h:876
@ QUERY_HEADER_MINIMAL_LEN
Definition: binlog_event.h:866
@ START_V3_HEADER_LEN
Definition: binlog_event.h:870
@ XA_PREPARE_HEADER_LEN
Definition: binlog_event.h:892
@ EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN
Definition: binlog_event.h:883
@ INCIDENT_HEADER_LEN
Definition: binlog_event.h:886
@ USER_VAR_HEADER_LEN
Definition: binlog_event.h:877
@ DELETE_FILE_HEADER_LEN
Definition: binlog_event.h:875
@ ROTATE_HEADER_LEN
Definition: binlog_event.h:872
@ EXECUTE_LOAD_QUERY_HEADER_LEN
Definition: binlog_event.h:884
@ TABLE_MAP_HEADER_LEN
Definition: binlog_event.h:882
@ ROWS_HEADER_LEN_V2
Definition: binlog_event.h:889
@ VIEW_CHANGE_HEADER_LEN
Definition: binlog_event.h:891
@ TRANSACTION_PAYLOAD_HEADER_LEN
Definition: binlog_event.h:893
@ HEARTBEAT_HEADER_LEN
Definition: binlog_event.h:887
@ INTVAR_HEADER_LEN
Definition: binlog_event.h:873
const Log_event_header * header() const
Return a const pointer to the header of the log event.
Definition: binlog_event.h:951
Event_reader & reader()
Returns a reference to the event Event_reader object.
Definition: binlog_event.h:967
Binary_log_event(Log_event_type type_code)
This constructor is used to initialize the type_code of header object m_header.
Definition: binlog_event.h:902
Log_event_footer * footer()
Return a non-const pointer to the footer of the log event.
Definition: binlog_event.h:963
Log_event_header m_header
Definition: binlog_event.h:975
virtual ~Binary_log_event()=0
Log_event_footer m_footer
Definition: binlog_event.h:976
Binary_log_event & operator=(Binary_log_event &&)=default
Binary_log_event(Binary_log_event &&)=default
static const int LOG_EVENT_TYPES
Definition: binlog_event.h:858
Binary_log_event(const Binary_log_event &)=default
Binary_log_event & operator=(const Binary_log_event &)=default
Event_reader m_reader
Definition: binlog_event.h:974
Log_event_header * header()
Return a non-const pointer to the header of the log event.
Definition: binlog_event.h:955
enum Log_event_type get_event_type() const
Helper method.
Definition: binlog_event.h:946
const Log_event_footer * footer() const
Return a const pointer to the footer of the log event.
Definition: binlog_event.h:959
Event_reader class purpose is to avoid out-of-buffer reads when deserializing binary log events and i...
Definition: event_reader.h:74
An unknown event should never occur.
Definition: binlog_event.h:989
Unknown_event()
This is the minimal constructor, and set the type_code as UNKNOWN_EVENT in the header object in Binar...
Definition: binlog_event.h:995
const char * p
Definition: ctype-mb.cc:1225
This header file contains the status of variables used by MySQL tests for debug operations.
Contains the class responsible for deserializing fields of an event previously stored in a buffer.
const unsigned char checksum_version_split[3]
Replication event checksum is introduced in the following "checksum-home" version.
Definition: binlog_event.cpp:33
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....
Definition: binlog_event.h:184
const int64_t UNDEFINED_COMMIT_TIMESTAMP
Used to determine whether the original_commit_timestamp is already known or if it still needs to be d...
Definition: binlog_event.h:158
const int64_t SEQ_UNINIT
Uninitialized timestamp value (for either last committed or sequence number).
Definition: binlog_event.h:150
unsigned long version_product(const unsigned char *version_split)
Calculate the version product from the numeric pieces representing the server version: For a server v...
Definition: binlog_event.h:234
const uint32_t UNKNOWN_SERVER_VERSION
Definition: binlog_event.h:161
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.
Definition: binlog_event.h:216
const unsigned long checksum_version_product
Definition: binlog_event.cpp:34
#define MAX_COMMIT_TIMESTAMP_VALUE
We use 7 bytes, 1 bit being used as a flag.
Definition: binlog_event.h:153
const uint32_t UNDEFINED_SERVER_VERSION
Definition: binlog_event.h:160
Abstraction functions over zlib/intrinsics.
ha_checksum my_checksum(ha_checksum crc, const unsigned char *pos, size_t length)
Calculate a CRC32 checksum for a memoryblock.
Definition: my_checksum.h:117
Common #defines and includes for file and socket I/O.
Definition: buf0block_hint.cc:30
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
bool is_valid(const dd::Spatial_reference_system *srs, const Geometry *g, const char *func_name, bool *is_valid) noexcept
Decides if a geometry is valid.
Definition: is_valid.cc:95
The namespace contains classes representing events that can occur in a replication stream.
Definition: binlog_event.cpp:38
constexpr size_t max_log_event_size
The maximum value for MAX_ALLOWED_PACKET.
Definition: binlog_event.h:440
uint32_t checksum_crc32(uint32_t crc, const unsigned char *pos, size_t length)
Calculate a long checksum for a memoryblock.
Definition: binlog_event.h:489
Log_event_type
Enumeration type for the different types of log events.
Definition: binlog_event.h:278
@ OBSOLETE_UPDATE_ROWS_EVENT_V1
Definition: binlog_event.h:316
@ HEARTBEAT_LOG_EVENT
Heartbeat event to be send by master at its idle time to ensure master's online status to slave.
Definition: binlog_event.h:328
@ HEARTBEAT_LOG_EVENT_V2
Definition: binlog_event.h:364
@ INCIDENT_EVENT
Something out of the ordinary happened on the master.
Definition: binlog_event.h:322
@ FORMAT_DESCRIPTION_EVENT
Definition: binlog_event.h:304
@ BEGIN_LOAD_QUERY_EVENT
Definition: binlog_event.h:306
@ EXECUTE_LOAD_QUERY_EVENT
Definition: binlog_event.h:307
@ OBSOLETE_WRITE_ROWS_EVENT_V1
Definition: binlog_event.h:315
@ XID_EVENT
Definition: binlog_event.h:305
@ ROWS_QUERY_LOG_EVENT
Definition: binlog_event.h:337
@ WRITE_ROWS_EVENT
Version 2 of the Row events.
Definition: binlog_event.h:340
@ DELETE_ROWS_EVENT
Definition: binlog_event.h:342
@ IGNORABLE_LOG_EVENT
In some situations, it is necessary to send over ignorable data to the slave: data that a slave can h...
Definition: binlog_event.h:336
@ XA_PREPARE_LOG_EVENT
Definition: binlog_event.h:354
@ QUERY_EVENT
Definition: binlog_event.h:292
@ VIEW_CHANGE_EVENT
Definition: binlog_event.h:351
@ START_EVENT_V3
Definition: binlog_event.h:291
@ UNKNOWN_EVENT
Every time you add a type, you have to.
Definition: binlog_event.h:286
@ PREVIOUS_GTIDS_LOG_EVENT
Definition: binlog_event.h:347
@ UPDATE_ROWS_EVENT
Definition: binlog_event.h:341
@ RAND_EVENT
Definition: binlog_event.h:302
@ TABLE_MAP_EVENT
Definition: binlog_event.h:309
@ DELETE_FILE_EVENT
Definition: binlog_event.h:300
@ STOP_EVENT
Definition: binlog_event.h:293
@ OBSOLETE_DELETE_ROWS_EVENT_V1
Definition: binlog_event.h:317
@ PARTIAL_UPDATE_ROWS_EVENT
Extension of UPDATE_ROWS_EVENT, allowing partial values according to binlog_row_value_options.
Definition: binlog_event.h:360
@ GTID_LOG_EVENT
Definition: binlog_event.h:344
@ ANONYMOUS_GTID_LOG_EVENT
Definition: binlog_event.h:345
@ TRANSACTION_PAYLOAD_EVENT
Definition: binlog_event.h:362
@ APPEND_BLOCK_EVENT
Definition: binlog_event.h:299
@ INTVAR_EVENT
Definition: binlog_event.h:295
@ USER_VAR_EVENT
Definition: binlog_event.h:303
@ GTID_TAGGED_LOG_EVENT
Definition: binlog_event.h:366
@ ROTATE_EVENT
Definition: binlog_event.h:294
@ SLAVE_EVENT
Definition: binlog_event.h:297
@ ENUM_END_EVENT
Add new events here - right above this comment! Existing events (except ENUM_END_EVENT) should never ...
Definition: binlog_event.h:371
@ TRANSACTION_CONTEXT_EVENT
Definition: binlog_event.h:349
const std::string & get_event_type_as_string(Log_event_type type)
Get the event type as string object.
Definition: binlog_event.cpp:82
enum_binlog_checksum_alg
Enumeration spcifying checksum algorithm used to encode a binary log event.
Definition: binlog_event.h:454
@ BINLOG_CHECKSUM_ALG_OFF
Events are without checksum though its generator is checksum-capable New Master (NM).
Definition: binlog_event.h:459
@ BINLOG_CHECKSUM_ALG_ENUM_END
the cut line: valid alg range is [1, 0x7f]
Definition: binlog_event.h:463
@ BINLOG_CHECKSUM_ALG_UNDEF
Special value to tag undetermined yet checksum or events from checksum-unaware servers.
Definition: binlog_event.h:468
@ BINLOG_CHECKSUM_ALG_CRC32
CRC32 of zlib algorithm.
Definition: binlog_event.h:461
Event_decoding_error
Errors that we distinguish during event decoding, that are translated to specific error returned by t...
Definition: event_decoding_error.h:34
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:86
required uint64 version
Definition: replication_group_member_actions.proto:41
required string type
Definition: replication_group_member_actions.proto:34
Holds basic information about an event: common-header fields, query, etc.
Definition: binlog_event.h:397
Log_event_type event_type
Definition: binlog_event.h:398
const char * query
Definition: binlog_event.h:399
size_t query_length
Definition: binlog_event.h:400
int32_t log_pos
Definition: binlog_event.h:402
int32_t server_id
Definition: binlog_event.h:403
bool ignorable_event
Definition: binlog_event.h:401
Event type helpers, enclosed in the structure.
Definition: binlog_event.h:383
static bool is_any_gtid_event(const Log_event_type &type)
Helps to identify any GTID event - returns true for GTID_LOG_EVENT, GTID_TAGGED_LOG_EVENT and ANONYMO...
Definition: binlog_event.h:391
static bool is_assigned_gtid_event(const Log_event_type &type)
Helps to identify known GTID event - returns true for GTID_LOG_EVENT and GTID_TAGGED_LOG_EVENT.
Definition: binlog_event.h:386
#define BAPI_ASSERT(x)
Definition: wrapper_functions.h:61