MySQL 8.4.0
Source Code Documentation
Rpl_sys_table_access Class Reference

The class are wrappers for handler index and random scan functions to simplify their usage. More...

#include <rpl_sys_table_access.h>

Public Member Functions

 Rpl_sys_table_access (const std::string &schema_name, const std::string &table_name, uint max_num_field)
 Construction. More...
 
 ~Rpl_sys_table_access ()
 Destruction. More...
 
bool open (enum thr_lock_type lock_type)
 Creates new thread/session context (THD) and open's table on class object creation. More...
 
bool close (bool error, bool ignore_global_read_lock=false)
 All opened tables with the open_tables are closed and removes THD created in close(). More...
 
TABLEget_table ()
 Get TABLE object created for the table access purposes. More...
 
void set_error ()
 Set error. More...
 
bool get_error ()
 Verify if error is set. More...
 
bool store_field (Field *field, std::string fld, CHARSET_INFO *cs=&my_charset_bin)
 Stores provided string to table's field. More...
 
bool store_field (Field *field, long long fld, bool unsigned_val=true)
 Stores provided integer to table's field. More...
 
bool store_field (Field *field, const Json_wrapper &wrapper)
 Stores provided Json to table's field. More...
 
bool get_field (Field *field, std::string &fld, CHARSET_INFO *cs=&my_charset_bin)
 Retrieves string field from provided table's field. More...
 
bool get_field (Field *field, uint &fld)
 Retrieves long long integer field from provided table's field. More...
 
bool get_field (Field *field, Json_wrapper &wrapper)
 Retrieves Json field from provided table's field. More...
 
std::string get_field_error_msg (std::string field_name) const
 
bool delete_all_rows ()
 Delete all rows on m_schema_name.m_table_name. More...
 
ulonglong get_version ()
 Return the version stored on m_schema_version_name.m_table_version_name for the m_schema_name.m_table_name table. More...
 
bool increment_version ()
 Increment the version stored on m_schema_version_name.m_table_version_name for the m_schema_name.m_table_name table. More...
 
bool update_version (ulonglong version)
 Update the version stored on m_schema_version_name.m_table_version_name for the m_schema_name.m_table_name table. More...
 
bool delete_version ()
 Delete the version stored on m_schema_version_name.m_table_version_name for the m_schema_name.m_table_name table. More...
 
std::string get_db_name ()
 Get database name of table accessed. More...
 
std::string get_table_name ()
 Get table name of table accessed. More...
 

Static Public Member Functions

static void handler_write_row_func (Rpl_sys_table_access &table_op, bool &err_val, std::string &err_msg, uint table_index=0, key_part_map keypart_map=HA_WHOLE_KEY)
 
static void handler_delete_row_func (Rpl_sys_table_access &table_op, bool &err_val, std::string &err_msg, uint table_index=0, key_part_map keypart_map=HA_WHOLE_KEY)
 
template<class F , class... Ts, std::size_t... Is>
static void for_each_in_tuple (std::tuple< Ts... > &tuple, F func, std::index_sequence< Is... >)
 
template<class F , class... Ts>
static void for_each_in_tuple (std::tuple< Ts... > &tuple, F func)
 
template<class F , class... Ts, std::size_t... Is>
static void for_each_in_tuple (const std::tuple< Ts... > &tuple, F func, std::index_sequence< Is... >)
 
template<class F , class... Ts>
static void for_each_in_tuple (const std::tuple< Ts... > &tuple, F func)
 

Private Attributes

THDm_thd {nullptr}
 
THDm_current_thd {nullptr}
 
bool m_error {false}
 
Table_refm_table_list {nullptr}
 
enum thr_lock_type m_lock_type
 
std::string m_schema_name
 
std::string m_table_name
 
uint m_max_num_field
 
const std::string m_schema_version_name {"mysql"}
 
const std::string m_table_version_name
 
const uint m_table_data_index = 0
 
const uint m_table_version_index = 1
 
const uint m_table_list_size = 2
 

Detailed Description

The class are wrappers for handler index and random scan functions to simplify their usage.

The class is used to simplify table data access.

It creates new thread/session context (THD) and open table on class object creation, and destroys thread and closes all open thread tables on class object destruction.

Constructor & Destructor Documentation

◆ Rpl_sys_table_access()

Rpl_sys_table_access::Rpl_sys_table_access ( const std::string &  schema_name,
const std::string &  table_name,
uint  max_num_field 
)

Construction.

Parameters
[in]schema_nameDatabase where the table resides
[in]table_nameTable to be opened
[in]max_num_fieldMaximum number of fields

◆ ~Rpl_sys_table_access()

Rpl_sys_table_access::~Rpl_sys_table_access ( )

Destruction.

All opened tables with the open_tables are closed during destruction if not already done in deinit().

Member Function Documentation

◆ close()

bool Rpl_sys_table_access::close ( bool  error,
bool  ignore_global_read_lock = false 
)

All opened tables with the open_tables are closed and removes THD created in close().

Parameters
[in]errorState that there was a error on the table operations
[in]ignore_global_read_lockState that the global_read_lock must be ignored
Return values
trueif there is error
falseif there is no error

◆ delete_all_rows()

bool Rpl_sys_table_access::delete_all_rows ( void  )

Delete all rows on m_schema_name.m_table_name.

Return values
trueif there is error
falseif there is no error

◆ delete_version()

bool Rpl_sys_table_access::delete_version ( )

Delete the version stored on m_schema_version_name.m_table_version_name for the m_schema_name.m_table_name table.

Return values
trueif there is error
falseif there is no error

◆ for_each_in_tuple() [1/4]

template<class F , class... Ts>
static void Rpl_sys_table_access::for_each_in_tuple ( const std::tuple< Ts... > &  tuple,
func 
)
inlinestatic

◆ for_each_in_tuple() [2/4]

template<class F , class... Ts, std::size_t... Is>
static void Rpl_sys_table_access::for_each_in_tuple ( const std::tuple< Ts... > &  tuple,
func,
std::index_sequence< Is... >   
)
inlinestatic

◆ for_each_in_tuple() [3/4]

template<class F , class... Ts>
static void Rpl_sys_table_access::for_each_in_tuple ( std::tuple< Ts... > &  tuple,
func 
)
inlinestatic

◆ for_each_in_tuple() [4/4]

template<class F , class... Ts, std::size_t... Is>
static void Rpl_sys_table_access::for_each_in_tuple ( std::tuple< Ts... > &  tuple,
func,
std::index_sequence< Is... >   
)
inlinestatic

◆ get_db_name()

std::string Rpl_sys_table_access::get_db_name ( )
inline

Get database name of table accessed.

Returns
database name.

◆ get_error()

bool Rpl_sys_table_access::get_error ( )
inline

Verify if error is set.

Return values
trueif there is error
falseif there is no error

◆ get_field() [1/3]

bool Rpl_sys_table_access::get_field ( Field field,
Json_wrapper wrapper 
)

Retrieves Json field from provided table's field.

Parameters
[in]fieldField class object
[in]wrapperThe retrieved field would be saved in Json_wrapper format.
Return values
trueError
falseSuccess

◆ get_field() [2/3]

bool Rpl_sys_table_access::get_field ( Field field,
std::string &  fld,
CHARSET_INFO cs = &my_charset_bin 
)

Retrieves string field from provided table's field.

Parameters
[in]fieldField class object
[in]fldThe std::string value to be retrieved.
[in]csCharset info
Return values
trueError
falseSuccess

◆ get_field() [3/3]

bool Rpl_sys_table_access::get_field ( Field field,
uint &  fld 
)

Retrieves long long integer field from provided table's field.

Parameters
[in]fieldField class object
[in]fldThe uint value to be retrieved.
Return values
trueError
falseSuccess

◆ get_field_error_msg()

std::string Rpl_sys_table_access::get_field_error_msg ( std::string  field_name) const

◆ get_table()

TABLE * Rpl_sys_table_access::get_table ( )

Get TABLE object created for the table access purposes.

Returns
TABLE pointer.

◆ get_table_name()

std::string Rpl_sys_table_access::get_table_name ( )
inline

Get table name of table accessed.

Returns
table name.

◆ get_version()

ulonglong Rpl_sys_table_access::get_version ( )

Return the version stored on m_schema_version_name.m_table_version_name for the m_schema_name.m_table_name table.

Return values
0if there is error
>0if there is no error

◆ handler_delete_row_func()

void Rpl_sys_table_access::handler_delete_row_func ( Rpl_sys_table_access table_op,
bool &  err_val,
std::string &  err_msg,
uint  table_index = 0,
key_part_map  keypart_map = HA_WHOLE_KEY 
)
static

◆ handler_write_row_func()

void Rpl_sys_table_access::handler_write_row_func ( Rpl_sys_table_access table_op,
bool &  err_val,
std::string &  err_msg,
uint  table_index = 0,
key_part_map  keypart_map = HA_WHOLE_KEY 
)
static

◆ increment_version()

bool Rpl_sys_table_access::increment_version ( )

Increment the version stored on m_schema_version_name.m_table_version_name for the m_schema_name.m_table_name table.

Return values
trueif there is error
falseif there is no error

◆ open()

bool Rpl_sys_table_access::open ( enum thr_lock_type  lock_type)

Creates new thread/session context (THD) and open's table on class object creation.

Parameters
[in]lock_typeHow to lock the table
Return values
trueif there is error
falseif there is no error

◆ set_error()

void Rpl_sys_table_access::set_error ( )
inline

Set error.

◆ store_field() [1/3]

bool Rpl_sys_table_access::store_field ( Field field,
const Json_wrapper wrapper 
)

Stores provided Json to table's field.

Parameters
[in]fieldField class object
[in]wrapperThe Json_wrapper class object value
Return values
trueError
falseSuccess

◆ store_field() [2/3]

bool Rpl_sys_table_access::store_field ( Field field,
long long  fld,
bool  unsigned_val = true 
)

Stores provided integer to table's field.

Parameters
[in]fieldField class object
[in]fldThe long long value to be saved.
[in]unsigned_valIf value is unsigned.
Return values
trueError
falseSuccess

◆ store_field() [3/3]

bool Rpl_sys_table_access::store_field ( Field field,
std::string  fld,
CHARSET_INFO cs = &my_charset_bin 
)

Stores provided string to table's field.

Parameters
[in]fieldField class object
[in]fldThe std::string value to be saved.
[in]csCharset info
Return values
trueError
falseSuccess

◆ update_version()

bool Rpl_sys_table_access::update_version ( ulonglong  version)

Update the version stored on m_schema_version_name.m_table_version_name for the m_schema_name.m_table_name table.

Parameters
[in]versionthe version value
Return values
trueif there is error
falseif there is no error

Member Data Documentation

◆ m_current_thd

THD* Rpl_sys_table_access::m_current_thd {nullptr}
private

◆ m_error

bool Rpl_sys_table_access::m_error {false}
private

◆ m_lock_type

enum thr_lock_type Rpl_sys_table_access::m_lock_type
private

◆ m_max_num_field

uint Rpl_sys_table_access::m_max_num_field
private

◆ m_schema_name

std::string Rpl_sys_table_access::m_schema_name
private

◆ m_schema_version_name

const std::string Rpl_sys_table_access::m_schema_version_name {"mysql"}
private

◆ m_table_data_index

const uint Rpl_sys_table_access::m_table_data_index = 0
private

◆ m_table_list

Table_ref* Rpl_sys_table_access::m_table_list {nullptr}
private

◆ m_table_list_size

const uint Rpl_sys_table_access::m_table_list_size = 2
private

◆ m_table_name

std::string Rpl_sys_table_access::m_table_name
private

◆ m_table_version_index

const uint Rpl_sys_table_access::m_table_version_index = 1
private

◆ m_table_version_name

const std::string Rpl_sys_table_access::m_table_version_name
private
Initial value:
{
"replication_group_configuration_version"}

◆ m_thd

THD* Rpl_sys_table_access::m_thd {nullptr}
private

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