36#ifndef BINLOG_EVENT_INCLUDED
37#define BINLOG_EVENT_INCLUDED
66#ifndef SYSTEM_CHARSET_MBMAXLEN
67#define SYSTEM_CHARSET_MBMAXLEN 3
70#define NAME_CHAR_LEN 64
73#define NAME_LEN (NAME_CHAR_LEN * SYSTEM_CHARSET_MBMAXLEN)
76#ifndef ST_SERVER_VER_SPLIT_LEN
77#define ST_SERVER_VER_SPLIT_LEN 3
84#ifndef BIN_LOG_HEADER_SIZE
85#define BIN_LOG_HEADER_SIZE 4U
95#define BINLOG_VERSION 4
106#define MAX_DBS_IN_EVENT_MTS 16
113#define OVER_MAX_DBS_IN_EVENT_MTS 254
119#define MAX_TIME_ZONE_NAME_LENGTH (NAME_LEN + 1)
126#define MAX_SIZE_LOG_EVENT_STATUS \
127 (1U + 4 + 1U + 8 + 1U + 1 + \
128 255 + 1U + 4 + 1U + \
130 MAX_TIME_ZONE_NAME_LENGTH + 1U + \
136 (MAX_DBS_IN_EVENT_MTS * (1 + NAME_LEN)) \
137 + 1U + 3 + 1U + 1 + \
150#define MAX_COMMIT_TIMESTAMP_VALUE (1ULL << 55)
161#define LOG_EVENT_IGNORABLE_F 0x80
182 unsigned char split_versions[3]) {
185 unsigned long number;
186 for (
unsigned int i = 0; i <= 2; i++) {
187 number = strtoul(
p, &
r, 10);
192 if (number < 256 && (*
r ==
'.' || i != 0))
193 split_versions[i] =
static_cast<unsigned char>(number);
195 split_versions[0] = 0;
196 split_versions[1] = 0;
197 split_versions[2] = 0;
214 unsigned char version_split[3];
216 uint32_t ret =
static_cast<uint32_t
>(version_split[0]) * 10000 +
217 static_cast<uint32_t
>(version_split[1]) * 100 +
218 static_cast<uint32_t
>(version_split[2]);
232 return ((version_split[0] * 256 + version_split[1]) * 256 + version_split[2]);
270#define LOG_EVENT_BINLOG_IN_USE_F 0x1
403#define ST_SERVER_VER_LEN 50
409#define EVENT_TYPE_OFFSET 4
410#define SERVER_ID_OFFSET 5
411#define EVENT_LEN_OFFSET 9
412#define LOG_POS_OFFSET 13
413#define FLAGS_OFFSET 17
416#define ST_BINLOG_VER_OFFSET 0
417#define ST_SERVER_VER_OFFSET 2
418#define ST_CREATED_OFFSET (ST_SERVER_VER_OFFSET + ST_SERVER_VER_LEN)
419#define ST_COMMON_HEADER_LEN_OFFSET (ST_CREATED_OFFSET + 4)
421#define LOG_EVENT_HEADER_LEN 19U
435#define LOG_EVENT_MINIMAL_HEADER_LEN 19U
457#define CHECKSUM_CRC32_SIGNATURE_LEN 4
462#define BINLOG_CHECKSUM_LEN CHECKSUM_CRC32_SIGNATURE_LEN
463#define BINLOG_CHECKSUM_ALG_DESC_LEN 1
464#define LOG_EVENT_HEADER_SIZE 20
485class Format_description_event;
905 virtual void print_event_info(std::ostream &
info) = 0;
909 virtual void print_long_info(std::ostream &
info) = 0;
974 void print_event_info(std::ostream &
info)
override;
975 void print_long_info(std::ostream &
info)
override;
#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:403
This is the abstract base class for binary log events.
Definition: binlog_event.h:826
Event_reader & reader()
Returns a reference to the event Event_reader object.
Definition: binlog_event.h:942
Log_event_footer * footer()
Return a non-const pointer to the footer of the log event.
Definition: binlog_event.h:938
Event_reader m_reader
Definition: binlog_event.h:949
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:877
const Log_event_header * header() const
Return a const pointer to the header of the log event.
Definition: binlog_event.h:926
Binary_log_event & operator=(Binary_log_event &&)=default
enum_post_header_length
The lengths for the fixed data part of each event.
Definition: binlog_event.h:839
@ XID_HEADER_LEN
Definition: binlog_event.h:854
@ TABLE_MAP_HEADER_LEN
Definition: binlog_event.h:857
@ IGNORABLE_HEADER_LEN
Definition: binlog_event.h:863
@ USER_VAR_HEADER_LEN
Definition: binlog_event.h:852
@ HEARTBEAT_HEADER_LEN
Definition: binlog_event.h:862
@ XA_PREPARE_HEADER_LEN
Definition: binlog_event.h:867
@ VIEW_CHANGE_HEADER_LEN
Definition: binlog_event.h:866
@ APPEND_BLOCK_HEADER_LEN
Definition: binlog_event.h:849
@ DELETE_FILE_HEADER_LEN
Definition: binlog_event.h:850
@ INTVAR_HEADER_LEN
Definition: binlog_event.h:848
@ INCIDENT_HEADER_LEN
Definition: binlog_event.h:861
@ EXECUTE_LOAD_QUERY_HEADER_LEN
Definition: binlog_event.h:859
@ QUERY_HEADER_MINIMAL_LEN
Definition: binlog_event.h:841
@ START_V3_HEADER_LEN
Definition: binlog_event.h:845
@ RAND_HEADER_LEN
Definition: binlog_event.h:851
@ QUERY_HEADER_LEN
Definition: binlog_event.h:843
@ ROWS_HEADER_LEN_V2
Definition: binlog_event.h:864
@ ROWS_HEADER_LEN_V1
Definition: binlog_event.h:856
@ TRANSACTION_PAYLOAD_HEADER_LEN
Definition: binlog_event.h:868
@ STOP_HEADER_LEN
Definition: binlog_event.h:844
@ TRANSACTION_CONTEXT_HEADER_LEN
Definition: binlog_event.h:865
@ EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN
Definition: binlog_event.h:858
@ FORMAT_DESCRIPTION_HEADER_LEN
Definition: binlog_event.h:853
@ ROTATE_HEADER_LEN
Definition: binlog_event.h:847
@ BEGIN_LOAD_QUERY_HEADER_LEN
Definition: binlog_event.h:855
enum Log_event_type get_event_type() const
Helper method.
Definition: binlog_event.h:921
Binary_log_event(const Binary_log_event &)=default
Log_event_footer m_footer
Definition: binlog_event.h:951
static const int LOG_EVENT_TYPES
Definition: binlog_event.h:833
virtual ~Binary_log_event()=0
Log_event_header * header()
Return a non-const pointer to the header of the log event.
Definition: binlog_event.h:930
const Log_event_footer * footer() const
Return a const pointer to the footer of the log event.
Definition: binlog_event.h:934
Binary_log_event(Binary_log_event &&)=default
Log_event_header m_header
Definition: binlog_event.h:950
Binary_log_event & operator=(const Binary_log_event &)=default
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:964
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:970
const char * p
Definition: ctype-mb.cc:1237
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.
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:222
const unsigned char checksum_version_split[3]
Replication event checksum is introduced in the following "checksum-home" version.
Definition: binlog_event.cpp:30
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:181
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:155
const int64_t SEQ_UNINIT
Uninitialized timestamp value (for either last committed or sequence number).
Definition: binlog_event.h:147
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:231
const uint32_t UNKNOWN_SERVER_VERSION
Definition: binlog_event.h:158
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:213
const unsigned long checksum_version_product
Definition: binlog_event.cpp:31
#define MAX_COMMIT_TIMESTAMP_VALUE
We use 7 bytes, 1 bit being used as a flag.
Definition: binlog_event.h:150
const uint32_t UNDEFINED_SERVER_VERSION
Definition: binlog_event.h:157
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.
The namespace contains classes representing events that can occur in a replication stream.
constexpr size_t max_log_event_size
The maximum value for MAX_ALLOWED_PACKET.
Definition: binlog_event.h:426
enum_binlog_checksum_alg
Enumeration spcifying checksum algorithm used to encode a binary log event.
Definition: binlog_event.h:440
@ BINLOG_CHECKSUM_ALG_ENUM_END
the cut line: valid alg range is [1, 0x7f]
Definition: binlog_event.h:449
@ BINLOG_CHECKSUM_ALG_CRC32
CRC32 of zlib algorithm.
Definition: binlog_event.h:447
@ BINLOG_CHECKSUM_ALG_UNDEF
Special value to tag undetermined yet checksum or events from checksum-unaware servers.
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:445
Log_event_type
Enumeration type for the different types of log events.
Definition: binlog_event.h:275
@ EXECUTE_LOAD_QUERY_EVENT
Definition: binlog_event.h:304
@ TABLE_MAP_EVENT
Definition: binlog_event.h:306
@ XA_PREPARE_LOG_EVENT
Definition: binlog_event.h:350
@ WRITE_ROWS_EVENT_V1
The V1 event numbers are used from 5.1.16 until mysql-5.6.
Definition: binlog_event.h:311
@ HEARTBEAT_LOG_EVENT_V2
Definition: binlog_event.h:360
@ USER_VAR_EVENT
Definition: binlog_event.h:300
@ DELETE_ROWS_EVENT
Definition: binlog_event.h:338
@ 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:332
@ DELETE_ROWS_EVENT_V1
Definition: binlog_event.h:313
@ FORMAT_DESCRIPTION_EVENT
Definition: binlog_event.h:301
@ PREVIOUS_GTIDS_LOG_EVENT
Definition: binlog_event.h:343
@ SLAVE_EVENT
Definition: binlog_event.h:294
@ DELETE_FILE_EVENT
Definition: binlog_event.h:297
@ UNKNOWN_EVENT
Every time you add a type, you have to.
Definition: binlog_event.h:283
@ RAND_EVENT
Definition: binlog_event.h:299
@ TRANSACTION_PAYLOAD_EVENT
Definition: binlog_event.h:358
@ TRANSACTION_CONTEXT_EVENT
Definition: binlog_event.h:345
@ INCIDENT_EVENT
Something out of the ordinary happened on the master.
Definition: binlog_event.h:318
@ PARTIAL_UPDATE_ROWS_EVENT
Extension of UPDATE_ROWS_EVENT, allowing partial values according to binlog_row_value_options.
Definition: binlog_event.h:356
@ ROWS_QUERY_LOG_EVENT
Definition: binlog_event.h:333
@ GTID_LOG_EVENT
Definition: binlog_event.h:340
@ WRITE_ROWS_EVENT
Version 2 of the Row events.
Definition: binlog_event.h:336
@ UPDATE_ROWS_EVENT_V1
Definition: binlog_event.h:312
@ ANONYMOUS_GTID_LOG_EVENT
Definition: binlog_event.h:341
@ 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:324
@ ROTATE_EVENT
Definition: binlog_event.h:291
@ BEGIN_LOAD_QUERY_EVENT
Definition: binlog_event.h:303
@ ENUM_END_EVENT
Add new events here - right above this comment! Existing events (except ENUM_END_EVENT) should never ...
Definition: binlog_event.h:365
@ INTVAR_EVENT
Definition: binlog_event.h:292
@ UPDATE_ROWS_EVENT
Definition: binlog_event.h:337
@ APPEND_BLOCK_EVENT
Definition: binlog_event.h:296
@ VIEW_CHANGE_EVENT
Definition: binlog_event.h:347
@ XID_EVENT
Definition: binlog_event.h:302
@ STOP_EVENT
Definition: binlog_event.h:290
@ START_EVENT_V3
Definition: binlog_event.h:288
@ QUERY_EVENT
Definition: binlog_event.h:289
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:475
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
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
Struct to pass basic information about a event: type, query, is it ignorable.
Definition: binlog_event.h:385
const char * query
Definition: binlog_event.h:387
Log_event_type event_type
Definition: binlog_event.h:386
bool ignorable_event
Definition: binlog_event.h:389
size_t query_length
Definition: binlog_event.h:388
Event type helpers, enclosed in the structure.
Definition: binlog_event.h:369
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:377
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:372
#define BAPI_ASSERT(x)
Definition: wrapper_functions.h:62