MySQL 9.1.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) |
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... | |
virtual 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) |
virtual void | disconnect () |
virtual void | connect (const MySQLSession &other, const std::string &username, const std::string &password) |
Connect using the same settings and parameters that were used for the last other.connect() using provided credentials. More... | |
virtual void | execute (const std::string &query) |
virtual void | query (const std::string &query, const RowProcessor &processor, const FieldValidator &validator) |
virtual std::unique_ptr< MySQLSession::ResultRow > | query_one (const std::string &query, const FieldValidator &validator) |
void | query (const std::string &stmt, const RowProcessor &processor) |
std::unique_ptr< MySQLSession::ResultRow > | query_one (const std::string &stmt) |
virtual uint64_t | last_insert_id () 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_error () |
virtual unsigned int | last_errno () |
virtual const char * | ssl_cipher () |
virtual bool | is_ssl_session_reused () |
virtual unsigned long | server_version () |
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 | |
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 > | logged_real_query (const std::string &q) |
log query before running it. More... | |
Private Attributes | |
struct { | |
std::string host | |
unsigned int port {} | |
std::string unix_socket | |
std::string default_schema | |
} | connect_params_ |
MYSQL * | connection_ |
bool | connected_ |
std::string | connection_address_ |
SQLLogFilter | log_filter_ |
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 |
using mysqlrouter::MySQLSession::OptionalResultsetMetadata = BooleanOption<MYSQL_OPT_OPTIONAL_RESULTSET_METADATA> |
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> |
MySQLSession::MySQLSession | ( | ) |
|
virtual |
|
virtual |
Connect using the same settings and parameters that were used for the last other.connect() using provided credentials.
|
virtual |
int MySQLSession::connect_timeout | ( | ) | const |
|
virtual |
|
virtual |
|
inlinenoexcept |
|
inline |
get a mysql option.
[in,out] | opt | option to query. |
true | on success. |
false | if option is not known. |
|
inlinevirtualnoexcept |
|
virtual |
|
virtual |
|
virtual |
|
virtualnoexcept |
|
private |
log query before running it.
|
static |
|
virtual |
|
inline |
|
virtual |
|
inline |
|
virtual |
int MySQLSession::read_timeout | ( | ) | const |
|
private |
run query.
There are 3 cases:
q | stmt to execute |
|
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 |
std::string MySQLSession::tls_version | ( | ) | const |
|
virtualnoexcept |
struct { ... } mysqlrouter::MySQLSession::connect_params_ |
|
private |
|
private |
|
private |
std::string mysqlrouter::MySQLSession::default_schema |
std::string mysqlrouter::MySQLSession::host |
|
staticconstexpr |
|
staticconstexpr |
|
static |
|
static |
|
static |
|
static |
|
static |
|
private |
|
private |
unsigned int mysqlrouter::MySQLSession::port {} |
std::string mysqlrouter::MySQLSession::unix_socket |