MySQL  8.0.16
Source Code Documentation
binary_log::Log_event_header Class Reference

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...
 

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
 

Detailed Description

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:

Common-Header
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.

Member Typedef Documentation

◆ Byte

typedef unsigned char binary_log::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.

Constructor & Destructor Documentation

◆ Log_event_header() [1/2]

binary_log::Log_event_header::Log_event_header ( Log_event_type  type_code_arg = ENUM_END_EVENT)
inlineexplicit

◆ Log_event_header() [2/2]

binary_log::Log_event_header::Log_event_header ( Event_reader reader)

Log_event_header constructor.

Parameters
readerthe 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|
  +============================================+

Member Function Documentation

◆ get_is_valid()

bool binary_log::Log_event_header::get_is_valid ( )
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.

Returns
True if the event object is valid, false otherwise.

◆ set_is_valid()

void binary_log::Log_event_header::set_is_valid ( bool  is_valid)
inline

Set if the event object shall be considered valid or not.

Parameters
is_validif the event object shall be considered valid.

Member Data Documentation

◆ data_written

size_t binary_log::Log_event_header::data_written

◆ flags

uint16_t binary_log::Log_event_header::flags

◆ log_pos

unsigned long long binary_log::Log_event_header::log_pos

◆ m_is_valid

bool binary_log::Log_event_header::m_is_valid
private

◆ type_code

Log_event_type binary_log::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.

◆ unmasked_server_id

unsigned int binary_log::Log_event_header::unmasked_server_id

◆ when

struct timeval binary_log::Log_event_header::when

The documentation for this class was generated from the following files: