refactor(Deps/MySQL): Drop MariaDB and MySQL 5.7/8.1 and add MySQL 8.… (#19451)

This commit is contained in:
Kitzunu 2024-09-19 05:24:11 +02:00 committed by GitHub
parent 5af3d2d650
commit dbde182ecd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 37 additions and 204 deletions

21
.github/SECURITY.md vendored
View File

@ -15,23 +15,16 @@ Versions of AzerothCore:
| AzerothCore Branch | Supported |
| ------------------ | ------------------ |
| master | :white_check_mark: |
| Any playerbot fork | :red_circle: |
| Any NPCBot fork | :red_circle: |
Versions of MySQL:
| MySQL Version | Supported |
| ------------- | ------------------ |
| 8.1 | :white_check_mark: |
| 8.4 | :white_check_mark: |
| 8.0 | :white_check_mark: |
| 5.7 | :white_check_mark: |
| 5.6 and lower | :red_circle: |
Versions of MariaDB:
| MariaDB Version | Supported |
| --------------- | ------------------ |
| 10.6 | :white_check_mark: |
| 10.5 | :white_check_mark: |
| 10.4 and lower | :red_circle: |
| 5.7 and lower | :red_circle: |
Versions of CLang:
@ -44,7 +37,7 @@ Versions of CLang:
Versions of GCC:
| GCC Version | Supported |
| ----------- | ------------------ |
| ------------ | ------------------ |
| 14 | :white_check_mark: |
| 12 | :white_check_mark: |
| 11 and lower | :red_circle: |
@ -52,7 +45,7 @@ Versions of GCC:
Versions of Ubuntu:
| Ubuntu version | Supported |
| -------------- | ------------------ |
| --------------- | ------------------ |
| 24.04 | :white_check_mark: |
| 22.04 | :white_check_mark: |
| 20.04 and lower | :red_circle: |
@ -60,7 +53,7 @@ Versions of Ubuntu:
Versions of macOS:
| macOS Version | Supported |
| -------------- | ------------------ |
| ------------- | ------------------ |
| 12 | :white_check_mark: |
| 11 and lower | :red_circle: |

View File

@ -1,16 +1,4 @@
REVOKE ALL PRIVILEGES ON * . * FROM 'acore'@'localhost';
REVOKE ALL PRIVILEGES ON `acore_world` . * FROM 'acore'@'localhost';
REVOKE GRANT OPTION ON `acore_world` . * FROM 'acore'@'localhost';
REVOKE ALL PRIVILEGES ON `acore_characters` . * FROM 'acore'@'localhost';
REVOKE GRANT OPTION ON `acore_characters` . * FROM 'acore'@'localhost';
REVOKE ALL PRIVILEGES ON `acore_auth` . * FROM 'acore'@'localhost';
REVOKE GRANT OPTION ON `acore_auth` . * FROM 'acore'@'localhost';
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'acore'@'localhost';
DROP USER 'acore'@'localhost';

View File

@ -1,9 +0,0 @@
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'acore'@'localhost';
DROP USER 'acore'@'localhost';
DROP DATABASE IF EXISTS `acore_world`;
DROP DATABASE IF EXISTS `acore_characters`;
DROP DATABASE IF EXISTS `acore_auth`;

View File

@ -24,77 +24,6 @@
set( MYSQL_FOUND 0 )
# Find MariaDB for Windows
if (WIN32)
# Set know versions MariaDB
set(_MARIADB_KNOWN_VERSIONS "MariaDB 10.9" "MariaDB 10.8" "MariaDB 10.7" "MariaDB 10.6" "MariaDB 10.5")
# Set default options
set(MARIADB_FOUND_LIB 0)
set(MARIADB_FOUND_INCLUDE 0)
set(MARIADB_FOUND_EXECUTABLE 0)
set(MARIADB_FOUND 0)
macro(FindLibMariaDB MariaDBVersion)
# Find include
find_path(MYSQL_INCLUDE_DIR
NAMES
mysql.h
PATHS
${MYSQL_ADD_INCLUDE_PATH}
"$ENV{ProgramW6432}/${MariaDBVersion}/include/mysql"
"$ENV{ProgramFiles}/${MariaDBVersion}/include/mysql"
"${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include/mysql"
DOC
"Specify the directory containing mysql.h."
)
if(MYSQL_INCLUDE_DIR)
set(MARIADB_FOUND_INCLUDE 1)
endif()
find_library(MYSQL_LIBRARY
NAMES
libmariadb
PATHS
${MYSQL_ADD_LIBRARIES_PATH}
"$ENV{ProgramW6432}/${MariaDBVersion}/lib"
"$ENV{ProgramW6432}/${MariaDBVersion}/lib/opt"
"$ENV{ProgramFiles}/${MariaDBVersion}/lib"
"$ENV{ProgramFiles}/${MariaDBVersion}/lib/opt"
"$ENV{SystemDrive}/${MariaDBVersion}/lib/opt"
"${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib"
DOC
"Specify the location of the mysql library here."
)
if(MYSQL_LIBRARY)
set(MARIADB_FOUND_LIB 1)
endif()
find_program(MYSQL_EXECUTABLE mysql
PATHS
"$ENV{ProgramW6432}/${MariaDBVersion}/bin"
"$ENV{ProgramW6432}/${MariaDBVersion}/bin/opt"
"$ENV{ProgramFiles}/${MariaDBVersion}/bin"
"$ENV{ProgramFiles}/${MariaDBVersion}/bin/opt"
"$ENV{SystemDrive}/${MariaDBVersion}/bin/opt"
DOC
"path to your mysql binary.")
if (MYSQL_LIBRARY AND MYSQL_INCLUDE_DIR AND MYSQL_EXECUTABLE)
set(MARIADB_FOUND 1)
endif()
endmacro(FindLibMariaDB)
foreach(version ${_MARIADB_KNOWN_VERSIONS})
if (NOT MARIADB_FOUND)
FindLibMariaDB(${version})
endif()
endforeach()
endif()
if( UNIX )
set(MYSQL_CONFIG_PREFER_PATH "$ENV{MYSQL_HOME}/bin" CACHE FILEPATH
"preferred path to MySQL (mysql_config)"
@ -156,15 +85,12 @@ find_path(MYSQL_INCLUDE_DIR
/usr/local/include/mysql
/usr/local/mysql/include
"C:/tools/mysql/current/include" # chocolatey package
"$ENV{ProgramW6432}/MySQL/MySQL Server 8.1/include"
"$ENV{ProgramW6432}/MySQL/MySQL Server 8.4/include"
"$ENV{ProgramFiles}/MySQL/MySQL Server 8.4/include"
"$ENV{SystemDrive}/MySQL/MySQL Server 8.4/include"
"$ENV{ProgramW6432}/MySQL/MySQL Server 8.0/include"
"$ENV{ProgramW6432}/MySQL/MySQL Server 5.7/include"
"$ENV{ProgramFiles}/MySQL/MySQL Server 8.1/include"
"$ENV{ProgramFiles}/MySQL/MySQL Server 8.0/include"
"$ENV{ProgramFiles}/MySQL/MySQL Server 5.7/include"
"$ENV{SystemDrive}/MySQL/MySQL Server 8.1/include"
"$ENV{SystemDrive}/MySQL/MySQL Server 8.0/include"
"$ENV{SystemDrive}/MySQL/MySQL Server 5.7/include"
"$ENV{MYSQL_INCLUDE_DIR}"
"$ENV{MYSQL_DIR}/include"
DOC
@ -195,15 +121,12 @@ if( WIN32 )
PATHS
${MYSQL_ADD_LIBRARIES_PATH}
"C:/tools/mysql/current/lib" # chocolatey package
"$ENV{ProgramW6432}/MySQL/MySQL Server 8.1/lib"
"$ENV{ProgramW6432}/MySQL/MySQL Server 8.4/lib"
"$ENV{ProgramFiles}/MySQL/MySQL Server 8.4/lib"
"$ENV{SystemDrive}/MySQL/MySQL Server 8.4/lib"
"$ENV{ProgramW6432}/MySQL/MySQL Server 8.0/lib"
"$ENV{ProgramW6432}/MySQL/MySQL Server 5.7/lib"
"$ENV{ProgramFiles}/MySQL/MySQL Server 8.1/lib"
"$ENV{ProgramFiles}/MySQL/MySQL Server 8.0/lib"
"$ENV{ProgramFiles}/MySQL/MySQL Server 5.7/lib"
"$ENV{SystemDrive}/MySQL/MySQL Server 8.1/lib"
"$ENV{SystemDrive}/MySQL/MySQL Server 8.0/lib"
"$ENV{SystemDrive}/MySQL/MySQL Server 5.7/lib"
"$ENV{MYSQL_LIBRARY}"
"$ENV{MYSQL_DIR}/lib"
DOC "Specify the location of the mysql library here."
@ -242,15 +165,12 @@ if( WIN32 )
find_program(MYSQL_EXECUTABLE mysql
PATHS
"C:/tools/mysql/current/bin" # chocolatey package
"$ENV{ProgramW6432}/MySQL/MySQL Server 8.1/bin"
"$ENV{ProgramW6432}/MySQL/MySQL Server 8.4/bin"
"$ENV{ProgramFiles}/MySQL/MySQL Server 8.4/bin"
"$ENV{SystemDrive}/MySQL/MySQL Server 8.4/bin"
"$ENV{ProgramW6432}/MySQL/MySQL Server 8.0/bin"
"$ENV{ProgramW6432}/MySQL/MySQL Server 5.7/bin"
"$ENV{ProgramFiles}/MySQL/MySQL Server 8.1/bin"
"$ENV{ProgramFiles}/MySQL/MySQL Server 8.0/bin"
"$ENV{ProgramFiles}/MySQL/MySQL Server 5.7/bin"
"$ENV{SystemDrive}/MySQL/MySQL Server 8.1/bin"
"$ENV{SystemDrive}/MySQL/MySQL Server 8.0/bin"
"$ENV{SystemDrive}/MySQL/MySQL Server 5.7/bin"
"$ENV{MYSQL_ROOT}/bin"
DOC
"path to your mysql binary.")

View File

@ -153,7 +153,6 @@ if(WITH_STRICT_DATABASE_TYPE_CHECKS)
message(" *** WITH_STRICT_DATABASE_TYPE_CHECKS - WARNING!")
message(" *** Validates uses of database Get***() functions from Field class")
message(" *** invalid calls will result in returning value 0")
message(" *** NOT COMPATIBLE WITH MARIADB!")
add_definitions(-DACORE_STRICT_DATABASE_TYPE_CHECKS)
endif()

View File

@ -176,8 +176,7 @@ SourceDirectory = ""
# MySQLExecutable
# Description: The path to your MySQL CLI binary.
# If the path is left empty, built-in path from cmake is used.
# Example: "C:/Program Files/MariaDB 10.5/bin/mysql.exe"
# "C:/Program Files/MySQL/MySQL Server 8.0/bin/mysql.exe"
# Example: "C:/Program Files/MySQL/MySQL Server 8.4/bin/mysql.exe"
# "mysql.exe"
# "/usr/bin/mysql"
# Default: ""

View File

@ -386,12 +386,6 @@ int main(int argc, char** argv)
sScriptMgr->OnStartup();
// Be kind and warn people of EOL deprecation :)
#if !defined(MARIADB_VERSION_ID)
if (MySQL::GetLibraryVersion() < 80000)
LOG_WARN("server", "WARNING: You are using MySQL version 5.7 which is soon EOL!\nThis version will be deprecated. Consider upgrading to MySQL 8.0 or 8.1!");
#endif
// Launch CliRunnable thread
std::shared_ptr<std::thread> cliThread;
#if AC_PLATFORM == AC_PLATFORM_WINDOWS

View File

@ -59,15 +59,10 @@ DatabaseWorkerPool<T>::DatabaseWorkerPool() :
{
WPFatal(mysql_thread_safe(), "Used MySQL library isn't thread-safe.");
#if !defined(MARIADB_VERSION_ID) || MARIADB_VERSION_ID < 100600
bool isSupportClientDB = mysql_get_client_version() >= MIN_MYSQL_CLIENT_VERSION;
bool isSameClientDB = mysql_get_client_version() == MYSQL_VERSION_ID;
#else // MariaDB 10.6+
bool isSupportClientDB = mysql_get_client_version() >= MIN_MYSQL_CLIENT_VERSION;
bool isSameClientDB = true; // Client version 3.2.3?
#endif
WPFatal(isSupportClientDB, "AzerothCore does not support MySQL versions below 5.7 or MariaDB versions below 10.5.\n\nFound version: {} / {}. Server compiled with: {}.\nSearch the wiki for ACE00043 in Common Errors (https://www.azerothcore.org/wiki/common-errors#ace00043).",
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);
@ -378,8 +373,6 @@ void DatabaseWorkerPool<T>::KeepAlive()
*
* DatabaseIncompatibleVersion("8.0.35") => false
* DatabaseIncompatibleVersion("5.6.6") => true
* DatabaseIncompatibleVersion("5.5.5-10.5.5-MariaDB") => false
* DatabaseIncompatibleVersion("5.5.5-10.4.0-MariaDB") => true
*
* Adapted from stackoverflow response
* https://stackoverflow.com/a/2941508
@ -410,17 +403,6 @@ bool DatabaseIncompatibleVersion(std::string const mysqlVersion)
uint8 offset = 0;
std::string minVersion = MIN_MYSQL_SERVER_VERSION;
// If the version string contains "MariaDB", use that
if (mysqlVersion.find("MariaDB") != std::string::npos)
{
// All MariaDB 10.X versions have a prefix of 5.5.5 from the
// mysql_get_server_info() function. To make matters more
// annoying, this is removed in MariaDB 11.X
if (mysqlVersion.rfind("5.5.5-", 0) == 0)
offset = 6;
minVersion = MIN_MARIADB_SERVER_VERSION;
}
auto parsedMySQLVersion = parse(mysqlVersion.substr(offset));
auto parsedMinVersion = parse(minVersion);
@ -455,7 +437,7 @@ uint32 DatabaseWorkerPool<T>::OpenConnections(InternalIndex type, uint8 numConne
}
else if (DatabaseIncompatibleVersion(connection->GetServerInfo()))
{
LOG_ERROR("sql.driver", "AzerothCore does not support MySQL versions below 5.7 or MariaDB versions below 10.5.\n\nFound server version: {}. Server compiled with: {}.",
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);
return 1;
}

View File

@ -26,31 +26,17 @@
/** @file DatabaseWorkerPool.h */
/**
* @def MIN_MYSQL_CLIENT_VERSION
* The minimum MariaDB Client Version
* MARIADB_VERSION_ID is defined if using libmariadbclient instead of libmysqlclient
*/
#if MARIADB_VERSION_ID >= 100600
#define MIN_MYSQL_CLIENT_VERSION 30203u
#else
/**
* @def MIN_MYSQL_CLIENT_VERSION
* The minimum MySQL Client Version
*/
#define MIN_MYSQL_CLIENT_VERSION 50700u
#endif
#define MIN_MYSQL_CLIENT_VERSION 80000u
/**
* @def MIN_MYSQL_SERVER_VERSION
* The minimum MySQL Server Version
*/
#define MIN_MYSQL_SERVER_VERSION "5.7.0"
/**
* @def MIN_MARIADB_SERVER_VERSION
* The minimum MariaDB Server Version
*/
#define MIN_MARIADB_SERVER_VERSION "10.5.0"
#define MIN_MYSQL_SERVER_VERSION "8.0.0"
template <typename T>
class ProducerConsumerQueue;
@ -253,4 +239,4 @@ private:
#endif
};
#endif
#endif // _DATABASEWORKERPOOL_H

View File

@ -130,7 +130,6 @@ uint32 MySQLConnection::Open()
if (m_connectionInfo.ssl != "")
{
#if !defined(MARIADB_VERSION_ID) && MYSQL_VERSION_ID >= 80000
mysql_ssl_mode opt_use_ssl = SSL_MODE_DISABLED;
if (m_connectionInfo.ssl == "ssl")
{
@ -138,15 +137,6 @@ uint32 MySQLConnection::Open()
}
mysql_options(mysqlInit, MYSQL_OPT_SSL_MODE, (char const*)&opt_use_ssl);
#else
MySQLBool opt_use_ssl = MySQLBool(0);
if (m_connectionInfo.ssl == "ssl")
{
opt_use_ssl = MySQLBool(1);
}
mysql_options(mysqlInit, MYSQL_OPT_SSL_ENFORCE, (char const*)&opt_use_ssl);
#endif
}
m_Mysql = reinterpret_cast<MySQLHandle*>(mysql_real_connect(mysqlInit, m_connectionInfo.host.c_str(), m_connectionInfo.user.c_str(),
@ -227,7 +217,7 @@ bool MySQLConnection::Execute(PreparedStatementBase* stmt)
uint32 _s = getMSTime();
#if !defined(MARIADB_VERSION_ID) && (MYSQL_VERSION_ID >= 80300)
#if MYSQL_VERSION_ID >= 80300
if (mysql_stmt_bind_named_param(msql_STMT, msql_BIND, m_mStmt->GetParameterCount(), nullptr))
#else
if (mysql_stmt_bind_param(msql_STMT, msql_BIND))
@ -279,7 +269,7 @@ bool MySQLConnection::_Query(PreparedStatementBase* stmt, MySQLPreparedStatement
uint32 _s = getMSTime();
#if !defined(MARIADB_VERSION_ID) && (MYSQL_VERSION_ID >= 80300)
#if MYSQL_VERSION_ID >= 80300
if (mysql_stmt_bind_named_param(msql_STMT, msql_BIND, m_mStmt->GetParameterCount(), nullptr))
#else
if (mysql_stmt_bind_param(msql_STMT, msql_BIND))

View File

@ -493,18 +493,9 @@ void DBUpdater<T>::ApplyFile(DatabaseWorkerPool<T>& pool, std::string const& hos
// Set max allowed packet to 1 GB
args.emplace_back("--max-allowed-packet=1GB");
#if !defined(MARIADB_VERSION_ID) && MYSQL_VERSION_ID >= 80000
if (ssl == "ssl")
args.emplace_back("--ssl-mode=REQUIRED");
#else
if (ssl == "ssl")
args.emplace_back("--ssl");
#endif
// Execute sql file
args.emplace_back("-e");
args.emplace_back(Acore::StringFormat("BEGIN; SOURCE {}; COMMIT;", path.generic_string()));

View File

@ -54,7 +54,7 @@ SourceDirectory = ""
# MySQLExecutable
# Description: The path to your MySQL CLI binary.
# If the path is left empty, built-in path from cmake is used.
# Example: "C:/Program Files/MariaDB 10.9/bin/mysql.exe"
# Example: "C:/Program Files/MySQL Server 8.4/bin/mysql.exe"
# "mysql.exe"
# "/usr/bin/mysql"
# Default: ""