![]() |
MySQL 9.3.0
Source Code Documentation
|
#include <mysql_session.h>
Classes | |
class | Error |
class | MYSQL_RES_Deleter |
class | ResultRow |
class | Transaction |
Public Member Functions | |
MySQLSession () | |
virtual | ~MySQLSession () |
virtual void | set_ssl_options (mysql_ssl_mode ssl_mode, const std::string &tls_version, const std::string &ssl_cipher, const std::string &ca, const std::string &capath, const std::string &crl, const std::string &crlpath) |
uint64_t | connection_id () |
mysql_ssl_mode | ssl_mode () const |
std::string | tls_version () const |
std::string | ssl_cipher () const |
std::string | ssl_ca () const |
std::string | ssl_capath () const |
std::string | ssl_crl () const |
std::string | ssl_crlpath () const |
std::string | ssl_cert () const |
std::string | ssl_key () const |
int | connect_timeout () const |
int | read_timeout () const |
virtual void | set_ssl_cert (const std::string &cert, const std::string &key) |
template<class SettableMysqlOption > | |
stdx::expected< void, MysqlError > | set_option (const SettableMysqlOption &opt) |
set a mysql option. More... | |
template<class GettableMysqlOption > | |
bool | get_option (GettableMysqlOption &opt) const |
get a mysql option. More... | |
void | connect (const std::string &host, unsigned int port, const std::string &username, const std::string &password, const std::string &unix_socket, const std::string &default_schema, int connect_timeout=kDefaultConnectTimeout, int read_timeout=kDefaultReadTimeout, unsigned long extra_client_flags=0) |
void | connect (const MySQLSession &other, const std::string &username, const std::string &password) |
void | change_user (const std::string &user, const std::string &password, const std::string &db) |
virtual void | connect (const std::string &host, unsigned int port, const std::string &username, const mysql_harness::SecureString &password, const std::string &unix_socket, const std::string &default_schema, int connect_timeout=kDefaultConnectTimeout, int read_timeout=kDefaultReadTimeout, unsigned long extra_client_flags=0) |
virtual void | connect (const MySQLSession &other, const std::string &username, const mysql_harness::SecureString &password) |
Connect using the same settings and parameters that were used for the last other.connect() using provided credentials. More... | |
virtual void | change_user (const std::string &user, const mysql_harness::SecureString &password, const std::string &db) |
virtual void | disconnect () |
virtual void | reset () |
virtual uint64_t | prepare (const std::string &query) |
virtual void | prepare_execute_with_bind_parameters (uint64_t ps_id, std::vector< MYSQL_BIND > bind_parameters, const ResultRowProcessor &processor, const FieldValidator &validator, const OnResultSetEnd &on_resultset_end) |
virtual void | prepare_remove (uint64_t ps_id) |
virtual void | execute (const std::string &query) |
virtual void | query (const std::string &query, const ResultRowProcessor &processor, const FieldValidator &validator) |
virtual std::unique_ptr< MySQLSession::ResultRow > | query_one (const std::string &query, const FieldValidator &validator) |
void | query (const std::string &query, const RowProcessor &processor, const FieldValidator &validator) |
void | query (const std::string &stmt, const RowProcessor &processor) |
virtual std::unique_ptr< MySQLSession::ResultRow > | query_one (const std::string &stmt) |
virtual int | ping () |
virtual bool | execute_nb (const std::string &query) |
virtual uint64_t | last_insert_id () noexcept |
virtual uint64_t | affected_rows () noexcept |
virtual unsigned | warning_count () noexcept |
virtual std::string | quote (const std::string &s, char qchar='\'') const |
virtual bool | is_connected () noexcept |
const std::string & | get_address () noexcept |
virtual const char * | last_sqlstate () |
virtual const char * | last_error () |
virtual unsigned int | last_errno () |
virtual const char * | ssl_cipher () |
virtual bool | has_data_on_socket () |
virtual std::vector< std::string > | get_session_tracker_data (enum enum_session_state_type type) |
virtual bool | is_ssl_session_reused () |
virtual unsigned long | server_version () |
MYSQL * | get_handle () |
Static Public Member Functions | |
static mysql_ssl_mode | parse_ssl_mode (std::string ssl_mode) |
static const char * | ssl_mode_to_string (mysql_ssl_mode ssl_mode) noexcept |
Static Public Attributes | |
static constexpr int | kDefaultConnectTimeout = 5 |
static constexpr int | kDefaultReadTimeout = 30 |
static const char | kSslModeDisabled [] = "DISABLED" |
static const char | kSslModePreferred [] = "PREFERRED" |
static const char | kSslModeRequired [] = "REQUIRED" |
static const char | kSslModeVerifyCa [] = "VERIFY_CA" |
static const char | kSslModeVerifyIdentity [] |
Private Types | |
enum class | AsyncQueryState { kNone , kQuery , kStoreResult } |
using | mysql_result_type = std::unique_ptr< MYSQL_RES, MYSQL_RES_Deleter > |
Private Member Functions | |
stdx::expected< mysql_result_type, MysqlError > | real_query (const std::string &q) |
run query. More... | |
stdx::expected< mysql_result_type, MysqlError > | real_query_nb (const std::string &q) |
stdx::expected< mysql_result_type, MysqlError > | logged_real_query (const std::string &q) |
log query after running it. More... | |
stdx::expected< mysql_result_type, MysqlError > | logged_real_query_nb (const std::string &q) |
void | throw_mysqlerror (MYSQL_STMT *stmt, uint64_t ps_id) |
Private Attributes | |
struct { | |
std::string host | |
unsigned int port {} | |
std::string unix_socket | |
std::string default_schema | |
} | connect_params_ |
uint64_t | last_stmt_id {0} |
std::map< uint64_t, MYSQL_STMT * > | stmts_ |
MYSQL * | connection_ |
bool | connected_ |
std::string | connection_address_ |
SQLLogFilter | log_filter_ |
unsigned long | extra_client_flags_ {0} |
uint64_t | connection_id_ {0} |
AsyncQueryState | async_state_ = AsyncQueryState::kNone |
bool | async_query_logged_ = false |
mysql_harness::logging::DomainLogger | logger_ {"sql"} |
using mysqlrouter::MySQLSession::BooleanOption = impl::Option<Opt, bool> |
using mysqlrouter::MySQLSession::CanHandleExpiredPasswords = BooleanOption<MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS> |
using mysqlrouter::MySQLSession::CompressionAlgorithms = ConstCharOption<MYSQL_OPT_COMPRESSION_ALGORITHMS> |
using mysqlrouter::MySQLSession::ConnectAttributeDelete = BooleanOption<MYSQL_OPT_CONNECT_ATTR_DELETE> |
using mysqlrouter::MySQLSession::ConnectAttributeReset = BooleanOption<MYSQL_OPT_CONNECT_ATTR_RESET> |
using mysqlrouter::MySQLSession::ConstCharOption = impl::Option<Opt, const char *> |
using mysqlrouter::MySQLSession::EnableCleartextPlugin = BooleanOption<MYSQL_ENABLE_CLEARTEXT_PLUGIN> |
typedef std::function<void(unsigned, MYSQL_FIELD *)> mysqlrouter::MySQLSession::FieldValidator |
using mysqlrouter::MySQLSession::GetServerPublicKey = BooleanOption<MYSQL_OPT_GET_SERVER_PUBLIC_KEY> |
using mysqlrouter::MySQLSession::IntegerOption = impl::Option<Opt, unsigned int> |
using mysqlrouter::MySQLSession::LongOption = impl::Option<Opt, unsigned long> |
|
private |
typedef std::function<void()> mysqlrouter::MySQLSession::OnResultSetEnd |
using mysqlrouter::MySQLSession::OptionalResultsetMetadata = BooleanOption<MYSQL_OPT_OPTIONAL_RESULTSET_METADATA> |
typedef std::function<bool(const ResultRow &)> mysqlrouter::MySQLSession::ResultRowProcessor |
typedef std::vector<const char *> mysqlrouter::MySQLSession::Row |
typedef std::function<bool(const Row &)> mysqlrouter::MySQLSession::RowProcessor |
using mysqlrouter::MySQLSession::SharedMemoryBasename = ConstCharOption<MYSQL_SHARED_MEMORY_BASE_NAME> |
using mysqlrouter::MySQLSession::ZstdCompressionLevel = IntegerOption<MYSQL_OPT_ZSTD_COMPRESSION_LEVEL> |
|
strongprivate |
MySQLSession::MySQLSession | ( | ) |
|
virtual |
|
virtualnoexcept |
|
virtual |
Reimplemented in collector::CountedMySQLSession.
void MySQLSession::change_user | ( | const std::string & | user, |
const std::string & | password, | ||
const std::string & | db | ||
) |
|
virtual |
Connect using the same settings and parameters that were used for the last other.connect() using provided credentials.
void MySQLSession::connect | ( | const MySQLSession & | other, |
const std::string & | username, | ||
const std::string & | password | ||
) |
|
virtual |
Reimplemented in collector::CountedMySQLSession.
void MySQLSession::connect | ( | const std::string & | host, |
unsigned int | port, | ||
const std::string & | username, | ||
const std::string & | password, | ||
const std::string & | unix_socket, | ||
const std::string & | default_schema, | ||
int | connect_timeout = kDefaultConnectTimeout , |
||
int | read_timeout = kDefaultReadTimeout , |
||
unsigned long | extra_client_flags = 0 |
||
) |
int MySQLSession::connect_timeout | ( | ) | const |
uint64_t MySQLSession::connection_id | ( | ) |
|
virtual |
|
virtual |
Reimplemented in collector::CountedMySQLSession.
|
virtual |
|
inlinenoexcept |
|
inline |
|
inline |
get a mysql option.
[in,out] | opt | option to query. |
true | on success. |
false | if option is not known. |
|
virtual |
|
virtual |
|
inlinevirtualnoexcept |
|
virtual |
|
virtual |
|
virtual |
|
virtualnoexcept |
|
virtual |
|
private |
log query after running it.
|
private |
|
static |
|
virtual |
|
virtual |
Reimplemented in collector::CountedMySQLSession.
|
virtual |
Reimplemented in collector::CountedMySQLSession.
|
virtual |
Reimplemented in collector::CountedMySQLSession.
|
virtual |
Reimplemented in collector::CountedMySQLSession.
void MySQLSession::query | ( | const std::string & | query, |
const RowProcessor & | processor, | ||
const FieldValidator & | validator | ||
) |
|
inline |
|
virtual |
Reimplemented in collector::CountedMySQLSession.
|
inlinevirtual |
Reimplemented in collector::CountedMySQLSession.
|
virtual |
int MySQLSession::read_timeout | ( | ) | const |
|
private |
run query.
There are 3 cases:
q | stmt to execute |
|
private |
|
virtual |
Reimplemented in collector::CountedMySQLSession.
|
virtual |
|
inline |
set a mysql option.
[in] | opt | option to set. |
true | on success |
|
virtual |
|
virtual |
std::string MySQLSession::ssl_ca | ( | ) | const |
std::string MySQLSession::ssl_capath | ( | ) | const |
std::string MySQLSession::ssl_cert | ( | ) | const |
|
virtual |
std::string MySQLSession::ssl_cipher | ( | ) | const |
std::string MySQLSession::ssl_crl | ( | ) | const |
std::string MySQLSession::ssl_crlpath | ( | ) | const |
std::string MySQLSession::ssl_key | ( | ) | const |
mysql_ssl_mode MySQLSession::ssl_mode | ( | ) | const |
|
staticnoexcept |
|
private |
std::string MySQLSession::tls_version | ( | ) | const |
|
virtualnoexcept |
|
private |
|
private |
struct { ... } mysqlrouter::MySQLSession::connect_params_ |
|
private |
|
private |
|
private |
|
private |
std::string mysqlrouter::MySQLSession::default_schema |
|
private |
std::string mysqlrouter::MySQLSession::host |
|
staticconstexpr |
|
staticconstexpr |
|
static |
|
static |
|
static |
|
static |
|
static |
|
private |
|
private |
|
private |
unsigned int mysqlrouter::MySQLSession::port {} |
|
private |
std::string mysqlrouter::MySQLSession::unix_socket |