![]() |
TrinityCore
|
#include <MySQLConnection.h>
Public Member Functions | |
MySQLConnection (MySQLConnectionInfo &connInfo) | |
MySQLConnection (ProducerConsumerQueue< SQLOperation * > *queue, MySQLConnectionInfo &connInfo) | |
Constructor for synchronous connections. More... | |
virtual | ~MySQLConnection () |
Constructor for asynchronous connections. More... | |
virtual uint32 | Open () |
void | Close () |
bool | PrepareStatements () |
bool | Execute (char const *sql) |
bool | Execute (PreparedStatementBase *stmt) |
ResultSet * | Query (char const *sql) |
PreparedResultSet * | Query (PreparedStatementBase *stmt) |
bool | _Query (char const *sql, MySQLResult **pResult, MySQLField **pFields, uint64 *pRowCount, uint32 *pFieldCount) |
bool | _Query (PreparedStatementBase *stmt, MySQLPreparedStatement **mysqlStmt, MySQLResult **pResult, uint64 *pRowCount, uint32 *pFieldCount) |
void | BeginTransaction () |
void | RollbackTransaction () |
void | CommitTransaction () |
int | ExecuteTransaction (std::shared_ptr< TransactionBase > transaction) |
size_t | EscapeString (char *to, const char *from, size_t length) |
void | Ping () |
uint32 | GetLastError () |
Protected Types | |
typedef std::vector< std::unique_ptr< MySQLPreparedStatement > > | PreparedStatementContainer |
Protected Member Functions | |
bool | LockIfReady () |
void | Unlock () |
Called by parent databasepool. Will let other threads access this connection. More... | |
uint32 | GetServerVersion () const |
MySQLPreparedStatement * | GetPreparedStatement (uint32 index) |
void | PrepareStatement (uint32 index, std::string_view sql, ConnectionFlags flags) |
virtual void | DoPrepareStatements ()=0 |
Protected Attributes | |
PreparedStatementContainer | m_stmts |
bool | m_reconnecting |
PreparedStatements storage. More... | |
bool | m_prepareError |
Are we reconnecting? More... | |
Private Member Functions | |
bool | _HandleMySQLErrno (uint32 errNo, uint8 attempts=5) |
Was there any error while preparing statements? More... | |
MySQLConnection (MySQLConnection const &right)=delete | |
MySQLConnection & | operator= (MySQLConnection const &right)=delete |
Private Attributes | |
ProducerConsumerQueue< SQLOperation * > * | m_queue |
std::unique_ptr< DatabaseWorker > | m_worker |
Queue shared with other asynchronous connections. More... | |
MySQLHandle * | m_Mysql |
Core worker task. More... | |
MySQLConnectionInfo & | m_connectionInfo |
MySQL Handle. More... | |
ConnectionFlags | m_connectionFlags |
Connection info (used for logging) More... | |
std::mutex | m_Mutex |
Connection flags (for preparing relevant statements) More... | |
Friends | |
template<class T > | |
class | DatabaseWorkerPool |
class | PingOperation |
Definition at line 54 of file MySQLConnection.h.
|
protected |
Definition at line 99 of file MySQLConnection.h.
MySQLConnection::MySQLConnection | ( | MySQLConnectionInfo & | connInfo | ) |
Definition at line 50 of file MySQLConnection.cpp.
MySQLConnection::MySQLConnection | ( | ProducerConsumerQueue< SQLOperation * > * | queue, |
MySQLConnectionInfo & | connInfo | ||
) |
Constructor for synchronous connections.
Definition at line 58 of file MySQLConnection.cpp.
|
virtual |
Constructor for asynchronous connections.
Definition at line 69 of file MySQLConnection.cpp.
|
privatedelete |
Was there any error while preparing statements?
Definition at line 531 of file MySQLConnection.cpp.
bool MySQLConnection::_Query | ( | char const * | sql, |
MySQLResult ** | pResult, | ||
MySQLField ** | pFields, | ||
uint64 * | pRowCount, | ||
uint32 * | pFieldCount | ||
) |
Definition at line 333 of file MySQLConnection.cpp.
bool MySQLConnection::_Query | ( | PreparedStatementBase * | stmt, |
MySQLPreparedStatement ** | mysqlStmt, | ||
MySQLResult ** | pResult, | ||
uint64 * | pRowCount, | ||
uint32 * | pFieldCount | ||
) |
Definition at line 263 of file MySQLConnection.cpp.
void MySQLConnection::BeginTransaction | ( | ) |
Definition at line 374 of file MySQLConnection.cpp.
void MySQLConnection::Close | ( | ) |
Definition at line 74 of file MySQLConnection.cpp.
void MySQLConnection::CommitTransaction | ( | ) |
Definition at line 384 of file MySQLConnection.cpp.
|
protectedpure virtual |
Implemented in CharacterDatabaseConnection, HotfixDatabaseConnection, LoginDatabaseConnection, and WorldDatabaseConnection.
size_t MySQLConnection::EscapeString | ( | char * | to, |
const char * | from, | ||
size_t | length | ||
) |
Definition at line 440 of file MySQLConnection.cpp.
bool MySQLConnection::Execute | ( | char const * | sql | ) |
Definition at line 189 of file MySQLConnection.cpp.
bool MySQLConnection::Execute | ( | PreparedStatementBase * | stmt | ) |
Definition at line 216 of file MySQLConnection.cpp.
int MySQLConnection::ExecuteTransaction | ( | std::shared_ptr< TransactionBase > | transaction | ) |
Definition at line 389 of file MySQLConnection.cpp.
uint32 MySQLConnection::GetLastError | ( | ) |
|
protected |
Definition at line 470 of file MySQLConnection.cpp.
|
protected |
Definition at line 465 of file MySQLConnection.cpp.
|
protected |
Tries to acquire lock. If lock is acquired by another thread the calling parent will just try another connection
Definition at line 455 of file MySQLConnection.cpp.
|
virtual |
Definition at line 88 of file MySQLConnection.cpp.
|
privatedelete |
void MySQLConnection::Ping | ( | ) |
|
protected |
Definition at line 482 of file MySQLConnection.cpp.
bool MySQLConnection::PrepareStatements | ( | ) |
Definition at line 183 of file MySQLConnection.cpp.
ResultSet * MySQLConnection::Query | ( | char const * | sql | ) |
Definition at line 317 of file MySQLConnection.cpp.
PreparedResultSet * MySQLConnection::Query | ( | PreparedStatementBase * | stmt | ) |
Definition at line 514 of file MySQLConnection.cpp.
void MySQLConnection::RollbackTransaction | ( | ) |
Definition at line 379 of file MySQLConnection.cpp.
|
protected |
Called by parent databasepool. Will let other threads access this connection.
Definition at line 460 of file MySQLConnection.cpp.
|
friend |
Definition at line 56 of file MySQLConnection.h.
|
friend |
Definition at line 57 of file MySQLConnection.h.
|
private |
Connection info (used for logging)
Definition at line 112 of file MySQLConnection.h.
|
private |
MySQL Handle.
Definition at line 111 of file MySQLConnection.h.
|
private |
Connection flags (for preparing relevant statements)
Definition at line 113 of file MySQLConnection.h.
|
private |
Core worker task.
Definition at line 110 of file MySQLConnection.h.
|
protected |
Are we reconnecting?
Definition at line 103 of file MySQLConnection.h.
|
private |
Definition at line 108 of file MySQLConnection.h.
|
protected |
PreparedStatements storage.
Definition at line 102 of file MySQLConnection.h.
|
protected |
Definition at line 101 of file MySQLConnection.h.
|
private |
Queue shared with other asynchronous connections.
Definition at line 109 of file MySQLConnection.h.