MySQL 9.1.0
Source Code Documentation
mysql::binlog::event Namespace Reference

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

Namespaces

namespace  codecs
 
namespace  compression
 
namespace  debug
 

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...
 
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
 Holds basic information about an event: common-header fields, query, etc. 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...
 
struct  Log_event_type_helper
 Event type helpers, enclosed in the structure. 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_id
 Each table share has a table id, it is mainly used for row based replication. 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_boundary_parser
 This is the base class for verifying transaction boundaries. 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...
 
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 ,
  OBSOLETE_WRITE_ROWS_EVENT_V1 = 23 , OBSOLETE_UPDATE_ROWS_EVENT_V1 = 24 , OBSOLETE_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 , GTID_TAGGED_LOG_EVENT = 42 ,
  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 class  Event_decoding_error { ok , unknown_non_ignorable_fields , invalid_event , last }
 Errors that we distinguish during event decoding, that are translated to specific error returned by the Server. 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

const std::string & get_event_type_as_string (Log_event_type type)
 Get the event type as string object. More...
 
uint32_t checksum_crc32 (uint32_t crc, const unsigned char *pos, size_t length)
 Calculate a long checksum for a memoryblock. More...
 
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_vector_dimensionality (std::vector< unsigned int > &vec, Event_reader &reader_obj, unsigned int length)
 Parses VECTOR_DIMENSIONALITY 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...
 
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...
 
char * strndup (const char *s, size_t n)
 The strndup() function returns a pointer to a new string which is a duplicate of the string s, but it only copies at most n bytes. More...
 
const char * bapi_strndup (const char *destination, size_t n)
 This is a wrapper function, and returns a pointer to a new string which is a duplicate of the input string. More...
 
void * bapi_memdup (const void *source, size_t len)
 This is a wrapper function, and returns a pointer to a new memory with the contents copied from the input memory pointer, up to a given length. More...
 
void * bapi_malloc (size_t size, int flags)
 This is a wrapper function in order to allocate memory from the heap in the binlogevent library. More...
 
void bapi_free (void *ptr)
 This is a wrapper function in order to free the memory allocated from the heap in the binlogevent library. More...
 

Variables

static const std::unordered_map< Log_event_type, const std::string > event_type_to_string
 
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 

◆ Event_decoding_error

Errors that we distinguish during event decoding, that are translated to specific error returned by the Server.

Enumerator
ok 

no error

unknown_non_ignorable_fields 

Unknown, non ignorable fields found in the event stream.

invalid_event 

Invalid event - cannot read an event.

last 

End of enum, put additional constants above.

◆ 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 
OBSOLETE_WRITE_ROWS_EVENT_V1 
OBSOLETE_UPDATE_ROWS_EVENT_V1 
OBSOLETE_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 
GTID_TAGGED_LOG_EVENT 
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 mysql::binlog::event::available_buffer ( const char *  buf_start,
const char *  buf_current,
buf_len 
)

◆ bapi_free()

void mysql::binlog::event::bapi_free ( void *  ptr)
inline

This is a wrapper function in order to free the memory allocated from the heap in the binlogevent library.

If compiled with the MySQL server, and memory is allocated using memory allocating methods from the mysys library, my_free is called. Otherwise, the standard free() is called from the function.

Parameters
ptrPointer to the memory which is to be freed.

◆ bapi_malloc()

void * mysql::binlog::event::bapi_malloc ( size_t  size,
int  flags 
)
inline

This is a wrapper function in order to allocate memory from the heap in the binlogevent library.

If compiled with the MySQL server, and memory is allocated using memory allocating methods from the mysys library, my_malloc is called. Otherwise, the standard malloc() is called from the function.

Parameters
sizeSize of the memory to be allocated.
flagsflags to pass to MySQL server my_malloc functions
Returns
Void pointer to the allocated chunk of memory

◆ bapi_memdup()

void * mysql::binlog::event::bapi_memdup ( const void *  source,
size_t  len 
)
inline

This is a wrapper function, and returns a pointer to a new memory with the contents copied from the input memory pointer, up to a given length.

Parameters
sourcePointer to the buffer from which data is to be copied
lenLength up to which the source should be copied
Returns
dest pointer to a new memory if allocation was successful NULL otherwise

◆ bapi_strndup()

const char * mysql::binlog::event::bapi_strndup ( const char *  destination,
size_t  n 
)
inline

This is a wrapper function, and returns a pointer to a new string which is a duplicate of the input string.

The terminating Null character is added.

If compiled with MySQL server,the strndup function from the mysys library is called, which allow instrumenting memory allocated. Else, the standard string function is called.

Parameters
destinationThe string to be duplicated
nThe number of bytes to be copied
Returns
The duplicated string, or NULL if insufficient memory was available.

◆ checksum_crc32()

uint32_t mysql::binlog::event::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 mysql::binlog::event::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

◆ get_event_type_as_string()

const std::string & mysql::binlog::event::get_event_type_as_string ( Log_event_type  type)

Get the event type as string object.

Parameters
typethe event type for which to get a textual representation.
Returns
std::string a text representing the event name.

◆ parse_column_charset()

static void mysql::binlog::event::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 mysql::binlog::event::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 mysql::binlog::event::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 mysql::binlog::event::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 mysql::binlog::event::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 mysql::binlog::event::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 mysql::binlog::event::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 mysql::binlog::event::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 mysql::binlog::event::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

◆ parse_vector_dimensionality()

static void mysql::binlog::event::parse_vector_dimensionality ( std::vector< unsigned int > &  vec,
Event_reader reader_obj,
unsigned int  length 
)
static

Parses VECTOR_DIMENSIONALITY field.

Parameters
[out]vecstores vector columns's dimensionality extracted from field.
[in]reader_objthe Event_reader object containing the serialized field.
[in]lengthlength of the field

◆ strndup()

char * mysql::binlog::event::strndup ( const char *  s,
size_t  n 
)
inline

The strndup() function returns a pointer to a new string which is a duplicate of the string s, but it only copies at most n bytes.

If s is longer than n, only n bytes are copied, and a terminating null byte ('\0') is added. Memory for the new string is obtained with malloc, and can be freed with free.

Parameters
sThe string whose copy we want to create
nNumber of bytes to be copied
Returns
The duplicated string, or NULL if insufficient memory was available.

◆ valid_buffer_range()

template<class T >
bool mysql::binlog::event::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

◆ event_type_to_string

const std::unordered_map<Log_event_type, const std::string> mysql::binlog::event::event_type_to_string
static

◆ INVALID_XID

const uint64_t mysql::binlog::event::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 mysql::binlog::event::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.