MySQL 9.3.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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 () 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)
 
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 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::ResultRowquery_one (const std::string &query, const FieldValidator &validator) override
 
std::unique_ptr< MySQLSession::ResultRowquery_one (const std::string &query) override
 
- Public Member Functions inherited from mysqlrouter::MySQLSession
 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, MysqlErrorset_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...
 
virtual void disconnect ()
 
void query (const std::string &query, const RowProcessor &processor, const FieldValidator &validator)
 
void query (const std::string &stmt, const RowProcessor &processor)
 
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 ()
 
MYSQLget_handle ()
 

Private Attributes

ConnectionParameters connection_params_
 
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 []
 

Member Typedef Documentation

◆ Sqls

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

Constructor & Destructor Documentation

◆ CountedMySQLSession()

collector::CountedMySQLSession::CountedMySQLSession ( )

◆ ~CountedMySQLSession()

collector::CountedMySQLSession::~CountedMySQLSession ( )
override

Member Function Documentation

◆ 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/2]

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

◆ connect() [2/2]

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

◆ execute()

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

Reimplemented from mysqlrouter::MySQLSession.

◆ execute_initial_sqls()

void collector::CountedMySQLSession::execute_initial_sqls ( )
virtual

◆ get_connection_parameters()

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

◆ get_initial_sqls()

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

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

◆ reset()

void collector::CountedMySQLSession::reset ( )
overridevirtual

Reimplemented from mysqlrouter::MySQLSession.

Member Data Documentation

◆ connection_params_

ConnectionParameters collector::CountedMySQLSession::connection_params_
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: