MySQL  8.0.18
Source Code Documentation
binary_log::Gtid_event Class Reference

GTID stands for Global Transaction IDentifier It is composed of two parts: More...

#include <control_events.h>

Inheritance diagram for binary_log::Gtid_event:
binary_log::Binary_log_event Gtid_log_event

Public Member Functions

 Gtid_event (const char *buf, const Format_description_event *fde)
 Ctor of Gtid_event. More...
 
 Gtid_event (long long int last_committed_arg, long long int sequence_number_arg, bool may_have_sbr_stmts_arg, unsigned long long int original_commit_timestamp_arg, unsigned long long int immediate_commit_timestamp_arg, uint32_t original_server_version_arg, uint32_t immediate_server_version_arg)
 Constructor. More...
 
void set_trx_length (unsigned long long int transaction_length_arg)
 
Set the transaction length information. More...
 
- Public Member Functions inherited from binary_log::Binary_log_event
virtual ~Binary_log_event ()=0
 
 Binary_log_event (const Binary_log_event &)=default
 
 Binary_log_event (Binary_log_event &&)=default
 
Binary_log_eventoperator= (const Binary_log_event &)=default
 
Binary_log_eventoperator= (Binary_log_event &&)=default
 
enum Log_event_type get_event_type () const
 Helper method. More...
 
const Log_event_headerheader () const
 Return a const pointer to the header of the log event. More...
 
Log_event_headerheader ()
 Return a non-const pointer to the header of the log event. More...
 
const Log_event_footerfooter () const
 Return a const pointer to the footer of the log event. More...
 
Log_event_footerfooter ()
 Return a non-const pointer to the footer of the log event. More...
 
Event_readerreader ()
 Returns a reference to the event Event_reader object. More...
 

Public Attributes

long long int last_committed
 
long long int sequence_number
 
unsigned const char FLAG_MAY_HAVE_SBR = 1
 GTID flags constants. More...
 
bool may_have_sbr_stmts
 Transaction might have changes logged with SBR. More...
 
unsigned long long int original_commit_timestamp
 Timestamp when the transaction was committed on the originating master. More...
 
unsigned long long int immediate_commit_timestamp
 Timestamp when the transaction was committed on the nearest master. More...
 
bool has_commit_timestamps
 
unsigned long long int transaction_length
 The length of the transaction in bytes. More...
 
uint32_t original_server_version
 The version of the server where the transaction was originally executed. More...
 
uint32_t immediate_server_version
 The version of the immediate server. More...
 

Static Public Attributes

static const int POST_HEADER_LENGTH
 Total length of post header. More...
 
static const int MAX_DATA_LENGTH
 
static const int MAX_EVENT_LENGTH
 
- Static Public Attributes inherited from binary_log::Binary_log_event
static const int LOG_EVENT_TYPES = (ENUM_END_EVENT - 1)
 

Protected Member Functions

int get_commit_timestamp_length () const
 
int get_server_version_length () const
 We only store the immediate_server_version if both server versions are the same. More...
 
- Protected Member Functions inherited from binary_log::Binary_log_event
 Binary_log_event (Log_event_type type_code)
 This constructor is used to initialize the type_code of header object m_header. More...
 
 Binary_log_event (const char **buf, const Format_description_event *fde)
 This constructor will create a new object of Log_event_header and initialize the variable m_header, which in turn will be used to initialize Log_event's member common_header. More...
 

Protected Attributes

gtid_info gtid_info_struct
 
Uuid Uuid_parent_struct
 

Static Protected Attributes

static const int ENCODED_FLAG_LENGTH = 1
 
static const int ENCODED_SID_LENGTH = 16
 
static const int ENCODED_GNO_LENGTH = 8
 
static const int LOGICAL_TIMESTAMP_TYPECODE_LENGTH = 1
 Length of typecode for logical timestamps. More...
 
static const int LOGICAL_TIMESTAMP_LENGTH = 16
 Length of two logical timestamps. More...
 
static const int LOGICAL_TIMESTAMP_TYPECODE = 2
 
static const int IMMEDIATE_COMMIT_TIMESTAMP_LENGTH = 7
 
static const int ORIGINAL_COMMIT_TIMESTAMP_LENGTH = 7
 
static const int FULL_COMMIT_TIMESTAMP_LENGTH
 
static const int ENCODED_COMMIT_TIMESTAMP_LENGTH = 55
 
static const int TRANSACTION_LENGTH_MIN_LENGTH = 1
 
static const int TRANSACTION_LENGTH_MAX_LENGTH = 9
 
static const int ORIGINAL_SERVER_VERSION_LENGTH = 4
 Length of original_server_version. More...
 
static const int IMMEDIATE_SERVER_VERSION_LENGTH = 4
 Length of immediate_server_version. More...
 
static const int FULL_SERVER_VERSION_LENGTH
 Length of original and immediate server version. More...
 
static const int ENCODED_SERVER_VERSION_LENGTH = 31
 
static const int64_t MIN_GNO = 1
 
static const int64_t MAX_GNO = LLONG_MAX
 

Additional Inherited Members

- Public Types inherited from binary_log::Binary_log_event
enum  enum_post_header_length {
  QUERY_HEADER_MINIMAL_LEN = (4 + 4 + 1 + 2), QUERY_HEADER_LEN = (QUERY_HEADER_MINIMAL_LEN + 2), STOP_HEADER_LEN = 0, START_V3_HEADER_LEN = (2 + ST_SERVER_VER_LEN + 4),
  ROTATE_HEADER_LEN = 8, INTVAR_HEADER_LEN = 0, APPEND_BLOCK_HEADER_LEN = 4, DELETE_FILE_HEADER_LEN = 4,
  RAND_HEADER_LEN = 0, USER_VAR_HEADER_LEN = 0, FORMAT_DESCRIPTION_HEADER_LEN = (START_V3_HEADER_LEN + 1 + LOG_EVENT_TYPES), XID_HEADER_LEN = 0,
  BEGIN_LOAD_QUERY_HEADER_LEN = APPEND_BLOCK_HEADER_LEN, ROWS_HEADER_LEN_V1 = 8, TABLE_MAP_HEADER_LEN = 8, EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN = (4 + 4 + 4 + 1),
  EXECUTE_LOAD_QUERY_HEADER_LEN, INCIDENT_HEADER_LEN = 2, HEARTBEAT_HEADER_LEN = 0, IGNORABLE_HEADER_LEN = 0,
  ROWS_HEADER_LEN_V2 = 10, TRANSACTION_CONTEXT_HEADER_LEN = 18, VIEW_CHANGE_HEADER_LEN = 52, XA_PREPARE_HEADER_LEN = 0
}
 The lengths for the fixed data part of each event. More...
 

Detailed Description

GTID stands for Global Transaction IDentifier It is composed of two parts:

  • SID for Source Identifier, and
  • GNO for Group Number. The basic idea is to
    • Associate an identifier, the Global Transaction IDentifier or GTID, to every transaction.
    • When a transaction is copied to a slave, re-executed on the slave, and written to the slave's binary log, the GTID is preserved.
    • When a slave connects to a master, the slave uses GTIDs instead of (file, offset)

Binary Format

The Body can have up to nine components:

Body for Gtid_event
Name Format

Description

GTID_FLAGS 1 byte 00000001 = Transaction may have changes logged with SBR. In 5.6, 5.7.0-5.7.18, and 8.0.0-8.0.1, this flag is always set. Starting in 5.7.19 and 8.0.2, this flag is cleared if the transaction only contains row events. It is set if any part of the transaction is written in statement format.
SID 16 byte sequence UUID representing the SID
GNO 8 byte integer Group number, second component of GTID.
logical clock timestamp typecode 1 byte integer The type of logical timestamp used in the logical clock fields.
last_committed 8 byte integer Store the transaction's commit parent sequence_number
sequence_number 8 byte integer The transaction's logical timestamp assigned at prepare phase
immediate_commit_timestamp 7 byte integer Timestamp of commit on the immediate master
original_commit_timestamp 7 byte integer Timestamp of commit on the originating master
transaction_length 1 to 9 byte integer // See net_length_size(ulonglong num) The packed transaction's length in bytes, including the Gtid
immediate_server_version 4 byte integer Server version of the immediate server
original_server_version 4 byte integer Version of the server where the transaction was originally executed

Constructor & Destructor Documentation

◆ Gtid_event() [1/2]

binary_log::Gtid_event::Gtid_event ( const char *  buf,
const Format_description_event fde 
)

Ctor of Gtid_event.

The layout of the buffer is as follows

+----------+---+---+-------+--------------+---------+----------+
|gtid flags|SID|GNO|TS_TYPE|logical ts(:s)|commit ts|trx length|
+----------+---+---+-------+------------------------+----------+

TS_TYPE is from {G_COMMIT_TS2} singleton set of values Details on commit timestamps in Gtid_event(const char*...)

Parameters
bufContains the serialized event.
fdeAn FDE event (see Rotate_event constructor for more info).

Fetch the original/immediate_server_version. Set it to UNDEFINED_SERVER_VERSION if no version can be fetched.

◆ Gtid_event() [2/2]

binary_log::Gtid_event::Gtid_event ( long long int  last_committed_arg,
long long int  sequence_number_arg,
bool  may_have_sbr_stmts_arg,
unsigned long long int  original_commit_timestamp_arg,
unsigned long long int  immediate_commit_timestamp_arg,
uint32_t  original_server_version_arg,
uint32_t  immediate_server_version_arg 
)
inlineexplicit

Constructor.

Member Function Documentation

◆ get_commit_timestamp_length()

int binary_log::Gtid_event::get_commit_timestamp_length ( ) const
inlineprotected

◆ get_server_version_length()

int binary_log::Gtid_event::get_server_version_length ( ) const
inlineprotected

We only store the immediate_server_version if both server versions are the same.

◆ set_trx_length()

void binary_log::Gtid_event::set_trx_length ( unsigned long long int  transaction_length_arg)
inline


Set the transaction length information.

This function should be used when the full transaction length (including the Gtid event length) is known.

Parameters
transaction_length_argThe transaction length.

Member Data Documentation

◆ ENCODED_COMMIT_TIMESTAMP_LENGTH

const int binary_log::Gtid_event::ENCODED_COMMIT_TIMESTAMP_LENGTH = 55
staticprotected

◆ ENCODED_FLAG_LENGTH

const int binary_log::Gtid_event::ENCODED_FLAG_LENGTH = 1
staticprotected

◆ ENCODED_GNO_LENGTH

const int binary_log::Gtid_event::ENCODED_GNO_LENGTH = 8
staticprotected

◆ ENCODED_SERVER_VERSION_LENGTH

const int binary_log::Gtid_event::ENCODED_SERVER_VERSION_LENGTH = 31
staticprotected

◆ ENCODED_SID_LENGTH

const int binary_log::Gtid_event::ENCODED_SID_LENGTH = 16
staticprotected

◆ FLAG_MAY_HAVE_SBR

unsigned const char binary_log::Gtid_event::FLAG_MAY_HAVE_SBR = 1

GTID flags constants.

◆ FULL_COMMIT_TIMESTAMP_LENGTH

const int binary_log::Gtid_event::FULL_COMMIT_TIMESTAMP_LENGTH
staticprotected

◆ FULL_SERVER_VERSION_LENGTH

const int binary_log::Gtid_event::FULL_SERVER_VERSION_LENGTH
staticprotected
Initial value:

Length of original and immediate server version.

◆ gtid_info_struct

gtid_info binary_log::Gtid_event::gtid_info_struct
protected

◆ has_commit_timestamps

bool binary_log::Gtid_event::has_commit_timestamps

◆ immediate_commit_timestamp

unsigned long long int binary_log::Gtid_event::immediate_commit_timestamp

Timestamp when the transaction was committed on the nearest master.

◆ IMMEDIATE_COMMIT_TIMESTAMP_LENGTH

const int binary_log::Gtid_event::IMMEDIATE_COMMIT_TIMESTAMP_LENGTH = 7
staticprotected

◆ immediate_server_version

uint32_t binary_log::Gtid_event::immediate_server_version

The version of the immediate server.

◆ IMMEDIATE_SERVER_VERSION_LENGTH

const int binary_log::Gtid_event::IMMEDIATE_SERVER_VERSION_LENGTH = 4
staticprotected

Length of immediate_server_version.

◆ last_committed

long long int binary_log::Gtid_event::last_committed

◆ LOGICAL_TIMESTAMP_LENGTH

const int binary_log::Gtid_event::LOGICAL_TIMESTAMP_LENGTH = 16
staticprotected

Length of two logical timestamps.

◆ LOGICAL_TIMESTAMP_TYPECODE

const int binary_log::Gtid_event::LOGICAL_TIMESTAMP_TYPECODE = 2
staticprotected

◆ LOGICAL_TIMESTAMP_TYPECODE_LENGTH

const int binary_log::Gtid_event::LOGICAL_TIMESTAMP_TYPECODE_LENGTH = 1
staticprotected

Length of typecode for logical timestamps.

◆ MAX_DATA_LENGTH

const int binary_log::Gtid_event::MAX_DATA_LENGTH
static

◆ MAX_EVENT_LENGTH

const int binary_log::Gtid_event::MAX_EVENT_LENGTH
static

◆ MAX_GNO

const int64_t binary_log::Gtid_event::MAX_GNO = LLONG_MAX
staticprotected

◆ may_have_sbr_stmts

bool binary_log::Gtid_event::may_have_sbr_stmts

Transaction might have changes logged with SBR.

◆ MIN_GNO

const int64_t binary_log::Gtid_event::MIN_GNO = 1
staticprotected

◆ original_commit_timestamp

unsigned long long int binary_log::Gtid_event::original_commit_timestamp

Timestamp when the transaction was committed on the originating master.

◆ ORIGINAL_COMMIT_TIMESTAMP_LENGTH

const int binary_log::Gtid_event::ORIGINAL_COMMIT_TIMESTAMP_LENGTH = 7
staticprotected

◆ original_server_version

uint32_t binary_log::Gtid_event::original_server_version

The version of the server where the transaction was originally executed.

◆ ORIGINAL_SERVER_VERSION_LENGTH

const int binary_log::Gtid_event::ORIGINAL_SERVER_VERSION_LENGTH = 4
staticprotected

Length of original_server_version.

◆ POST_HEADER_LENGTH

const int binary_log::Gtid_event::POST_HEADER_LENGTH
static

◆ sequence_number

long long int binary_log::Gtid_event::sequence_number

◆ transaction_length

unsigned long long int binary_log::Gtid_event::transaction_length

The length of the transaction in bytes.

◆ TRANSACTION_LENGTH_MAX_LENGTH

const int binary_log::Gtid_event::TRANSACTION_LENGTH_MAX_LENGTH = 9
staticprotected

◆ TRANSACTION_LENGTH_MIN_LENGTH

const int binary_log::Gtid_event::TRANSACTION_LENGTH_MIN_LENGTH = 1
staticprotected

◆ Uuid_parent_struct

Uuid binary_log::Gtid_event::Uuid_parent_struct
protected

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