MySQL 8.3.0
Source Code Documentation
Gtid Struct Reference

TODO: Move this structure to mysql/binlog/event/control_events.h when we start using C++11. More...

#include <rpl_gtid.h>

Public Types

using Tsid = mysql::gtid::Tsid
 
using Tag = mysql::gtid::Tag
 

Public Member Functions

void clear ()
 Set both components to 0. More...
 
void set (rpl_sidno sidno_arg, rpl_gno gno_arg)
 Set both components to the given, positive values. More...
 
bool is_empty () const
 Return true if sidno is zero (and assert that gno is zero too in this case). More...
 
int to_string (const Tsid &tsid, char *buf) const
 Convert a Gtid to a string. More...
 
int to_string (const Tsid_map *tsid_map, char *buf, bool need_lock=false) const
 Convert this Gtid to a string. More...
 
bool equals (const Gtid &other) const
 Returns true if this Gtid has the same sid and gno as 'other'. More...
 
mysql::utils::Return_status parse (Tsid_map *tsid_map, const char *text)
 Parses the given string and stores in this Gtid. More...
 
void print (const Tsid_map *tsid_map) const
 Debug only: print this Gtid to stdout. More...
 
void dbug_print (const Tsid_map *tsid_map, const char *text="", bool need_lock=false) const
 Print this Gtid to the trace file if debug is enabled; no-op otherwise. More...
 

Static Public Member Functions

static bool is_valid (const char *text)
 Returns true if parse() would succeed, but doesn't store the result anywhere. More...
 
static std::pair< Tag, std::size_t > parse_tag_str (const char *text, std::size_t pos)
 Parses TAG from a textual representation of the GTID (text) More...
 
static void report_parsing_error (const char *text)
 Helper used to report BINLOG error. More...
 
static std::pair< mysql::utils::Return_status, mysql::gtid::Gtidparse_gtid_from_cstring (const char *text)
 Parses GTID from text. More...
 

Public Attributes

rpl_sidno sidno
 SIDNO of this Gtid. More...
 
rpl_gno gno
 GNO of this Gtid. More...
 

Static Public Attributes

static const int MAX_TEXT_LENGTH
 The maximal length of the textual representation of a TSID, not including the terminating '\0'. More...
 
static constexpr auto gtid_separator = ':'
 Definition of GTID separator (colon) which separates UUID and GNO. More...
 

Protected Member Functions

int to_string_gno (char *buf) const
 Converts internal gno into the string. More...
 

Static Protected Member Functions

static std::size_t skip_whitespace (const char *text, std::size_t pos)
 Helper function used to skip whitespaces in GTID specification. More...
 
static std::tuple< mysql::utils::Return_status, rpl_sid, std::size_t > parse_sid_str (const char *text, std::size_t pos)
 Parses SID from a textual representation of the GTID. More...
 
static std::tuple< mysql::utils::Return_status, rpl_gno, std::size_t > parse_gno_str (const char *text, std::size_t pos)
 Parses GNO from a textual representation of the GTID (text) More...
 
static std::pair< mysql::utils::Return_status, std::size_t > parse_gtid_separator (const char *text, std::size_t pos)
 Parses GTID separator from a textual representation of the GTID (text) More...
 

Detailed Description

TODO: Move this structure to mysql/binlog/event/control_events.h when we start using C++11.

Holds information about a GTID: the sidno and the gno.

This is a POD. It has to be a POD because it is part of Gtid_specification, which has to be a POD because it is used in THD::variables.

Member Typedef Documentation

◆ Tag

◆ Tsid

Member Function Documentation

◆ clear()

void Gtid::clear ( )
inline

Set both components to 0.

◆ dbug_print()

void Gtid::dbug_print ( const Tsid_map tsid_map,
const char *  text = "",
bool  need_lock = false 
) const
inline

Print this Gtid to the trace file if debug is enabled; no-op otherwise.

◆ equals()

bool Gtid::equals ( const Gtid other) const
inline

Returns true if this Gtid has the same sid and gno as 'other'.

◆ is_empty()

bool Gtid::is_empty ( ) const
inline

Return true if sidno is zero (and assert that gno is zero too in this case).

◆ is_valid()

bool Gtid::is_valid ( const char *  text)
static

Returns true if parse() would succeed, but doesn't store the result anywhere.

◆ parse()

Return_status Gtid::parse ( Tsid_map tsid_map,
const char *  text 
)

Parses the given string and stores in this Gtid.

Parameters
tsid_maptsid_map to use when converting TSID to a sidno.
textThe text to parse
Returns
status of operation

◆ parse_gno_str()

std::tuple< Return_status, rpl_gno, std::size_t > Gtid::parse_gno_str ( const char *  text,
std::size_t  pos 
)
staticprotected

Parses GNO from a textual representation of the GTID (text)

Parameters
[in]textString with full GTID specification
[in]posCurrent position within a text
Returns
operation status; Parsed gno in case status is equal to true or 0; Updated position within text

◆ parse_gtid_from_cstring()

std::pair< Return_status, mysql::gtid::Gtid > Gtid::parse_gtid_from_cstring ( const char *  text)
static

Parses GTID from text.

In case GTID is valid, it will return "ok" status code and a valid mysql::gtid::Gtid object. Otherwise, it will return an empty Gtid and error

Parameters
[in]textText containing textual representation of a GTID

◆ parse_gtid_separator()

std::pair< Return_status, std::size_t > Gtid::parse_gtid_separator ( const char *  text,
std::size_t  pos 
)
staticprotected

Parses GTID separator from a textual representation of the GTID (text)

Parameters
[in]textString with full GTID specification
[in]posCurrent position within a text
Returns
parsing status, error in case separator could not have been parsed Updated position within text

◆ parse_sid_str()

std::tuple< Return_status, rpl_sid, std::size_t > Gtid::parse_sid_str ( const char *  text,
std::size_t  pos 
)
staticprotected

Parses SID from a textual representation of the GTID.

Parameters
[in]textString with full GTID specification
[in]posCurrent position within a text
Returns
operation status; Parsed sidno in case status is equal to true, 0 otherwise; Updated position within text up to which characters has been accepted

◆ parse_tag_str()

std::pair< Gtid::Tag, std::size_t > Gtid::parse_tag_str ( const char *  text,
std::size_t  pos 
)
static

Parses TAG from a textual representation of the GTID (text)

Parameters
[in]textString with full GTID specification
[in]posCurrent position within a text
Returns
Parsed tag Updated position within text

◆ print()

void Gtid::print ( const Tsid_map tsid_map) const
inline

Debug only: print this Gtid to stdout.

◆ report_parsing_error()

void Gtid::report_parsing_error ( const char *  text)
static

Helper used to report BINLOG error.

Parameters
[in]textString with full GTID specification

◆ set()

void Gtid::set ( rpl_sidno  sidno_arg,
rpl_gno  gno_arg 
)
inline

Set both components to the given, positive values.

◆ skip_whitespace()

std::size_t Gtid::skip_whitespace ( const char *  text,
std::size_t  pos 
)
staticprotected

Helper function used to skip whitespaces in GTID specification.

Parameters
[in]textString with full GTID specification
[in]posCurrent position within a text
Returns
Updated position in text

◆ to_string() [1/2]

int Gtid::to_string ( const Tsid tsid,
char *  buf 
) const

Convert a Gtid to a string.

Parameters
tsidthe TSID to use. This overrides the sidno of this Gtid.
[out]bufBuffer to store the Gtid in (normally MAX_TEXT_LENGTH+1 bytes long).
Returns
Length of the string, not counting '\0'.

◆ to_string() [2/2]

int Gtid::to_string ( const Tsid_map tsid_map,
char *  buf,
bool  need_lock = false 
) const

Convert this Gtid to a string.

Parameters
tsid_maptsid_map to use when converting sidno to a TSID.
[out]bufBuffer to store the Gtid in (normally MAX_TEXT_LENGTH+1 bytes long).
need_lockIf true, the function will acquire tsid_map->tsid_lock; otherwise it will assert that the lock is held.
Returns
Length of the string, not counting '\0'.

◆ to_string_gno()

int Gtid::to_string_gno ( char *  buf) const
protected

Converts internal gno into the string.

Parameters
[out]bufBuffer to store the GNO in
Returns
Length of the string

Member Data Documentation

◆ gno

rpl_gno Gtid::gno

GNO of this Gtid.

◆ gtid_separator

constexpr auto Gtid::gtid_separator = ':'
staticconstexpr

Definition of GTID separator (colon) which separates UUID and GNO.

◆ MAX_TEXT_LENGTH

const int Gtid::MAX_TEXT_LENGTH
static
Initial value:
=
constexpr auto tsid_max_length
Maximum TSID text length (without null character)
Definition: tsid.h:40
const int MAX_GNO_TEXT_LENGTH
The length of MAX_GNO when printed in decimal.
Definition: rpl_gtid.h:285

The maximal length of the textual representation of a TSID, not including the terminating '\0'.

◆ sidno

rpl_sidno Gtid::sidno

SIDNO of this Gtid.


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