Core/Database: Silence deprecation warning on mysql_stmt_bind_param

This commit is contained in:
Shauren
2024-03-01 11:29:09 +01:00
parent 47c14bedef
commit 5c44ac1787

View File

@@ -207,6 +207,25 @@ bool MySQLConnection::Execute(char const* sql)
return true;
}
static auto mysql_bind_param_no_deprecated(MYSQL_STMT* stmt, MYSQL_BIND* bnd)
{
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#else
#pragma warning(push)
#pragma warning(disable: 4996)
#endif
return mysql_stmt_bind_param(stmt, bnd);
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
#pragma GCC diagnostic pop
#else
#pragma warning(pop)
#endif
}
bool MySQLConnection::Execute(PreparedStatementBase* stmt)
{
if (!m_Mysql)
@@ -224,7 +243,7 @@ bool MySQLConnection::Execute(PreparedStatementBase* stmt)
uint32 _s = getMSTime();
if (mysql_stmt_bind_param(msql_STMT, msql_BIND))
if (mysql_bind_param_no_deprecated(msql_STMT, msql_BIND))
{
uint32 lErrno = mysql_errno(m_Mysql);
TC_LOG_ERROR("sql.sql", "SQL(p): {}\n [ERROR]: [{}] {}", m_mStmt->getQueryString(), lErrno, mysql_stmt_error(msql_STMT));
@@ -272,7 +291,7 @@ bool MySQLConnection::_Query(PreparedStatementBase* stmt, MySQLPreparedStatement
uint32 _s = getMSTime();
if (mysql_stmt_bind_param(msql_STMT, msql_BIND))
if (mysql_bind_param_no_deprecated(msql_STMT, msql_BIND))
{
uint32 lErrno = mysql_errno(m_Mysql);
TC_LOG_ERROR("sql.sql", "SQL(p): {}\n [ERROR]: [{}] {}", m_mStmt->getQueryString(), lErrno, mysql_stmt_error(msql_STMT));