MySQL 9.1.0
Source Code Documentation
|
The Common-Header always has the same form and length within one version of MySQL. More...
#include <binlog_event.h>
Public Types | |
typedef unsigned char | Byte |
The following type definition is to be used whenever data is placed and manipulated in a common buffer. More... | |
Public Member Functions | |
Log_event_header (Log_event_type type_code_arg=ENUM_END_EVENT) | |
Log_event_header (Event_reader &reader) | |
Log_event_header constructor. More... | |
bool | get_is_valid () |
The get_is_valid function is related to event specific sanity checks to determine that the object was initialized without errors. More... | |
void | set_is_valid (bool is_valid) |
Set if the event object shall be considered valid or not. More... | |
const Event_decoding_error & | get_decoding_error () const |
Accessor for decoding error. More... | |
void | set_decoding_error (const Event_decoding_error &decoding_error) |
Sets specific decoding error. More... | |
Public Attributes | |
struct timeval | when |
Log_event_type | type_code |
Event type extracted from the header. More... | |
unsigned int | unmasked_server_id |
size_t | data_written |
unsigned long long | log_pos |
uint16_t | flags |
Private Attributes | |
bool | m_is_valid |
Event_decoding_error | m_decoding_error = Event_decoding_error::ok |
Holds information about specific decoding error. More... | |
The Common-Header always has the same form and length within one version of MySQL.
Each event type specifies a format and length of the Post-Header. The length of the Common-Header is the same for all events of the same type.
The binary format of Common-Header is as follows:
Name | Format | Description |
---|---|---|
when | 4 byte unsigned integer, represented by type struct timeval | The time when the query started, in seconds since 1970. |
type_code | 1 byte enumeration | See enum Log_event_type. |
unmasked_server_id | 4 byte unsigned integer | Server ID of the server that created the event. |
data_written | 4 byte unsigned integer | The total size of this event, in bytes. In other words, this is the sum of the sizes of Common-Header, Post-Header, and Body. |
log_pos | 4 byte unsigned integer | The position of the next event in the master binary log, in bytes from the beginning of the file. In a binlog that is not a relay log, this is just the position of the next event, in bytes from the beginning of the file. In a relay log, this is the position of the next event in the master's binlog. |
flags | 2 byte bitfield | 16 or less flags depending on the version of the binary log. |
Summing up the numbers above, we see that the total size of the common header is 19 bytes.
typedef unsigned char mysql::binlog::event::Log_event_header::Byte |
The following type definition is to be used whenever data is placed and manipulated in a common buffer.
Use this typedef for buffers that contain data containing binary and character data.
|
inlineexplicit |
mysql::binlog::event::Log_event_header::Log_event_header | ( | Event_reader & | reader | ) |
Log_event_header constructor.
reader | the Event_reader containing the serialized event (including header, event data and optional checksum information). |
The first 19 bytes in the header is as follows: +============================================+ | member_variable offset : len | +============================================+ | when.tv_sec 0 : 4 | +--------------------------------------------+ | type_code EVENT_TYPE_OFFSET(4) : 1 | +--------------------------------------------+ | server_id SERVER_ID_OFFSET(5) : 4 | +--------------------------------------------+ | data_written EVENT_LEN_OFFSET(9) : 4 | +--------------------------------------------+ | log_pos LOG_POS_OFFSET(13) : 4 | +--------------------------------------------+ | flags FLAGS_OFFSET(17) : 2 | +--------------------------------------------+ | extra_headers 19 : x-19| +============================================+
const Event_decoding_error & mysql::binlog::event::Log_event_header::get_decoding_error | ( | ) | const |
Accessor for decoding error.
|
inline |
The get_is_valid function is related to event specific sanity checks to determine that the object was initialized without errors.
Note that a given event object may be valid at some point (ancestor event type initialization was fine) but be turned invalid in a later stage.
void mysql::binlog::event::Log_event_header::set_decoding_error | ( | const Event_decoding_error & | decoding_error | ) |
Sets specific decoding error.
decoding_error | Decoding error to be set |
|
inline |
Set if the event object shall be considered valid or not.
is_valid | if the event object shall be considered valid. |
size_t mysql::binlog::event::Log_event_header::data_written |
uint16_t mysql::binlog::event::Log_event_header::flags |
unsigned long long mysql::binlog::event::Log_event_header::log_pos |
|
private |
Holds information about specific decoding error.
|
private |
Log_event_type mysql::binlog::event::Log_event_header::type_code |
Event type extracted from the header.
In the server, it is decoded by read_log_event(), but adding here for complete decoding.
unsigned int mysql::binlog::event::Log_event_header::unmasked_server_id |
struct timeval mysql::binlog::event::Log_event_header::when |