added mariadb support, on death loose 10% xp and respawn at bind point

This commit is contained in:
ElderShell 2026-04-30 22:28:54 -06:00
parent ab9d0a074d
commit 18987fe43d
4 changed files with 118 additions and 89 deletions

View file

@ -59,13 +59,38 @@ DatabaseWorkerPool<T>::DatabaseWorkerPool() :
{
WPFatal(mysql_thread_safe(), "Used MySQL library isn't thread-safe.");
bool isSupportClientDB = mysql_get_client_version() >= MIN_MYSQL_CLIENT_VERSION;
bool isSameClientDB = mysql_get_client_version() == MYSQL_VERSION_ID;
#ifdef MARIADB_BASE_VERSION
WPFatal(isSupportClientDB, "AzerothCore does not support MySQL versions below 8.0\n\nFound version: {} / {}. Server compiled with: {}.\nSearch the wiki for ACE00043 in Common Errors (https://www.azerothcore.org/wiki/common-errors#ace00043).",
mysql_get_client_info(), mysql_get_client_version(), MYSQL_VERSION_ID);
WPFatal(isSameClientDB, "Used MySQL library version ({} id {}) does not match the version id used to compile AzerothCore (id {}).\nSearch the wiki for ACE00046 in Common Errors (https://www.azerothcore.org/wiki/common-errors#ace00046).",
mysql_get_client_info(), mysql_get_client_version(), MYSQL_VERSION_ID);
// MariaDB path (skip MySQL 8 strict checks)
LOG_INFO("sql.sql", "MariaDB detected: {} (client version: {})",
mysql_get_client_info(),
mysql_get_client_version());
#else
// MySQL 8+ strict validation path
const uint32 clientVersion = mysql_get_client_version();
const uint32 compiledVersion = MYSQL_VERSION_ID;
bool isSupportClientDB = clientVersion >= MIN_MYSQL_CLIENT_VERSION;
bool isSameClientDB = clientVersion == compiledVersion;
WPFatal(isSupportClientDB,
"AzerothCore does not support MySQL versions below 8.0\n\n"
"Found version: {} / {}. Server compiled with: {}.\n"
"Search ACE00043 in Common Errors.",
mysql_get_client_info(),
clientVersion,
compiledVersion);
WPFatal(isSameClientDB,
"Used MySQL library version ({} id {}) does not match compiled version id ({}).\n"
"Search ACE00046 in Common Errors.",
mysql_get_client_info(),
clientVersion,
compiledVersion);
#endif
}
template <class T>
@ -417,9 +442,10 @@ bool DatabaseIncompatibleVersion(std::string const mysqlVersion)
template <class T>
uint32 DatabaseWorkerPool<T>::OpenConnections(InternalIndex type, uint8 numConnections)
{
LOG_INFO("sql.sql", "OpenConnections called for type {}", type);
for (uint8 i = 0; i < numConnections; ++i)
{
// Create the connection
auto connection = [&]
{
switch (type)
@ -433,26 +459,42 @@ uint32 DatabaseWorkerPool<T>::OpenConnections(InternalIndex type, uint8 numConne
}
}();
if (uint32 error = connection->Open())
uint32 error = connection->Open();
if (error)
{
// Failed to open a connection or invalid version, abort and cleanup
_queue->Cancel();
_connections[type].clear();
return error;
}
else if (DatabaseIncompatibleVersion(connection->GetServerInfo()))
bool incompatible = DatabaseIncompatibleVersion(connection->GetServerInfo());
#ifdef MARIADB_BASE_VERSION
// MariaDB: do NOT treat as fatal, but also do NOT blindly trust it
if (incompatible)
{
LOG_ERROR("sql.driver", "AzerothCore does not support MySQL versions below 8.0\n\nFound server version: {}. Server compiled with: {}.",
connection->GetServerInfo(), MYSQL_VERSION_ID);
LOG_WARN("sql.driver",
"MariaDB detected with non-standard version response: {}",
connection->GetServerInfo());
}
#else
if (incompatible)
{
LOG_ERROR("sql.driver",
"AzerothCore does not support MySQL versions below 8.0\n\n"
"Found server version: {}. Server compiled with: {}.",
connection->GetServerInfo(),
MYSQL_VERSION_ID);
_queue->Cancel();
_connections[type].clear();
return 1;
}
else
{
_connections[type].push_back(std::move(connection));
}
#endif
_connections[type].push_back(std::move(connection));
}
// Everything is fine
return 0;
}