MySQL 8.0.29
Source Code Documentation
mysqlrouter Namespace Reference

Namespaces

 
namespace  impl
 

Classes

class  AutoCleaner
 Automatic cleanup on scope exit utility class. More...
 
struct  ClusterInfo
 
class  ClusterMetadata
 
class  ClusterMetadataAR
 
class  ClusterMetadataGR
 
class  ClusterMetadataGRInClusterSet
 
class  ClusterMetadataGRV1
 
class  ClusterMetadataGRV2
 
class  ConfigGenerator
 
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_V1 , GR_V2 , GR_CS , RS_V2 }
 
enum  SqlStringFlags { QuoteOnlyIfNeeded = 1 << 0 , UseAnsiQuotes = 1 << 1 , EndOfInput = 1 << 7 }
 

Functions

std::string ROUTER_LIB_EXPORT to_string (const MetadataSchemaVersion &version)
 
MetadataSchemaVersion ROUTER_LIB_EXPORT get_metadata_schema_version (MySQLSession *mysql)
 
bool ROUTER_LIB_EXPORT metadata_schema_version_is_compatible (const mysqlrouter::MetadataSchemaVersion &required, const mysqlrouter::MetadataSchemaVersion &available)
 
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_LIB_EXPORT get_cluster_type (const MetadataSchemaVersion &schema_version, MySQLSession *mysql, unsigned int router_id=0)
 
std::string ROUTER_LIB_EXPORT to_string (const ClusterType cluster_type)
 
stdx::expected< void, std::string > ROUTER_LIB_EXPORT setup_metadata_session (MySQLSession &session)
 
std::map< std::string, std::string > ROUTER_LIB_EXPORT get_default_paths (const mysql_harness::Path &origin)
 Returns predefined (computed) default paths. More...
 
std::string ROUTER_LIB_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...
 
std::ostream & operator<< (std::ostream &strm, const URI &uri)
 
template<typename T >
std::string to_string (const T &data)
 
std::string ROUTER_LIB_EXPORT ms_to_seconds_string (const std::chrono::milliseconds &msec)
 
uint16_t 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_LIB_EXPORT prompt_password (const std::string &prompt)
 Prompts for a password from the console. More...
 
void ROUTER_LIB_EXPORT set_prompt_password (const std::function< std::string(const std::string &)> &f)
 Override default prompt password function. More...
 
bool ROUTER_LIB_EXPORT substitute_envvar (std::string &line) noexcept
 Substitutes placeholders of environment variables in a string. More...
 
std::string ROUTER_LIB_EXPORT substitute_variable (const std::string &s, const std::string &name, const std::string &value)
 
bool my_check_access (const std::string &path)
 
void copy_file (const std::string &from, const std::string &to)
 Copy contents of one file to another. More...
 
stdx::expected< void, std::error_code > rename_file (const std::string &from, const std::string &to)
 renames file. More...
 
bool ROUTER_LIB_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 strtoi_checked (const char *value, signed int default_result=0) noexcept
 Converts char array to signed integer, intuitively. More...
 
unsigned ROUTER_LIB_EXPORT strtoui_checked (const char *value, unsigned int default_result=0) noexcept
 Converts char array to unsigned integer, intuitively. More...
 
uint64_t ROUTER_LIB_EXPORT strtoull_checked (const char *value, uint64_t default_result=0) noexcept
 
std::string ROUTER_LIB_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_LIB_EXPORT escape_backticks (const std::string &string)
 
std::string ROUTER_LIB_EXPORT quote_identifier (const std::string &identifier, const char quote_char)
 
std::string ROUTER_LIB_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 verify_router_id_is_ours_v1 (const uint32_t router_id, const std::string &hostname_override, MySQLSession *mysql, mysql_harness::SocketOperationsBase *socket_operations)
 
static void verify_router_id_is_ours_v2 (const uint32_t router_id, const std::string &hostname_override, MySQLSession *mysql, mysql_harness::SocketOperationsBase *socket_operations)
 
static bool check_group_replication_online (MySQLSession *mysql)
 
static bool check_group_has_quorum (MySQLSession *mysql)
 
static uint64_t query_gr_cluster_count (MySQLSession *mysql, const bool metadata_v2)
 
static ClusterInfo query_metadata_servers (MySQLSession *mysql, const bool metadata_v2)
 
static std::vector< std::string > do_get_routing_mode_queries (MySQLSession *mysql, const bool metadata_v2, const std::string &cluster_name)
 
static ClusterType get_cluster_type (MySQLSession *mysql)
 
static bool is_part_of_cluster_set (MySQLSession *mysql)
 
static bool was_bootstrapped_as_clusterset (MySQLSession *mysql, const unsigned router_id)
 
std::unique_ptr< ClusterMetadatacreate_metadata (const MetadataSchemaVersion &schema_version, MySQLSession *mysql, const OptionsMap &options, mysql_harness::SocketOperationsBase *sockops)
 
static std::vector< std::string > get_grant_statements_v1 (const std::string &new_accounts)
 
static std::vector< std::string > get_grant_statements_v2 (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 &reg_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)
 
static 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
 

Variables

constexpr MetadataSchemaVersion kRequiredBootstrapSchemaVersion []
 
constexpr MetadataSchemaVersion kRequiredRoutingMetadataSchemaVersion []
 
constexpr MetadataSchemaVersion kNewMetadataVersion {2, 0, 0}
 
constexpr MetadataSchemaVersion kClusterSetsMetadataVersion {2, 1, 0}
 
constexpr MetadataSchemaVersion kUpgradeInProgressMetadataVersion {0, 0, 0}
 
const perm_mode kStrictDirectoryPerm = S_IRWXU
 Constant for directory accessible only for the owner. More...
 
constexpr const char * kDefaultSqlMode
 
static std::function< std::string(const std::string &)> g_prompt_password
 

Typedef Documentation

◆ OptionsMap

using mysqlrouter::OptionsMap = typedef std::map<std::string, std::string>

◆ perm_mode

using mysqlrouter::perm_mode = typedef mode_t

◆ URIAuthority

using mysqlrouter::URIAuthority = typedef std::tuple<std::string, uint16_t, std::string, std::string>

◆ URIPath

using mysqlrouter::URIPath = typedef std::vector<std::string>

◆ URIQuery

using mysqlrouter::URIQuery = typedef std::map<std::string, std::string>

Enumeration Type Documentation

◆ ClusterType

enum class mysqlrouter::ClusterType
strong
Enumerator
GR_V1 
GR_V2 
GR_CS 
RS_V2 

◆ SqlStringFlags

Enumerator
QuoteOnlyIfNeeded 
UseAnsiQuotes 
EndOfInput 

Function Documentation

◆ capture()

static std::string mysqlrouter::capture ( const std::string &  s,
size_t  pos_start,
size_t  match_len,
size_t &  pos_end 
)
static

◆ check_group_has_quorum()

static bool mysqlrouter::check_group_has_quorum ( MySQLSession mysql)
static

◆ check_group_replication_online()

static bool mysqlrouter::check_group_replication_online ( MySQLSession mysql)
static

◆ check_if_root()

static bool mysqlrouter::check_if_root ( const std::string &  username,
SysUserOperationsBase sys_user_operations 
)
static

◆ check_user()

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.

Exceptions
std::runtime_errorin case of an error
Parameters
usernamename of the system user to check
must_be_rootmake sure that the current user is root
sys_user_operationsobject for the system specific operation that should be used by the function
Returns
pointer to the user's passwd structure if the user can be switched to or nullptr otherwise

◆ copy_file()

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.

◆ create_metadata()

std::unique_ptr< ClusterMetadata > mysqlrouter::create_metadata ( const MetadataSchemaVersion schema_version,
MySQLSession mysql,
const OptionsMap options,
mysql_harness::SocketOperationsBase sockops 
)

◆ default_prompt_password()

static std::string mysqlrouter::default_prompt_password ( const std::string &  prompt)
static

◆ do_get_routing_mode_queries()

static std::vector< std::string > mysqlrouter::do_get_routing_mode_queries ( MySQLSession mysql,
const bool  metadata_v2,
const std::string &  cluster_name 
)
static

◆ escape_backticks()

std::string mysqlrouter::escape_backticks ( const std::string &  string)

◆ escape_sql_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.

◆ find_full_executable_path()

std::string mysqlrouter::find_full_executable_path ( const std::string &  argv0)

Returns absolute path to mysqlrouter.exe currently running.

Parameters
argv01th element of argv array passed to main() (i.e. argv[0])
Exceptions
std::runtime_error,...?
Note
argv0 is currently ignored on Windows platforms

◆ get_cluster_type() [1/2]

ClusterType mysqlrouter::get_cluster_type ( const MetadataSchemaVersion schema_version,
MySQLSession mysql,
unsigned int  router_id = 0 
)

◆ get_cluster_type() [2/2]

static ClusterType mysqlrouter::get_cluster_type ( MySQLSession mysql)
static

◆ get_default_paths()

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.

Parameters
originBase directory which will be prepended to any relative predefined directories
Exceptions
std::invalid_argument(std::logic_error) if origin is empty

◆ get_grant_statements_v1()

static std::vector< std::string > mysqlrouter::get_grant_statements_v1 ( const std::string &  new_accounts)
static

◆ get_grant_statements_v2()

static std::vector< std::string > mysqlrouter::get_grant_statements_v2 ( const std::string &  new_accounts)
static

◆ get_metadata_schema_version()

MetadataSchemaVersion mysqlrouter::get_metadata_schema_version ( MySQLSession mysql)

◆ get_string()

static std::string mysqlrouter::get_string ( const char *  input_str)
static

Return a string representation of the input character string.

Parameters
input_strA character string.
Returns
A string object encapsulation of the input character string. An empty string if input string is nullptr.

◆ get_tcp_port()

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.

Parameters
datastring containing the TCP port number
Returns
uint16_t the TCP port number

◆ get_user_info()

static passwd * mysqlrouter::get_user_info ( const std::string &  username,
SysUserOperationsBase sys_user_operations 
)
static

◆ hexdump()

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.

Parameters
bufferchar array or front of vector<uint8_t>
countnumber of bytes to dump
Returns
string containing the dump

◆ is_eol()

static bool mysqlrouter::is_eol ( const std::string &  s,
size_t  pos_start 
)
static

◆ is_ipv6()

static bool mysqlrouter::is_ipv6 ( const std::string &  s)
static

◆ is_part_of_cluster_set()

static bool mysqlrouter::is_part_of_cluster_set ( MySQLSession mysql)
static

◆ is_reserved_word()

bool mysqlrouter::is_reserved_word ( const std::string &  word)

◆ is_valid_socket_name()

bool mysqlrouter::is_valid_socket_name ( const std::string &  socket,
std::string &  err_msg 
)

Returns whether the socket name passed as parameter is valid.

◆ match_authority()

static bool mysqlrouter::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

◆ match_colon()

static bool mysqlrouter::match_colon ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end 
)
static

◆ match_dec_octet()

static bool mysqlrouter::match_dec_octet ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end,
std::string &  dec_octet 
)
static

◆ match_double_colon()

static bool mysqlrouter::match_double_colon ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end 
)
static

◆ match_fragment()

static bool mysqlrouter::match_fragment ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end,
std::string &  fragment 
)
static

◆ match_fragment_query_chars()

static bool mysqlrouter::match_fragment_query_chars ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end,
std::string &  chars 
)
static

◆ match_host()

static bool mysqlrouter::match_host ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end,
std::string &  host,
bool  with_pct_encoded 
)
static

◆ match_ip_literal()

static bool mysqlrouter::match_ip_literal ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end,
std::string &  ip_literal,
bool  with_pct_encoded 
)
static

◆ match_ipv4()

static bool mysqlrouter::match_ipv4 ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end,
std::string &  ipv4_addr 
)
static

◆ match_ipv6()

static bool mysqlrouter::match_ipv6 ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end,
std::string &  ipv6_addr 
)
static

◆ match_ipv6_1()

static bool mysqlrouter::match_ipv6_1 ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end,
std::string &  ipv6_addr 
)
static

◆ match_ipv6_2()

static bool mysqlrouter::match_ipv6_2 ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end,
std::string &  ipv6_addr 
)
static

◆ match_ipv6_3()

static bool mysqlrouter::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

◆ match_ipv6_8()

static bool mysqlrouter::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

◆ match_ipv6_h16()

static bool mysqlrouter::match_ipv6_h16 ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end,
std::string &  h16 
)
static

◆ match_ipv6_h16_colon()

static bool mysqlrouter::match_ipv6_h16_colon ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end,
std::string &  h16_colon 
)
static

◆ match_ipv6_h16_colon_prefix()

static bool mysqlrouter::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

◆ match_ipv6_ls32()

static bool mysqlrouter::match_ipv6_ls32 ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end,
std::string &  ls32 
)
static

◆ match_ipv6_zoneid()

static bool mysqlrouter::match_ipv6_zoneid ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end,
std::string &  zoneid,
bool  with_pct_encoded 
)
static

◆ match_path_absolute()

static bool mysqlrouter::match_path_absolute ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end,
std::string &  path 
)
static

◆ match_path_absolute_or_empty()

static bool mysqlrouter::match_path_absolute_or_empty ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end,
std::string &  path 
)
static

◆ match_path_chars()

static bool mysqlrouter::match_path_chars ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end,
std::string &  path_chars 
)
static

◆ match_path_empty()

static bool mysqlrouter::match_path_empty ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end,
std::string &  path 
)
static

◆ match_path_rootless()

static bool mysqlrouter::match_path_rootless ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end,
std::string &  path 
)
static

◆ match_path_segment()

static bool mysqlrouter::match_path_segment ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end,
std::string &  segment 
)
static

◆ match_pct_encoded()

static bool mysqlrouter::match_pct_encoded ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end,
std::string &  pct_enc 
)
static

◆ match_port()

static bool mysqlrouter::match_port ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end,
std::string &  port 
)
static

◆ match_query()

static bool mysqlrouter::match_query ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end,
std::string &  query 
)
static

◆ match_reg_name()

static bool mysqlrouter::match_reg_name ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end,
std::string &  reg_name,
bool  with_pct_encoded 
)
static

◆ match_scheme()

static bool mysqlrouter::match_scheme ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end,
std::string &  scheme 
)
static

◆ match_userinfo()

static bool mysqlrouter::match_userinfo ( const std::string &  s,
size_t  pos_start,
size_t &  pos_end,
std::string &  user_info 
)
static

◆ match_zero_or_more()

static size_t mysqlrouter::match_zero_or_more ( const std::string &  s,
const std::string &  pat,
size_t  pos_start = 0 
)
static

◆ metadata_schema_version_is_compatible() [1/2]

bool mysqlrouter::metadata_schema_version_is_compatible ( const mysqlrouter::MetadataSchemaVersion required,
const mysqlrouter::MetadataSchemaVersion available 
)

◆ metadata_schema_version_is_compatible() [2/2]

template<size_t N>
bool mysqlrouter::metadata_schema_version_is_compatible ( const mysqlrouter::MetadataSchemaVersion(&)  required[N],
const mysqlrouter::MetadataSchemaVersion available 
)

◆ ms_to_seconds_string()

std::string mysqlrouter::ms_to_seconds_string ( const std::chrono::milliseconds &  msec)

◆ my_check_access()

bool mysqlrouter::my_check_access ( const std::string &  path)

◆ operator<<()

std::ostream & mysqlrouter::operator<< ( std::ostream &  strm,
const URI uri 
)

◆ pct_decode()

static std::string mysqlrouter::pct_decode ( const std::string &  s)
static

◆ pct_encode()

static std::string mysqlrouter::pct_encode ( const std::string &  s,
const std::string &  allowed_chars 
)
static

◆ prompt_password()

std::string mysqlrouter::prompt_password ( const std::string &  prompt)

Prompts for a password from the console.

◆ query_gr_cluster_count()

static uint64_t mysqlrouter::query_gr_cluster_count ( MySQLSession mysql,
const bool  metadata_v2 
)
static

◆ query_metadata_servers()

static ClusterInfo mysqlrouter::query_metadata_servers ( MySQLSession mysql,
const bool  metadata_v2 
)
static

◆ quote_identifier()

std::string mysqlrouter::quote_identifier ( const std::string &  identifier,
const char  quote_char 
)

◆ quote_identifier_if_needed()

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.

◆ rename_file()

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.

Parameters
fromold filename
tonew filename
Returns
stdx::expected<void, std::error_code>

◆ set_owner_if_file_exists()

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.

Exceptions
std::runtime_errorin case of an error
Parameters
filepathpath to the file/directory this operation applies to
usernamename of the system user that should be new owner of the file
user_info_argpasswd structure for the system user that should be new owner of the file
sys_user_operationsobject for the system specific operation that should be used by the function

◆ set_prompt_password()

void mysqlrouter::set_prompt_password ( const std::function< std::string(const std::string &)> &  f)

Override default prompt password function.

◆ set_user()

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.

Exceptions
std::runtime_errorin case of an error
Parameters
usernamename of the system user that the process should switch to
permanentlyif it's tru then if the root is dropping privileges it can't be regained after this call
sys_user_operationsobject for the system specific operation that should be used by the function

◆ set_user_priv()

static void mysqlrouter::set_user_priv ( const std::string &  username,
struct passwd *  user_info_arg,
bool  permanently,
SysUserOperationsBase sys_user_operations 
)
static

◆ setup_metadata_session()

stdx::expected< void, std::string > mysqlrouter::setup_metadata_session ( MySQLSession session)

◆ skip()

static size_t mysqlrouter::skip ( size_t  pos_start,
size_t  match_len 
)
static

◆ split_query()

static URIQuery mysqlrouter::split_query ( const std::string &  s)
static

◆ split_userinfo()

static void mysqlrouter::split_userinfo ( const std::string &  user_info,
std::string &  username,
std::string &  password 
)
static

◆ strtoi_checked()

int mysqlrouter::strtoi_checked ( const char *  value,
signed int  default_result = 0 
)
noexcept

Converts char array to signed integer, intuitively.

Using strtol() can be daunting. This function wraps its with logic to ease its use. Features:

  • errno value is unaltered
  • on error, default value is returned
  • unlike strtol(), this function will fail (return default_result) if anything other than digits and sign are present in the char array. Inputs such as " 12" or "abc12.3" will fail, while strtol() would return 12.
Parameters
valuechar array to get converted
default_resultvalue to return in case of nullptr being passed

◆ strtoui_checked()

unsigned mysqlrouter::strtoui_checked ( const char *  value,
unsigned int  default_result = 0 
)
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:

  • errno value is unaltered
  • on error, default value is returned
  • unlike strtoul(), this function will fail (return default_result) if anything other than digits and sign are present in the char array. Inputs such as " 12" or "abc12.3" will fail, while strtoul() would return 12.
Parameters
valuechar array to get converted
default_resultvalue to return in case of nullptr being passed

◆ strtoull_checked()

uint64_t mysqlrouter::strtoull_checked ( const char *  value,
uint64_t  default_result = 0 
)
noexcept

◆ strtoX_checked_common()

template<typename RET >
static RET mysqlrouter::strtoX_checked_common ( const char *  value,
RET  default_value 
)
staticnoexcept

◆ substitute_envvar()

bool mysqlrouter::substitute_envvar ( std::string &  line)
noexcept

Substitutes placeholders of environment variables in a string.

Substitutes placeholders of environement 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).

Returns
bool (success flag)

◆ substitute_variable()

std::string mysqlrouter::substitute_variable ( const std::string &  s,
const std::string &  name,
const std::string &  value 
)

◆ to_string() [1/4]

std::string mysqlrouter::to_string ( const ClusterType  cluster_type)

◆ to_string() [2/4]

std::string mysqlrouter::to_string ( const MetadataSchemaVersion version)

◆ to_string() [3/4]

template<size_t N>
std::string mysqlrouter::to_string ( const mysqlrouter::MetadataSchemaVersion(&)  version[N])

◆ to_string() [4/4]

template<typename T >
std::string mysqlrouter::to_string ( const T &  data)

◆ verify_router_id_is_ours_v1()

static void mysqlrouter::verify_router_id_is_ours_v1 ( const uint32_t  router_id,
const std::string &  hostname_override,
MySQLSession mysql,
mysql_harness::SocketOperationsBase socket_operations 
)
static

◆ verify_router_id_is_ours_v2()

static void mysqlrouter::verify_router_id_is_ours_v2 ( const uint32_t  router_id,
const std::string &  hostname_override,
MySQLSession mysql,
mysql_harness::SocketOperationsBase socket_operations 
)
static

◆ was_bootstrapped_as_clusterset()

static bool mysqlrouter::was_bootstrapped_as_clusterset ( MySQLSession mysql,
const unsigned  router_id 
)
static

Variable Documentation

◆ g_prompt_password

std::function<std::string(const std::string &)> mysqlrouter::g_prompt_password
static
Initial value:
=
static std::string default_prompt_password(const std::string &prompt)
Definition: utils.cc:240

◆ kClusterSetsMetadataVersion

constexpr MetadataSchemaVersion mysqlrouter::kClusterSetsMetadataVersion {2, 1, 0}
constexpr

◆ kDefaultSqlMode

constexpr const char* mysqlrouter::kDefaultSqlMode
constexpr
Initial value:
=
"ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,"
"NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"

◆ kNewMetadataVersion

constexpr MetadataSchemaVersion mysqlrouter::kNewMetadataVersion {2, 0, 0}
constexpr

◆ kRequiredBootstrapSchemaVersion

constexpr MetadataSchemaVersion mysqlrouter::kRequiredBootstrapSchemaVersion[]
constexpr
Initial value:
{{1, 0, 0},
{2, 0, 0}}

◆ kRequiredRoutingMetadataSchemaVersion

constexpr MetadataSchemaVersion mysqlrouter::kRequiredRoutingMetadataSchemaVersion[]
constexpr
Initial value:
{
{1, 0, 0}, {2, 0, 0}}

◆ kStrictDirectoryPerm

const perm_mode mysqlrouter::kStrictDirectoryPerm = S_IRWXU

Constant for directory accessible only for the owner.

◆ kUpgradeInProgressMetadataVersion

constexpr MetadataSchemaVersion mysqlrouter::kUpgradeInProgressMetadataVersion {0, 0, 0}
constexpr