24#include <mysqld_error.h>
27 : _logger(logger), _autoSetup(
sConfigMgr->GetBoolDefault(
"Updates.AutoSetup", true)),
28 _updateFlags(
sConfigMgr->GetIntDefault(
"Updates.EnableDatabases", defaultUpdateMask))
37 _open.push([
this, name, updatesEnabledForThis, &pool]() ->
bool
39 std::string
const dbString =
sConfigMgr->GetStringDefault(name +
"DatabaseInfo",
"");
42 TC_LOG_ERROR(_logger,
"Database {} not specified in configuration file!", name);
47 if (asyncThreads < 1 || asyncThreads > 32)
50 "Please pick a value between 1 and 32.", name);
60 if ((error == ER_BAD_DB_ERROR) && updatesEnabledForThis &&
_autoSetup)
70 TC_LOG_ERROR(
"sql.driver",
"\nDatabasePool {} NOT opened. There were errors opening the MySQL connections. Check your SQLDriverLogFile "
71 "for specific errors. Read wiki at https://www.trinitycore.info/display/tc/TrinityCore+Home", name);
85 if (updatesEnabledForThis)
87 _populate.push([
this, name, &pool]() ->
bool
97 _update.push([
this, name, &pool]() ->
bool
108 _prepare.push([
this, name, &pool]() ->
bool
112 TC_LOG_ERROR(
_logger,
"Could not prepare statements of the {} database, see log for details.", name);
124 TC_LOG_INFO(
"sql.updates",
"Automatic database updates are disabled for all databases!");
163 while (!queue.empty())
165 if (!queue.front()())
#define TC_LOG_ERROR(filterType__,...)
#define TC_LOG_INFO(filterType__,...)
if(posix_memalign(&__mallocedMemory, __align, __size)) return NULL
static bool IsEnabled(uint32 const updateMask)
std::queue< Predicate > _populate
std::string const _logger
DatabaseLoader(std::string const &logger, uint32 const defaultUpdateMask)
uint32 const _updateFlags
std::queue< Predicate > _prepare
std::queue< Predicate > _update
std::queue< Predicate > _open
std::stack< Closer > _close
bool Process(std::queue< Predicate > &queue)
DatabaseLoader & AddDatabase(DatabaseWorkerPool< T > &pool, std::string const &name)
bool PrepareStatements()
Prepares all prepared statements.
void SetConnectionInfo(std::string const &infoString, uint8 const asyncThreads, uint8 const synchThreads)