MySQL 8.0.39
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:
[legend]

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...
 
virtual std::int64_t get_gno () const
 
Uuid get_uuid () const
 
void set_trx_length (unsigned long long int transaction_length_arg)
 Set the transaction length information. More...
 
unsigned long long get_trx_length () const
 
int get_commit_group_ticket_length () const
 Returns the length of the packed commit_group_ticket field. More...
 
void set_commit_group_ticket_and_update_transaction_length (std::uint64_t value)
 Set the commit_group_ticket and update the transaction length if needed, that is, if the commit_group_ticket was not set already account it on the transaction size. 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...
 
std::uint64_t commit_group_ticket {kGroupTicketUnset}
 Ticket number used to group sessions together during the BGC. More...
 

Static Public Attributes

static constexpr int COMMIT_GROUP_TICKET_LENGTH = 8
 
static constexpr std::uint64_t kGroupTicketUnset = 0
 
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 std::int64_t GNO_END = INT64_MAX
 One-past-the-max value of GNO. More...
 

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 ,
  TRANSACTION_PAYLOAD_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_group_ticket_length()

int binary_log::Gtid_event::get_commit_group_ticket_length ( ) const

Returns the length of the packed commit_group_ticket field.

It may be 8 bytes or 0 bytes, depending on whether or not the value is instantiated.

Returns
The length of the packed commit_group_ticket field

◆ get_commit_timestamp_length()

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

◆ get_gno()

virtual std::int64_t binary_log::Gtid_event::get_gno ( ) const
inlinevirtual

Reimplemented in Gtid_log_event.

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

◆ get_trx_length()

unsigned long long binary_log::Gtid_event::get_trx_length ( ) const
inline
Returns
The value of the transaction_length field.

◆ get_uuid()

Uuid binary_log::Gtid_event::get_uuid ( ) const
inline

◆ set_commit_group_ticket_and_update_transaction_length()

void binary_log::Gtid_event::set_commit_group_ticket_and_update_transaction_length ( std::uint64_t  value)

Set the commit_group_ticket and update the transaction length if needed, that is, if the commit_group_ticket was not set already account it on the transaction size.

Parameters
valueThe commit_group_ticket value.

◆ 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

◆ commit_group_ticket

std::uint64_t binary_log::Gtid_event::commit_group_ticket {kGroupTicketUnset}

Ticket number used to group sessions together during the BGC.

◆ COMMIT_GROUP_TICKET_LENGTH

constexpr int binary_log::Gtid_event::COMMIT_GROUP_TICKET_LENGTH = 8
staticconstexpr

◆ 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
Initial value:
=
static const int ORIGINAL_COMMIT_TIMESTAMP_LENGTH
Definition: control_events.h:1095
static const int IMMEDIATE_COMMIT_TIMESTAMP_LENGTH
Definition: control_events.h:1094

◆ FULL_SERVER_VERSION_LENGTH

const int binary_log::Gtid_event::FULL_SERVER_VERSION_LENGTH
staticprotected
Initial value:
=
static const int ORIGINAL_SERVER_VERSION_LENGTH
Length of original_server_version.
Definition: control_events.h:1105
static const int IMMEDIATE_SERVER_VERSION_LENGTH
Length of immediate_server_version.
Definition: control_events.h:1107

Length of original and immediate server version.

◆ GNO_END

const std::int64_t binary_log::Gtid_event::GNO_END = INT64_MAX
staticprotected

One-past-the-max value of GNO.

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

◆ kGroupTicketUnset

constexpr std::uint64_t binary_log::Gtid_event::kGroupTicketUnset = 0
staticconstexpr

◆ 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
Initial value:
=
static const int FULL_COMMIT_TIMESTAMP_LENGTH
Definition: control_events.h:1097
static const int TRANSACTION_LENGTH_MAX_LENGTH
Definition: control_events.h:1103
static const int FULL_SERVER_VERSION_LENGTH
Length of original and immediate server version.
Definition: control_events.h:1109
static constexpr int COMMIT_GROUP_TICKET_LENGTH
Definition: control_events.h:1076

◆ MAX_EVENT_LENGTH

const int binary_log::Gtid_event::MAX_EVENT_LENGTH
static
Initial value:
=
#define LOG_EVENT_HEADER_LEN
Definition: binlog_event.h:421
static const int POST_HEADER_LENGTH
Total length of post header.
Definition: control_events.h:1143
static const int MAX_DATA_LENGTH
Definition: control_events.h:1156

◆ 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
Initial value:
=
static const int LOGICAL_TIMESTAMP_TYPECODE_LENGTH
Length of typecode for logical timestamps.
Definition: control_events.h:1088
static const int ENCODED_GNO_LENGTH
Definition: control_events.h:1086
static const int ENCODED_SID_LENGTH
Definition: control_events.h:1085
static const int ENCODED_FLAG_LENGTH
Definition: control_events.h:1084
static const int LOGICAL_TIMESTAMP_LENGTH
Length of two logical timestamps.
Definition: control_events.h:1090

Total length of post header.

◆ 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: