MySQL 26.10.0
Source Code Documentation
collector::CountedMySQLSession Class Reference

#include <counted_mysql_session.h>

Inheritance diagram for collector::CountedMySQLSession:
[legend]

Classes

struct  ConnectionParameters
 

Public Types

using Sqls = std::vector< std::string >
 
- Public Types inherited from mysqlrouter::MySQLSession
typedef std::vector< const char * > Row
 
typedef std::function< bool(const Row &)> RowProcessor
 
typedef std::function< bool(const ResultRow &)> ResultRowProcessor
 
typedef std::function< void(unsigned, MYSQL_FIELD *)> FieldValidator
 
typedef std::function< void()> OnResultSetEnd
 
template<mysql_option Opt>
using BooleanOption = impl::Option< Opt, bool >
 
template<mysql_option Opt>
using IntegerOption = impl::Option< Opt, unsigned int >
 
template<mysql_option Opt>
using LongOption = impl::Option< Opt, unsigned long >
 
template<mysql_option Opt>
using ConstCharOption = impl::Option< Opt, const char * >
 
using DefaultAuthentication = ConstCharOption< MYSQL_DEFAULT_AUTH >
 
using EnableCleartextPlugin = BooleanOption< MYSQL_ENABLE_CLEARTEXT_PLUGIN >
 
using InitCommand = ConstCharOption< MYSQL_INIT_COMMAND >
 
using BindAddress = ConstCharOption< MYSQL_OPT_BIND >
 
using CanHandleExpiredPasswords = BooleanOption< MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS >
 
using Compress = BooleanOption< MYSQL_OPT_COMPRESS >
 
using CompressionAlgorithms = ConstCharOption< MYSQL_OPT_COMPRESSION_ALGORITHMS >
 
using ConnectAttributeReset = BooleanOption< MYSQL_OPT_CONNECT_ATTR_RESET >
 
using ConnectAttributeDelete = BooleanOption< MYSQL_OPT_CONNECT_ATTR_DELETE >
 
using ConnectTimeout = IntegerOption< MYSQL_OPT_CONNECT_TIMEOUT >
 
using GetServerPublicKey = BooleanOption< MYSQL_OPT_GET_SERVER_PUBLIC_KEY >
 
using LoadDataLocalDir = ConstCharOption< MYSQL_OPT_LOAD_DATA_LOCAL_DIR >
 
using LocalInfile = IntegerOption< MYSQL_OPT_LOCAL_INFILE >
 
using MaxAllowedPacket = LongOption< MYSQL_OPT_MAX_ALLOWED_PACKET >
 
using NamedPipe = BooleanOption< MYSQL_OPT_NAMED_PIPE >
 
using NetBufferLength = LongOption< MYSQL_OPT_NET_BUFFER_LENGTH >
 
using OptionalResultsetMetadata = BooleanOption< MYSQL_OPT_OPTIONAL_RESULTSET_METADATA >
 
using Protocol = IntegerOption< MYSQL_OPT_PROTOCOL >
 
using ReadTimeout = IntegerOption< MYSQL_OPT_READ_TIMEOUT >
 
using RetryCount = IntegerOption< MYSQL_OPT_RETRY_COUNT >
 
using SslCa = ConstCharOption< MYSQL_OPT_SSL_CA >
 
using SslCaPath = ConstCharOption< MYSQL_OPT_SSL_CAPATH >
 
using SslCert = ConstCharOption< MYSQL_OPT_SSL_CERT >
 
using SslCipher = ConstCharOption< MYSQL_OPT_SSL_CIPHER >
 
using SslCrl = ConstCharOption< MYSQL_OPT_SSL_CRL >
 
using SslCrlPath = ConstCharOption< MYSQL_OPT_SSL_CRLPATH >
 
using SslFipsMode = IntegerOption< MYSQL_OPT_SSL_FIPS_MODE >
 
using SslKey = ConstCharOption< MYSQL_OPT_SSL_KEY >
 
using SslMode = IntegerOption< MYSQL_OPT_SSL_MODE >
 
using TlsCipherSuites = ConstCharOption< MYSQL_OPT_TLS_CIPHERSUITES >
 
using TlsVersion = ConstCharOption< MYSQL_OPT_TLS_VERSION >
 
using WriteTimeout = IntegerOption< MYSQL_OPT_WRITE_TIMEOUT >
 
using ZstdCompressionLevel = IntegerOption< MYSQL_OPT_ZSTD_COMPRESSION_LEVEL >
 
using PluginDir = ConstCharOption< MYSQL_PLUGIN_DIR >
 
using ReportDataTruncation = BooleanOption< MYSQL_REPORT_DATA_TRUNCATION >
 
using ServerPluginKey = ConstCharOption< MYSQL_SERVER_PUBLIC_KEY >
 
using ReadDefaultFile = ConstCharOption< MYSQL_READ_DEFAULT_FILE >
 
using ReadDefaultGroup = ConstCharOption< MYSQL_READ_DEFAULT_GROUP >
 
using CharsetDir = ConstCharOption< MYSQL_SET_CHARSET_DIR >
 
using CharsetName = ConstCharOption< MYSQL_SET_CHARSET_NAME >
 
using SharedMemoryBasename = ConstCharOption< MYSQL_SHARED_MEMORY_BASE_NAME >
 

Public Member Functions

 CountedMySQLSession ()
 
 CountedMySQLSession (std::unique_ptr< mysqlrouter::MySQLSession > impl)
 
 ~CountedMySQLSession () override
 
virtual void allow_failure_at_next_query ()
 
virtual ConnectionParameters get_connection_parameters () const
 
virtual void execute_initial_sqls ()
 
virtual Sqls get_initial_sqls () const
 
virtual void connect_and_set_opts (const ConnectionParameters &connection_params, const Sqls &initial_sqls)
 
virtual void connect (const ConnectionParameters &connection_params)
 
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) override
 
void connect (const MySQLSession &other, const std::string &username, const mysql_harness::SecureString &password) override
 
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) override
 
void change_user (const std::string &user, const mysql_harness::SecureString &password, const std::string &db) override
 
void disconnect () override
 
void reset () override
 
uint64_t prepare (const std::string &query) override
 
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) override
 
void prepare_remove (uint64_t ps_id) override
 
void execute (const std::string &query) override
 
void query (const std::string &query, const ResultRowProcessor &processor, const FieldValidator &validator) override
 
std::unique_ptr< MySQLSession::ResultRow > query_one (const std::string &query, const FieldValidator &validator) override
 
std::unique_ptr< MySQLSession::ResultRow > query_one (const std::string &query) override
 
int ping () override
 
bool execute_nb (const std::string &query) override
 
uint64_t last_insert_id () noexcept override
 
uint64_t affected_rows () noexcept override
 
unsigned warning_count () noexcept override
 
std::string quote (const std::string &s, char qchar='\'') const override
 
bool is_connected () noexcept override
 
const char * last_sqlstate () override
 
const char * last_error () override
 
unsigned int last_errno () override
 
const char * ssl_cipher () override
 
bool has_data_on_socket () override
 
std::vector< std::string > get_session_tracker_data (enum enum_session_state_type type) override
 
bool is_ssl_session_reused () override
 
unsigned long server_version () override
 
MYSQL * get_handle () override
 
void log_queries (bool log) override
 
bool log_queries () const override
 
uint64_t connection_id ()
 
const std::string & get_address () noexcept
 
- Public Member Functions inherited from mysqlrouter::MySQLSession
 MySQLSession ()
 
virtual ~MySQLSession ()
 
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 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...
 
void query (const std::string &query, const RowProcessor &processor, const FieldValidator &validator)
 
void query (const std::string &stmt, const RowProcessor &processor)
 
const std::string & get_address () noexcept
 

Private Member Functions

void update_connection_address (const std::string &host, unsigned int port, const std::string &unix_socket)
 

Private Attributes

ConnectionParameters connection_params_
 
uint64_t connection_id_ {0}
 
std::unique_ptr< mysqlrouter::MySQLSession > impl_
 
std::string connection_address_
 
bool reconnect_at_next_query_ {false}
 
Sqls initial_sqls_
 

Additional Inherited Members

- Static Public Member Functions inherited from mysqlrouter::MySQLSession
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 inherited from mysqlrouter::MySQLSession
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 []
 
- Static Protected Member Functions inherited from mysqlrouter::MySQLSession
static Error make_query_preparation_error (const std::string &query, unsigned int error_code, const std::string &error_message)
 
static Error make_query_execution_error (const std::string &query, unsigned int error_code, const std::string &error_message)
 

Member Typedef Documentation

◆ Sqls

using collector::CountedMySQLSession::Sqls = std::vector<std::string>

Constructor & Destructor Documentation

◆ CountedMySQLSession() [1/2]

collector::CountedMySQLSession::CountedMySQLSession ( )

◆ CountedMySQLSession() [2/2]

collector::CountedMySQLSession::CountedMySQLSession ( std::unique_ptr< mysqlrouter::MySQLSession >  impl)
explicit

◆ ~CountedMySQLSession()

collector::CountedMySQLSession::~CountedMySQLSession ( )
override

Member Function Documentation

◆ affected_rows()

uint64_t collector::CountedMySQLSession::affected_rows ( )
overridevirtualnoexcept

Reimplemented from mysqlrouter::MySQLSession.

◆ allow_failure_at_next_query()

void collector::CountedMySQLSession::allow_failure_at_next_query ( )
virtual

◆ change_user()

void collector::CountedMySQLSession::change_user ( const std::string &  user,
const mysql_harness::SecureString &  password,
const std::string &  db 
)
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ connect() [1/3]

void collector::CountedMySQLSession::connect ( const ConnectionParameters &  connection_params)
virtual

◆ connect() [2/3]

void collector::CountedMySQLSession::connect ( const MySQLSession &  other,
const std::string &  username,
const mysql_harness::SecureString &  password 
)
override

◆ connect() [3/3]

void collector::CountedMySQLSession::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 
)
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ connect_and_set_opts()

void collector::CountedMySQLSession::connect_and_set_opts ( const ConnectionParameters &  connection_params,
const Sqls &  initial_sqls 
)
virtual

◆ connection_id()

uint64_t collector::CountedMySQLSession::connection_id ( )

◆ disconnect()

void collector::CountedMySQLSession::disconnect ( )
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ execute()

void collector::CountedMySQLSession::execute ( const std::string &  query)
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ execute_initial_sqls()

void collector::CountedMySQLSession::execute_initial_sqls ( )
virtual

◆ execute_nb()

bool collector::CountedMySQLSession::execute_nb ( const std::string &  query)
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ get_address()

const std::string & collector::CountedMySQLSession::get_address ( )
noexcept

◆ get_connection_parameters()

CountedMySQLSession::ConnectionParameters collector::CountedMySQLSession::get_connection_parameters ( ) const
virtual

◆ get_handle()

MYSQL * collector::CountedMySQLSession::get_handle ( )
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ get_initial_sqls()

CountedMySQLSession::Sqls collector::CountedMySQLSession::get_initial_sqls ( ) const
virtual

◆ get_session_tracker_data()

std::vector< std::string > collector::CountedMySQLSession::get_session_tracker_data ( enum enum_session_state_type  type)
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ has_data_on_socket()

bool collector::CountedMySQLSession::has_data_on_socket ( )
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ is_connected()

bool collector::CountedMySQLSession::is_connected ( )
overridevirtualnoexcept

Reimplemented from mysqlrouter::MySQLSession.

◆ is_ssl_session_reused()

bool collector::CountedMySQLSession::is_ssl_session_reused ( )
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ last_errno()

unsigned int collector::CountedMySQLSession::last_errno ( )
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ last_error()

const char * collector::CountedMySQLSession::last_error ( )
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ last_insert_id()

uint64_t collector::CountedMySQLSession::last_insert_id ( )
overridevirtualnoexcept

Reimplemented from mysqlrouter::MySQLSession.

◆ last_sqlstate()

const char * collector::CountedMySQLSession::last_sqlstate ( )
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ log_queries() [1/2]

bool collector::CountedMySQLSession::log_queries ( ) const
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ log_queries() [2/2]

void collector::CountedMySQLSession::log_queries ( bool  log)
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ ping()

int collector::CountedMySQLSession::ping ( )
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ prepare()

uint64_t collector::CountedMySQLSession::prepare ( const std::string &  query)
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ prepare_execute_with_bind_parameters()

void collector::CountedMySQLSession::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 
)
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ prepare_remove()

void collector::CountedMySQLSession::prepare_remove ( uint64_t  ps_id)
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ query()

void collector::CountedMySQLSession::query ( const std::string &  query,
const ResultRowProcessor &  processor,
const FieldValidator &  validator 
)
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ query_one() [1/2]

std::unique_ptr< MySQLSession::ResultRow > collector::CountedMySQLSession::query_one ( const std::string &  query)
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ query_one() [2/2]

std::unique_ptr< MySQLSession::ResultRow > collector::CountedMySQLSession::query_one ( const std::string &  query,
const FieldValidator &  validator 
)
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ quote()

std::string collector::CountedMySQLSession::quote ( const std::string &  s,
char  qchar = '\'' 
) const
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ reset()

void collector::CountedMySQLSession::reset ( )
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ server_version()

unsigned long collector::CountedMySQLSession::server_version ( )
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ set_ssl_options()

void collector::CountedMySQLSession::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 
)
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ ssl_cipher()

const char * collector::CountedMySQLSession::ssl_cipher ( )
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

◆ update_connection_address()

void collector::CountedMySQLSession::update_connection_address ( const std::string &  host,
unsigned int  port,
const std::string &  unix_socket 
)
private

◆ warning_count()

unsigned collector::CountedMySQLSession::warning_count ( )
overridevirtualnoexcept

Reimplemented from mysqlrouter::MySQLSession.

Member Data Documentation

◆ connection_address_

std::string collector::CountedMySQLSession::connection_address_
private

◆ connection_id_

uint64_t collector::CountedMySQLSession::connection_id_ {0}
private

◆ connection_params_

ConnectionParameters collector::CountedMySQLSession::connection_params_
private

◆ impl_

std::unique_ptr<mysqlrouter::MySQLSession> collector::CountedMySQLSession::impl_
private

◆ initial_sqls_

Sqls collector::CountedMySQLSession::initial_sqls_
private

◆ reconnect_at_next_query_

bool collector::CountedMySQLSession::reconnect_at_next_query_ {false}
private

The documentation for this class was generated from the following files: