MySQL 8.4.2
Source Code Documentation
|
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... | |
TABLE * | get_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 | |
THD * | m_thd {nullptr} |
THD * | m_current_thd {nullptr} |
bool | m_error {false} |
Table_ref * | m_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 |
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.
Rpl_sys_table_access::Rpl_sys_table_access | ( | const std::string & | schema_name, |
const std::string & | table_name, | ||
uint | max_num_field | ||
) |
Construction.
[in] | schema_name | Database where the table resides |
[in] | table_name | Table to be opened |
[in] | max_num_field | Maximum number of fields |
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().
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().
[in] | error | State that there was a error on the table operations |
[in] | ignore_global_read_lock | State that the global_read_lock must be ignored |
true | if there is error |
false | if there is no error |
bool Rpl_sys_table_access::delete_all_rows | ( | void | ) |
Delete all rows on m_schema_name.m_table_name
.
true | if there is error |
false | if there is no error |
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.
true | if there is error |
false | if there is no error |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inline |
Get database name of table accessed.
|
inline |
Verify if error is set.
true | if there is error |
false | if there is no error |
bool Rpl_sys_table_access::get_field | ( | Field * | field, |
Json_wrapper & | wrapper | ||
) |
Retrieves Json field from provided table's field.
[in] | field | Field class object |
[in] | wrapper | The retrieved field would be saved in Json_wrapper format. |
true | Error |
false | Success |
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.
[in] | field | Field class object |
[in] | fld | The std::string value to be retrieved. |
[in] | cs | Charset info |
true | Error |
false | Success |
bool Rpl_sys_table_access::get_field | ( | Field * | field, |
uint & | fld | ||
) |
Retrieves long long integer field from provided table's field.
[in] | field | Field class object |
[in] | fld | The uint value to be retrieved. |
true | Error |
false | Success |
std::string Rpl_sys_table_access::get_field_error_msg | ( | std::string | field_name | ) | const |
TABLE * Rpl_sys_table_access::get_table | ( | ) |
Get TABLE object created for the table access purposes.
|
inline |
Get table name of table accessed.
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.
0 | if there is error |
>0 | if there is no error |
|
static |
|
static |
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.
true | if there is error |
false | if there is no error |
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.
[in] | lock_type | How to lock the table |
true | if there is error |
false | if there is no error |
|
inline |
Set error.
bool Rpl_sys_table_access::store_field | ( | Field * | field, |
const Json_wrapper & | wrapper | ||
) |
Stores provided Json to table's field.
[in] | field | Field class object |
[in] | wrapper | The Json_wrapper class object value |
true | Error |
false | Success |
bool Rpl_sys_table_access::store_field | ( | Field * | field, |
long long | fld, | ||
bool | unsigned_val = true |
||
) |
Stores provided integer to table's field.
[in] | field | Field class object |
[in] | fld | The long long value to be saved. |
[in] | unsigned_val | If value is unsigned. |
true | Error |
false | Success |
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.
[in] | field | Field class object |
[in] | fld | The std::string value to be saved. |
[in] | cs | Charset info |
true | Error |
false | Success |
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.
[in] | version | the version value |
true | if there is error |
false | if there is no error |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |