MySQL 9.1.0
Source Code Documentation
Gtid_mode Class Reference

Class to access the value of @global.gtid_mode in an efficient and thread-safe manner. More...

#include <rpl_gtid.h>

Public Types

enum  value_type {
  OFF = 0 , DEFAULT = OFF , OFF_PERMISSIVE = 1 , ON_PERMISSIVE = 2 ,
  ON = 3
}
 Possible values for @global.gtid_mode. More...
 

Public Member Functions

 Gtid_mode ()
 
void set (value_type value)
 Set a new value for @global.gtid_mode. More...
 
value_type get () const
 Return the current gtid_mode as an enumeration value. More...
 
const char * get_string () const
 Return the current gtid_mode as a string. More...
 

Static Public Member Functions

static std::pair< bool, value_typefrom_string (std::string s)
 Return the given string gtid_mode as an enumeration value. More...
 
static const char * to_string (value_type value)
 Return the given gtid_mode as a string. More...
 

Static Public Attributes

static ulong sysvar_mode
 The sys_var framework needs a variable of type ulong to store the value in. More...
 
static const char * names []
 Strings holding the enumeration values for gtid_mode. More...
 
static Checkable_rwlock lock
 Protects updates to @global.gtid_mode. More...
 

Private Attributes

std::atomic< int > m_atomic_mode
 

Detailed Description

Class to access the value of @global.gtid_mode in an efficient and thread-safe manner.

Member Enumeration Documentation

◆ value_type

Possible values for @global.gtid_mode.

Enumerator
OFF 

New transactions are anonymous.

Replicated transactions must be anonymous; replicated GTID-transactions generate an error.

DEFAULT 
OFF_PERMISSIVE 

New transactions are anonyomus.

Replicated transactions can be either anonymous or GTID-transactions.

ON_PERMISSIVE 

New transactions are GTID-transactions.

Replicated transactions can be either anonymous or GTID-transactions.

ON 

New transactions are GTID-transactions.

Replicated transactions must be GTID-transactions; replicated anonymous transactions generate an error.

Constructor & Destructor Documentation

◆ Gtid_mode()

Gtid_mode::Gtid_mode ( )
inline

Member Function Documentation

◆ from_string()

std::pair< bool, Gtid_mode::value_type > Gtid_mode::from_string ( std::string  s)
static

Return the given string gtid_mode as an enumeration value.

Parameters
sThe string to decode.
Returns
A pair, where the first component indicates failure and the second component is the GTID_MODE. Specifically, the first component is false if the string is a valid GTID_MODE, and true if it is not.

◆ get()

Gtid_mode::value_type Gtid_mode::get ( ) const

Return the current gtid_mode as an enumeration value.

◆ get_string()

const char * Gtid_mode::get_string ( ) const

Return the current gtid_mode as a string.

Used only for debugging. Non-debug code typically reads and acts on the enum value before printing it. Then it is better to print the enum value.

◆ set()

void Gtid_mode::set ( value_type  value)

Set a new value for @global.gtid_mode.

This should only be called from Sys_var_gtid_mode::global_update and gtid_server_init.

◆ to_string()

const char * Gtid_mode::to_string ( Gtid_mode::value_type  value)
static

Return the given gtid_mode as a string.

Member Data Documentation

◆ lock

Checkable_rwlock Gtid_mode::lock
static
Initial value:
{
}
PSI_rwlock_key key_rwlock_gtid_mode_lock
Definition: mysqld.cc:1121

Protects updates to @global.gtid_mode.

SET @global.gtid_mode will try to take the write lock. If the lock is not granted immediately, SET will fail.

Thus, any other operation can block updates to @global.gtid_mode by acquiring the read lock.

◆ m_atomic_mode

std::atomic<int> Gtid_mode::m_atomic_mode
private

◆ names

const char * Gtid_mode::names
static
Initial value:
= {"OFF", "OFF_PERMISSIVE", "ON_PERMISSIVE",
"ON", NullS}
#define NullS
Definition of the null string (a null pointer of type char *), used in some of our string handling co...
Definition: nulls.h:33

Strings holding the enumeration values for gtid_mode.

Use Gtid_mode::get_string instead of accessing this directly.

◆ sysvar_mode

ulong Gtid_mode::sysvar_mode
static

The sys_var framework needs a variable of type ulong to store the value in.

The sys_var framework takes the value from there, but we copy it (in the methods of sys_var_gtid_mode) to the atomic value Gtid_mode::mode, and use only that in all other places.


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