MySQL 8.4.3
Source Code Documentation
|
Namespaces | |
namespace | anonymous_namespace{cluster_metadata.cc} |
namespace | impl |
Classes | |
class | AutoCleaner |
Automatic cleanup on scope exit utility class. More... | |
struct | ClusterInfo |
class | ClusterMetadata |
class | ClusterMetadataAR |
class | ClusterMetadataGR |
class | ClusterMetadataGRInClusterSet |
class | ClusterMetadataGRV2 |
class | ConfigGenerator |
struct | InstanceAttributes |
class | LogFilter |
struct | MetadataSchemaVersion |
class | MetadataUpgradeInProgressException |
class | MySQLClientThreadToken |
Thread Token for libmysqlclient API users. More... | |
class | MysqlError |
class | MySQLSession |
class | SQLLogFilter |
A SQLLogFilter allows to replace substrings defined by a set of hardcoded regular expressions with '***'. More... | |
class | sqlstring |
struct | SSLOptions |
SSL connection related options. More... | |
class | SysUserOperations |
This class provides implementations of SysUserOperationsBase methods. More... | |
class | SysUserOperationsBase |
Base class to allow multiple SysUserOperations implementations. More... | |
class | TargetCluster |
class | URI |
Parse and create URIs according to RFC3986. More... | |
class | URIError |
Exception when URI was not valid. More... | |
class | URIParser |
struct | UserCredentials |
Typedefs | |
using | URIAuthority = std::tuple< std::string, uint16_t, std::string, std::string > |
using | URIPath = std::vector< std::string > |
using | URIQuery = std::map< std::string, std::string > |
using | perm_mode = mode_t |
using | OptionsMap = std::map< std::string, std::string > |
Enumerations | |
enum class | ClusterType { GR_V2 , GR_CS , RS_V2 } |
enum class | InstanceType { GroupMember , AsyncMember , ReadReplica , Unsupported } |
enum class | ServerMode { ReadWrite , ReadOnly , Unavailable } |
enum | SqlStringFlags { QuoteOnlyIfNeeded = 1 << 0 , UseAnsiQuotes = 1 << 1 , EndOfInput = 1 << 7 } |
Functions | |
const char * | begin (const char *const c) |
const char * | end (const char *const c) |
size_t | size (const char *const c) |
std::string ROUTER_CLUSTER_EXPORT | to_string (const MetadataSchemaVersion &version) |
MetadataSchemaVersion ROUTER_CLUSTER_EXPORT | get_metadata_schema_version (MySQLSession *mysql) |
bool ROUTER_CLUSTER_EXPORT | metadata_schema_version_is_compatible (const mysqlrouter::MetadataSchemaVersion &required, const mysqlrouter::MetadataSchemaVersion &available) |
std::string ROUTER_CLUSTER_EXPORT | get_metadata_schema_uncompatible_msg (const mysqlrouter::MetadataSchemaVersion &version) |
bool ROUTER_CLUSTER_EXPORT | check_group_replication_online (MySQLSession *mysql) |
bool ROUTER_CLUSTER_EXPORT | check_group_has_quorum (MySQLSession *mysql) |
template<size_t N> | |
bool | metadata_schema_version_is_compatible (const mysqlrouter::MetadataSchemaVersion(&required)[N], const mysqlrouter::MetadataSchemaVersion &available) |
template<size_t N> | |
std::string | to_string (const mysqlrouter::MetadataSchemaVersion(&version)[N]) |
ClusterType ROUTER_CLUSTER_EXPORT | get_cluster_type (const MetadataSchemaVersion &schema_version, MySQLSession *mysql, unsigned int router_id=0) |
std::string ROUTER_CLUSTER_EXPORT | to_string (const ClusterType cluster_type) |
stdx::expected< void, std::string > ROUTER_CLUSTER_EXPORT | setup_metadata_session (MySQLSession &session) |
bool ROUTER_CLUSTER_EXPORT | is_part_of_cluster_set (MySQLSession *mysql) |
std::optional< InstanceType > ROUTER_CLUSTER_EXPORT | str_to_instance_type (const std::string &) |
std::string ROUTER_CLUSTER_EXPORT | to_string (const InstanceType) |
std::string ROUTER_CLUSTER_EXPORT | to_string (const TargetCluster::InvalidatedClusterRoutingPolicy) |
std::map< std::string, std::string > ROUTER_UTILS_EXPORT | get_default_paths (const mysql_harness::Path &origin) |
Returns predefined (computed) default paths. More... | |
std::string ROUTER_UTILS_EXPORT | find_full_executable_path (const std::string &argv0) |
Returns absolute path to mysqlrouter.exe currently running. More... | |
void | set_owner_if_file_exists (const std::string &filepath, const std::string &username, struct passwd *user_info_arg, mysqlrouter::SysUserOperationsBase *sys_user_operations) |
Sets the owner of selected file/directory if it exists. More... | |
void | set_user (const std::string &username, bool permanently=false, mysqlrouter::SysUserOperationsBase *sys_user_operations=SysUserOperations::instance()) |
Sets effective user of the calling process. More... | |
struct passwd * | check_user (const std::string &username, bool must_be_root, mysqlrouter::SysUserOperationsBase *sys_user_operations) |
Checks if the given user can be switched to or made an owner of a selected file. More... | |
ROUTER_UTILS_EXPORT std::ostream & | operator<< (std::ostream &strm, const URI &uri) |
template<typename T > | |
std::string | to_string (const T &data) |
std::string ROUTER_UTILS_EXPORT | ms_to_seconds_string (const std::chrono::milliseconds &msec) |
uint16_t ROUTER_UTILS_EXPORT | get_tcp_port (const std::string &data) |
Validates a string containing a TCP port. More... | |
std::string | hexdump (const unsigned char *buffer, size_t count) |
Dumps buffer as hex values. More... | |
std::string ROUTER_UTILS_EXPORT | prompt_password (const std::string &prompt) |
Prompts for a password from the console. More... | |
void ROUTER_UTILS_EXPORT | set_prompt_password (const std::function< std::string(const std::string &)> &f) |
Override default prompt password function. More... | |
bool ROUTER_UTILS_EXPORT | substitute_envvar (std::string &line) noexcept |
Substitutes placeholders of environment variables in a string. More... | |
std::string ROUTER_UTILS_EXPORT | substitute_variable (const std::string &s, const std::string &name, const std::string &value) |
bool | my_check_access (const std::string &path) |
void ROUTER_UTILS_EXPORT | copy_file (const std::string &from, const std::string &to) |
Copy contents of one file to another. More... | |
stdx::expected< void, std::error_code > ROUTER_UTILS_EXPORT | rename_file (const std::string &from, const std::string &to) |
renames file. More... | |
bool ROUTER_UTILS_EXPORT | is_valid_socket_name (const std::string &socket, std::string &err_msg) |
Returns whether the socket name passed as parameter is valid. More... | |
int ROUTER_UTILS_EXPORT | strtoi_checked (const char *value, signed int default_result=0) noexcept |
Converts char array to signed integer, intuitively. More... | |
unsigned ROUTER_UTILS_EXPORT | strtoui_checked (const char *value, unsigned int default_result=0) noexcept |
Converts char array to unsigned integer, intuitively. More... | |
uint64_t ROUTER_UTILS_EXPORT | strtoull_checked (const char *value, uint64_t default_result=0) noexcept |
std::string ROUTER_MYSQL_EXPORT | escape_sql_string (const std::string &s, bool wildcards) |
Escape a string to be used in a SQL query Same code as used by mysql. More... | |
std::string ROUTER_MYSQL_EXPORT | escape_backticks (const std::string &string) |
std::string ROUTER_MYSQL_EXPORT | quote_identifier (const std::string &identifier, const char quote_char) |
std::string ROUTER_MYSQL_EXPORT | quote_identifier_if_needed (const std::string &ident, const char quote_char) |
Quotes the given identifier, but only if it needs to be quoted. More... | |
static std::string | get_string (const char *input_str) |
Return a string representation of the input character string. More... | |
static void | do_verify_router_id_is_ours (const uint32_t router_id, const std::string &hostname_override, MySQLSession *mysql, mysql_harness::SocketOperationsBase *socket_operations) |
static uint64_t | query_gr_cluster_count (MySQLSession *mysql) |
static InstanceType | get_instance_type (const std::string &attributes) |
static ClusterInfo | query_metadata_servers (MySQLSession *mysql, const mysqlrouter::ClusterType cluster_type) |
static std::vector< std::string > | do_get_routing_mode_queries (MySQLSession *mysql) |
static ClusterType | get_cluster_type (MySQLSession *mysql) |
static bool | was_bootstrapped_as_clusterset (MySQLSession *mysql, const unsigned router_id) |
std::unique_ptr< ClusterMetadata > | create_metadata (const MetadataSchemaVersion &schema_version, MySQLSession *mysql, const OptionsMap &options, mysql_harness::SocketOperationsBase *sockops) |
static std::vector< std::string > | do_get_grant_statements (const std::string &new_accounts) |
bool | is_reserved_word (const std::string &word) |
static bool | check_if_root (const std::string &username, SysUserOperationsBase *sys_user_operations) |
static passwd * | get_user_info (const std::string &username, SysUserOperationsBase *sys_user_operations) |
static void | set_user_priv (const std::string &username, struct passwd *user_info_arg, bool permanently, SysUserOperationsBase *sys_user_operations) |
static size_t | match_zero_or_more (const std::string &s, const std::string &pat, size_t pos_start=0) |
static size_t | skip (size_t pos_start, size_t match_len) |
static std::string | capture (const std::string &s, size_t pos_start, size_t match_len, size_t &pos_end) |
static bool | is_eol (const std::string &s, size_t pos_start) |
static bool | match_pct_encoded (const std::string &s, size_t pos_start, size_t &pos_end, std::string &pct_enc) |
static bool | match_path_chars (const std::string &s, size_t pos_start, size_t &pos_end, std::string &path_chars) |
static bool | match_scheme (const std::string &s, size_t pos_start, size_t &pos_end, std::string &scheme) |
static bool | match_colon (const std::string &s, size_t pos_start, size_t &pos_end) |
static bool | match_double_colon (const std::string &s, size_t pos_start, size_t &pos_end) |
static bool | match_userinfo (const std::string &s, size_t pos_start, size_t &pos_end, std::string &user_info) |
static void | split_userinfo (const std::string &user_info, std::string &username, std::string &password) |
static bool | match_port (const std::string &s, size_t pos_start, size_t &pos_end, std::string &port) |
static bool | match_reg_name (const std::string &s, size_t pos_start, size_t &pos_end, std::string ®_name, bool with_pct_encoded) |
static bool | match_dec_octet (const std::string &s, size_t pos_start, size_t &pos_end, std::string &dec_octet) |
static bool | match_ipv4 (const std::string &s, size_t pos_start, size_t &pos_end, std::string &ipv4_addr) |
static bool | match_ipv6_h16 (const std::string &s, size_t pos_start, size_t &pos_end, std::string &h16) |
static bool | match_ipv6_ls32 (const std::string &s, size_t pos_start, size_t &pos_end, std::string &ls32) |
static bool | match_ipv6_h16_colon (const std::string &s, size_t pos_start, size_t &pos_end, std::string &h16_colon) |
static bool | match_ipv6_1 (const std::string &s, size_t pos_start, size_t &pos_end, std::string &ipv6_addr) |
static bool | match_ipv6_2 (const std::string &s, size_t pos_start, size_t &pos_end, std::string &ipv6_addr) |
static bool | match_ipv6_h16_colon_prefix (const std::string &s, size_t pos_start, size_t max_pre_double_colon, size_t &pos_end, std::string &ipv6_addr) |
static bool | match_ipv6_3 (const std::string &s, size_t pos_start, size_t max_pre_double_colon, size_t &pos_end, std::string &ipv6_addr) |
static bool | match_ipv6_8 (const std::string &s, size_t pos_start, size_t max_pre_double_colon, size_t &pos_end, std::string &ipv6_addr) |
static bool | match_ipv6_zoneid (const std::string &s, size_t pos_start, size_t &pos_end, std::string &zoneid, bool with_pct_encoded) |
static bool | match_ipv6 (const std::string &s, size_t pos_start, size_t &pos_end, std::string &ipv6_addr) |
static bool | match_ip_literal (const std::string &s, size_t pos_start, size_t &pos_end, std::string &ip_literal, bool with_pct_encoded) |
static bool | match_host (const std::string &s, size_t pos_start, size_t &pos_end, std::string &host, bool with_pct_encoded) |
static bool | match_authority (const std::string &s, size_t pos_start, size_t &pos_end, std::string &tmp_host, std::string &tmp_port, std::string &tmp_username, std::string &tmp_password) |
static bool | match_path_segment (const std::string &s, size_t pos_start, size_t &pos_end, std::string &segment) |
static bool | match_path_empty (const std::string &s, size_t pos_start, size_t &pos_end, std::string &path) |
static bool | match_path_absolute (const std::string &s, size_t pos_start, size_t &pos_end, std::string &path) |
static bool | match_path_absolute_or_empty (const std::string &s, size_t pos_start, size_t &pos_end, std::string &path) |
static bool | match_path_rootless (const std::string &s, size_t pos_start, size_t &pos_end, std::string &path) |
static bool | match_fragment_query_chars (const std::string &s, size_t pos_start, size_t &pos_end, std::string &chars) |
static bool | match_fragment (const std::string &s, size_t pos_start, size_t &pos_end, std::string &fragment) |
static bool | match_query (const std::string &s, size_t pos_start, size_t &pos_end, std::string &query) |
std::string | pct_decode (const std::string &s) |
static URIQuery | split_query (const std::string &s) |
static bool | is_ipv6 (const std::string &s) |
static std::string | pct_encode (const std::string &s, const std::string &allowed_chars) |
static std::string | default_prompt_password (const std::string &prompt) |
template<typename RET > | |
static RET | strtoX_checked_common (const char *value, RET default_value) noexcept |
using mysqlrouter::OptionsMap = typedef std::map<std::string, std::string> |
using mysqlrouter::perm_mode = typedef mode_t |
using mysqlrouter::URIAuthority = typedef std::tuple<std::string, uint16_t, std::string, std::string> |
using mysqlrouter::URIPath = typedef std::vector<std::string> |
using mysqlrouter::URIQuery = typedef std::map<std::string, std::string> |
|
strong |
|
strong |
|
strong |
|
inline |
|
static |
bool mysqlrouter::check_group_has_quorum | ( | MySQLSession * | mysql | ) |
bool mysqlrouter::check_group_replication_online | ( | MySQLSession * | mysql | ) |
|
static |
struct passwd * mysqlrouter::check_user | ( | const std::string & | username, |
bool | must_be_root, | ||
mysqlrouter::SysUserOperationsBase * | sys_user_operations | ||
) |
Checks if the given user can be switched to or made an owner of a selected file.
std::runtime_error | in case of an error |
username | name of the system user to check |
must_be_root | make sure that the current user is root |
sys_user_operations | object for the system specific operation that should be used by the function |
void mysqlrouter::copy_file | ( | const std::string & | from, |
const std::string & | to | ||
) |
Copy contents of one file to another.
Exception thrown if open, create read or write operation fails.
std::unique_ptr< ClusterMetadata > ROUTER_CLUSTER_EXPORT mysqlrouter::create_metadata | ( | const MetadataSchemaVersion & | schema_version, |
MySQLSession * | mysql, | ||
const OptionsMap & | options, | ||
mysql_harness::SocketOperationsBase * | sockops | ||
) |
|
static |
|
static |
|
static |
|
static |
|
inline |
std::string mysqlrouter::escape_backticks | ( | const std::string & | string | ) |
std::string mysqlrouter::escape_sql_string | ( | const std::string & | s, |
bool | wildcards | ||
) |
Escape a string to be used in a SQL query Same code as used by mysql.
Handles null bytes in the middle of the string. If wildcards is true then _ and % are masked as well.
std::string mysqlrouter::find_full_executable_path | ( | const std::string & | argv0 | ) |
Returns absolute path to mysqlrouter.exe currently running.
argv0 | 1th element of argv array passed to main() (i.e. argv[0] ) |
std::runtime_error,...? |
ClusterType mysqlrouter::get_cluster_type | ( | const MetadataSchemaVersion & | schema_version, |
MySQLSession * | mysql, | ||
unsigned int | router_id = 0 |
||
) |
|
static |
std::map< std::string, std::string > mysqlrouter::get_default_paths | ( | const mysql_harness::Path & | origin | ) |
Returns predefined (computed) default paths.
Returns a map of predefined default paths, which are computed based on origin
argument. This argument serves as base directory for any predefined relative paths. The returned map consists of absolue paths.
origin | Base directory which will be prepended to any relative predefined directories |
std::invalid_argument | (std::logic_error) if origin is empty |
|
static |
std::string mysqlrouter::get_metadata_schema_uncompatible_msg | ( | const mysqlrouter::MetadataSchemaVersion & | version | ) |
MetadataSchemaVersion mysqlrouter::get_metadata_schema_version | ( | MySQLSession * | mysql | ) |
|
static |
Return a string representation of the input character string.
input_str | A character string. |
uint16_t mysqlrouter::get_tcp_port | ( | const std::string & | data | ) |
Validates a string containing a TCP port.
Validates whether the data can be used as a TCP port. A TCP port is a valid number in the range of 0 and 65535. The returned integer is of type uint16_t.
An empty data string will result in TCP port 0 to be returned.
Throws runtime_error when the given string can not be converted to an integer or when the integer is to big.
data | string containing the TCP port number |
|
static |
std::string mysqlrouter::hexdump | ( | const unsigned char * | buffer, |
size_t | count | ||
) |
Dumps buffer as hex values.
Debugging function which dumps the given buffer as hex values in rows of 16 bytes. When literals is true, characters in a-z or A-Z, are printed as-is.
buffer | char array or front of vector<uint8_t> |
count | number of bytes to dump |
|
static |
|
static |
bool mysqlrouter::is_part_of_cluster_set | ( | MySQLSession * | mysql | ) |
bool mysqlrouter::is_reserved_word | ( | const std::string & | word | ) |
bool mysqlrouter::is_valid_socket_name | ( | const std::string & | socket, |
std::string & | err_msg | ||
) |
Returns whether the socket name passed as parameter is valid.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
bool mysqlrouter::metadata_schema_version_is_compatible | ( | const mysqlrouter::MetadataSchemaVersion & | required, |
const mysqlrouter::MetadataSchemaVersion & | available | ||
) |
bool mysqlrouter::metadata_schema_version_is_compatible | ( | const mysqlrouter::MetadataSchemaVersion(&) | required[N], |
const mysqlrouter::MetadataSchemaVersion & | available | ||
) |
std::string mysqlrouter::ms_to_seconds_string | ( | const std::chrono::milliseconds & | msec | ) |
bool mysqlrouter::my_check_access | ( | const std::string & | path | ) |
std::ostream & mysqlrouter::operator<< | ( | std::ostream & | strm, |
const URI & | uri | ||
) |
std::string mysqlrouter::pct_decode | ( | const std::string & | s | ) |
|
static |
std::string mysqlrouter::prompt_password | ( | const std::string & | prompt | ) |
Prompts for a password from the console.
|
static |
|
static |
std::string mysqlrouter::quote_identifier | ( | const std::string & | identifier, |
const char | quote_char | ||
) |
std::string mysqlrouter::quote_identifier_if_needed | ( | const std::string & | ident, |
const char | quote_char | ||
) |
Quotes the given identifier, but only if it needs to be quoted.
http://dev.mysql.com/doc/refman/5.1/en/identifiers.html specifies what is allowed in unquoted identifiers. Leading numbers are not strictly forbidden but discouraged as they may lead to ambiguous behavior.
stdx::expected< void, std::error_code > mysqlrouter::rename_file | ( | const std::string & | from, |
const std::string & | to | ||
) |
renames file.
The function will overwrite the 'to' file if already exists.
from | old filename |
to | new filename |
void mysqlrouter::set_owner_if_file_exists | ( | const std::string & | filepath, |
const std::string & | username, | ||
struct passwd * | user_info_arg, | ||
mysqlrouter::SysUserOperationsBase * | sys_user_operations | ||
) |
Sets the owner of selected file/directory if it exists.
std::runtime_error | in case of an error |
filepath | path to the file/directory this operation applies to |
username | name of the system user that should be new owner of the file |
user_info_arg | passwd structure for the system user that should be new owner of the file |
sys_user_operations | object for the system specific operation that should be used by the function |
void mysqlrouter::set_prompt_password | ( | const std::function< std::string(const std::string &)> & | f | ) |
Override default prompt password function.
void mysqlrouter::set_user | ( | const std::string & | username, |
bool | permanently = false , |
||
mysqlrouter::SysUserOperationsBase * | sys_user_operations = SysUserOperations::instance() |
||
) |
Sets effective user of the calling process.
std::runtime_error | in case of an error |
username | name of the system user that the process should switch to |
permanently | if it's tru then if the root is dropping privileges it can't be regained after this call |
sys_user_operations | object for the system specific operation that should be used by the function |
|
static |
stdx::expected< void, std::string > mysqlrouter::setup_metadata_session | ( | MySQLSession & | session | ) |
|
inline |
|
static |
|
static |
|
static |
std::optional< InstanceType > mysqlrouter::str_to_instance_type | ( | const std::string & | s | ) |
|
noexcept |
Converts char array to signed integer, intuitively.
Using strtol() can be daunting. This function wraps its with logic to ease its use. Features:
value | char array to get converted |
default_result | value to return in case of nullptr being passed |
|
noexcept |
Converts char array to unsigned integer, intuitively.
adding check for null parameter and some conversion restrictions.
Using strtoul() can be daunting. This function wraps its with logic to ease its use. Features:
value | char array to get converted |
default_result | value to return in case of nullptr being passed |
|
noexcept |
|
staticnoexcept |
|
noexcept |
Substitutes placeholders of environment variables in a string.
Substitutes placeholders of environment variables in a string. A placeholder contains the name of the variable and will be fetched from the environment. The substitution is done in-place.
Note that it is not an error to pass a string with no variable to be substituted - in such case success will be returned, and the original string will remain unchanged. Also note, that if an error occurs, the resulting string value is undefined (it will be left in an inconsistent state).
std::string mysqlrouter::substitute_variable | ( | const std::string & | s, |
const std::string & | name, | ||
const std::string & | value | ||
) |
std::string mysqlrouter::to_string | ( | const ClusterType | cluster_type | ) |
std::string mysqlrouter::to_string | ( | const InstanceType | instance_type | ) |
std::string mysqlrouter::to_string | ( | const MetadataSchemaVersion & | version | ) |
std::string mysqlrouter::to_string | ( | const mysqlrouter::MetadataSchemaVersion(&) | version[N] | ) |
std::string mysqlrouter::to_string | ( | const T & | data | ) |
std::string mysqlrouter::to_string | ( | const TargetCluster::InvalidatedClusterRoutingPolicy | policy | ) |
|
static |
|
static |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
const bool mysqlrouter::kDefaultUseGRNotificationsCluster = false |
const bool mysqlrouter::kDefaultUseGRNotificationsClusterSet = true |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
const perm_mode mysqlrouter::kStrictDirectoryPerm = S_IRWXU |
Constant for directory accessible only for the owner.
|
constexpr |