![]() |
AzerothCore 3.3.5a
OpenSource WoW Emulator
|
#include "ModuleDatabasePool.h"
Public Member Functions | |
| ModuleDatabasePool () | |
| virtual | ~ModuleDatabasePool () |
| void | SetConnectionInfo (std::string_view infoString, uint8 synchThreads) |
| uint32 | Open () |
| bool | PrepareStatements () |
| void | Close () |
| void | Execute (std::string_view sql) |
| void | DirectExecute (std::string_view sql) override |
| QueryResult | Query (std::string_view sql) override |
| MySQLConnectionInfo const * | GetConnectionInfo () const override |
| template<typename... Args> | |
| void | Execute (std::string_view sql, Args &&... args) |
| Format variants, mirroring DatabaseWorkerPool. | |
| template<typename... Args> | |
| void | DirectExecute (std::string_view sql, Args &&... args) |
| template<typename... Args> | |
| QueryResult | Query (std::string_view sql, Args &&... args) |
| void | Execute (PreparedStatementBase *stmt) |
| PreparedQueryResult | Query (PreparedStatementBase *stmt) |
| uint8 | GetPreparedStatementParamCount (uint32 index) const |
| void | DirectCommitTransaction (std::shared_ptr< TransactionBase > transaction) |
| Synchronously commits the transaction on a free connection. | |
| void | KeepAlive () |
| Pings every idle connection to keep them alive. | |
Public Member Functions inherited from DatabaseUpdatePool | |
| virtual | ~DatabaseUpdatePool ()=default |
Protected Member Functions | |
| virtual MySQLConnection * | CreateConnection (MySQLConnectionInfo &connInfo)=0 |
Private Member Functions | |
| MySQLConnection * | GetFreeConnection () |
Private Attributes | |
| MySQLConnectionInfo | _connectionInfo |
| std::vector< std::unique_ptr< MySQLConnection > > | _connections |
| std::vector< uint8 > | _preparedStatementSize |
| uint8 | _synchThreads |
| ModuleDatabasePool::ModuleDatabasePool | ( | ) |
|
virtual |
References Close().
| void ModuleDatabasePool::Close | ( | ) |
References _connections, and _preparedStatementSize.
Referenced by Open(), PrepareStatements(), and ~ModuleDatabasePool().
|
protectedpure virtual |
Referenced by Open().
| void ModuleDatabasePool::DirectCommitTransaction | ( | std::shared_ptr< TransactionBase > | transaction | ) |
Synchronously commits the transaction on a free connection.
Handle MySQL Errno 1213 without extending deadlock to the core itself
References _connections, MySQLConnection::ExecuteTransaction(), GetFreeConnection(), and MySQLConnection::Unlock().
|
overridevirtual |
Implements DatabaseUpdatePool.
References _connections, MySQLConnection::Execute(), GetFreeConnection(), and MySQLConnection::Unlock().
Referenced by Execute().
|
inline |
References DatabaseUpdatePool::DirectExecute(), and Acore::StringFormat().
| void ModuleDatabasePool::Execute | ( | PreparedStatementBase * | stmt | ) |
Prepared statements. The index space is defined by the module's connection class (DoPrepareStatements); parameter counts are recorded by PrepareStatements(), so building one before that call yields a zero-parameter statement. Both calls consume (delete) the statement, mirroring DatabaseWorkerPool.
References _connections, MySQLConnection::Execute(), GetFreeConnection(), and MySQLConnection::Unlock().
| void ModuleDatabasePool::Execute | ( | std::string_view | sql | ) |
References DirectExecute().
|
inline |
Format variants, mirroring DatabaseWorkerPool.
References Acore::StringFormat().
|
overridevirtual |
|
private |
Block forever until a connection is free
Must be matched with connection->Unlock() or you will get deadlocks
References _connections, and MySQLConnection::LockIfReady().
Referenced by DirectCommitTransaction(), DirectExecute(), Execute(), Query(), and Query().
Parameter count for a prepared statement index, for constructing typed PreparedStatement<T> objects module-side.
References _preparedStatementSize.
| void ModuleDatabasePool::KeepAlive | ( | ) |
Pings every idle connection to keep them alive.
Ping connections that are not busy; a locked connection is in use and alive.
References _connections.
| uint32 ModuleDatabasePool::Open | ( | ) |
Opens the configured number of synchronous connections. Returns 0 on success, or the MySQL error code of the first failed connection.
References _connectionInfo, _connections, _synchThreads, Close(), CreateConnection(), MySQLConnectionInfo::database, and LOG_ERROR.
| bool ModuleDatabasePool::PrepareStatements | ( | ) |
Prepares the connection statements. Call after the schema exists (post create/populate/update), mirroring DatabaseLoader's ordering.
References _connections, _preparedStatementSize, ASSERT, Close(), and MySQLConnection::m_stmts.
| PreparedQueryResult ModuleDatabasePool::Query | ( | PreparedStatementBase * | stmt | ) |
Delete proxy-class. Not needed anymore
References _connections, GetFreeConnection(), PreparedResultSet::GetRowCount(), MySQLConnection::Query(), and MySQLConnection::Unlock().
|
overridevirtual |
Implements DatabaseUpdatePool.
References _connections, GetFreeConnection(), ResultSet::GetRowCount(), ResultSet::NextRow(), MySQLConnection::Query(), and MySQLConnection::Unlock().
|
inline |
References DatabaseUpdatePool::Query(), and Acore::StringFormat().
| void ModuleDatabasePool::SetConnectionInfo | ( | std::string_view | infoString, |
| uint8 | synchThreads | ||
| ) |
References _connectionInfo, and _synchThreads.
|
private |
Referenced by GetConnectionInfo(), Open(), and SetConnectionInfo().
|
private |
Referenced by Close(), DirectCommitTransaction(), DirectExecute(), Execute(), GetFreeConnection(), KeepAlive(), Open(), PrepareStatements(), Query(), and Query().
|
private |
Referenced by Close(), GetPreparedStatementParamCount(), and PrepareStatements().
|
private |
Referenced by Open(), and SetConnectionInfo().