18 #ifndef _DATABASEWORKERPOOL_H
19 #define _DATABASEWORKERPOOL_H
33 #include <mysqld_error.h>
98 template<
typename Format,
typename... Args>
127 connection->Execute(sql);
128 connection->Unlock();
133 template<
typename Format,
typename... Args>
147 connection->Execute(stmt);
148 connection->Unlock();
164 template<
typename Format,
typename... Args>
175 template<
typename Format,
typename... Args>
199 template<
typename Format,
typename... Args>
279 if (!to || !from || !length)
282 return mysql_real_escape_string(
301 std::unique_ptr<ProducerConsumerQueue<SQLOperation*>>
_queue;
~DatabaseWorkerPool()
Definition: DatabaseWorkerPool.h:62
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
std::future< QueryResult > QueryResultFuture
Definition: Callback.h:24
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
Definition: QueryHolder.h:23
QueryResult PQuery(Format &&sql, T *conn, Args &&...args)
Definition: DatabaseWorkerPool.h:165
void SetConnectionInfo(std::string const &infoString, uint8 const asyncThreads, uint8 const synchThreads)
Definition: DatabaseWorkerPool.cpp:36
void ExecuteOrAppend(SQLTransaction &trans, PreparedStatement *stmt)
Definition: DatabaseWorkerPool.h:236
QueryResultFuture AsyncPQuery(Format &&sql, Args &&...args)
Definition: DatabaseWorkerPool.h:200
void KeepAlive()
Keeps all our MySQL connections alive, prevent the server from disconnecting us.
Definition: DatabaseWorkerPool.cpp:243
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
MySQLConnection * m_conn
Definition: SQLOperation.h:70
QueryResultFuture AsyncQuery(const char *sql)
Definition: DatabaseWorkerPool.cpp:149
Definition: DatabaseWorkerPool.h:55
bool IsFormatEmptyOrNull(const char *fmt)
Returns true if the given char pointer is null.
Definition: StringFormat.h:34
std::unique_ptr< ProducerConsumerQueue< SQLOperation * > > _queue
Queue shared by async worker threads.
Definition: DatabaseWorkerPool.h:301
uint32 OpenConnections(InternalIndex type, uint8 numConnections)
Definition: DatabaseWorkerPool.cpp:264
void Close()
Definition: DatabaseWorkerPool.cpp:72
Definition: PreparedStatement.h:74
uint8 _synch_threads
Definition: DatabaseWorkerPool.h:304
std::future< SQLQueryHolder * > QueryResultHolderFuture
Definition: QueryHolder.h:46
QueryResult PQuery(Format &&sql, Args &&...args)
Definition: DatabaseWorkerPool.h:176
bool PrepareStatements()
Prepares all prepared statements.
Definition: DatabaseWorkerPool.cpp:93
Definition: AdhocStatement.h:28
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
T * GetFreeConnection()
Definition: DatabaseWorkerPool.cpp:303
void PExecute(Format &&sql, Args &&...args)
Definition: DatabaseWorkerPool.h:99
InternalIndex
Definition: DatabaseWorkerPool.h:51
std::unique_ptr< MySQLConnectionInfo > _connectionInfo
Definition: DatabaseWorkerPool.h:303
void Enqueue(SQLOperation *op)
Definition: DatabaseWorkerPool.h:286
uint8 _async_threads
Definition: DatabaseWorkerPool.h:304
void DirectPExecute(Format &&sql, Args &&...args)
Definition: DatabaseWorkerPool.h:134
T::Statements PreparedStatementIndex
Definition: DatabaseWorkerPool.h:258
MySQLConnectionInfo const * GetConnectionInfo() const
Definition: DatabaseWorkerPool.h:76
Definition: Transaction.h:28
uint32_t uint32
Definition: Define.h:150
void EscapeString(std::string &str)
Apply escape string'ing for current collation. (utf8)
Definition: DatabaseWorkerPool.cpp:231
std::shared_ptr< ResultSet > QueryResult
Definition: QueryResult.h:61
DatabaseWorkerPool()
Definition: DatabaseWorkerPool.cpp:25
QueryResultHolderFuture DelayQueryHolder(SQLQueryHolder *holder)
Definition: DatabaseWorkerPool.cpp:169
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
bool Execute() override
Operation for idle delaythreads.
Definition: DatabaseWorkerPool.h:40
float length(float v)
Definition: vectorMath.h:208
std::string StringFormat(Format &&fmt, Args &&...args)
Default TC string format function.
Definition: StringFormat.h:28
Definition: DatabaseWorkerPool.h:37
std::future< PreparedQueryResult > PreparedQueryResultFuture
Definition: Callback.h:26
Definition: PreparedStatement.h:162
void Execute(PreparedStatement *stmt)
Definition: DatabaseWorkerPool.h:109
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
unsigned long EscapeString(char *to, const char *from, unsigned long length)
Definition: DatabaseWorkerPool.h:277
void DirectCommitTransaction(SQLTransaction &transaction)
Definition: DatabaseWorkerPool.cpp:202
void ExecuteOrAppend(SQLTransaction &trans, const char *sql)
Definition: DatabaseWorkerPool.h:246
char const * GetDatabaseName() const
Definition: DatabaseWorkerPool.h:295
uint8_t uint8
Definition: Define.h:152
Definition: SQLOperation.h:56
Definition: DatabaseWorkerPool.h:54
void DirectExecute(PreparedStatement *stmt)
Definition: DatabaseWorkerPool.h:144
void DirectExecute(const char *sql)
Definition: DatabaseWorkerPool.h:121
Definition: DatabaseWorkerPool.h:48
std::array< std::vector< std::unique_ptr< T > >, IDX_SIZE > _connections
Definition: DatabaseWorkerPool.h:302
Definition: DatabaseWorkerPool.h:53
uint32 Open()
Definition: DatabaseWorkerPool.cpp:46
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58