From c3a9d56b56b665133707f587ecb1bd1c272f6911 Mon Sep 17 00:00:00 2001 From: Shauren Date: Fri, 1 Nov 2019 16:21:14 +0100 Subject: Core/DBLayer: Support using mysql 8 --- src/server/database/Database/MySQLConnection.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/server/database/Database/MySQLConnection.h') diff --git a/src/server/database/Database/MySQLConnection.h b/src/server/database/Database/MySQLConnection.h index ea9ce7eb46f..0340d7e62c4 100644 --- a/src/server/database/Database/MySQLConnection.h +++ b/src/server/database/Database/MySQLConnection.h @@ -66,19 +66,18 @@ class TC_DATABASE_API MySQLConnection bool PrepareStatements(); - public: bool Execute(const char* sql); bool Execute(PreparedStatementBase* stmt); ResultSet* Query(const char* sql); PreparedResultSet* Query(PreparedStatementBase* stmt); - bool _Query(const char *sql, MYSQL_RES **pResult, MYSQL_FIELD **pFields, uint64* pRowCount, uint32* pFieldCount); - bool _Query(PreparedStatementBase* stmt, MYSQL_RES **pResult, uint64* pRowCount, uint32* pFieldCount); + bool _Query(const char* sql, MySQLResult** pResult, MySQLField** pFields, uint64* pRowCount, uint32* pFieldCount); + bool _Query(PreparedStatementBase* stmt, MySQLResult** pResult, uint64* pRowCount, uint32* pFieldCount); void BeginTransaction(); void RollbackTransaction(); void CommitTransaction(); int ExecuteTransaction(std::shared_ptr transaction); - + size_t EscapeString(char* to, const char* from, size_t length); void Ping(); uint32 GetLastError(); @@ -91,13 +90,12 @@ class TC_DATABASE_API MySQLConnection /// Called by parent databasepool. Will let other threads access this connection void Unlock(); - MYSQL* GetHandle() { return m_Mysql; } + uint32 GetServerVersion() const; MySQLPreparedStatement* GetPreparedStatement(uint32 index); void PrepareStatement(uint32 index, std::string const& sql, ConnectionFlags flags); virtual void DoPrepareStatements() = 0; - protected: typedef std::vector> PreparedStatementContainer; PreparedStatementContainer m_stmts; //! PreparedStatements storage @@ -107,10 +105,9 @@ class TC_DATABASE_API MySQLConnection private: bool _HandleMySQLErrno(uint32 errNo, uint8 attempts = 5); - private: ProducerConsumerQueue* m_queue; //! Queue shared with other asynchronous connections. std::unique_ptr m_worker; //! Core worker task. - MYSQL* m_Mysql; //! MySQL Handle. + MySQLHandle* m_Mysql; //! MySQL Handle. MySQLConnectionInfo& m_connectionInfo; //! Connection info (used for logging) ConnectionFlags m_connectionFlags; //! Connection flags (for preparing relevant statements) std::mutex m_Mutex; -- cgit v1.2.3