From d131bd1da0bf1b835ef912713dd7444361aa0089 Mon Sep 17 00:00:00 2001 From: ariel- Date: Wed, 1 Mar 2017 22:20:53 -0300 Subject: Core/Database: Prepared statement parameter preallocation (#18999) - Pass prepared statement size to the helper class to prevent runtime resizing. - Rename CheckValidIndex -> AssertValidIndex - Cached prepared size on the worker pool as it's shared among all connections - Cached query data only for each connection, done lookup in map instead of possibly creating a new element - Kill the prepared statement map, and store raw sql string on the MySQLPreparedStatement class (This info is only used for logging, and there is no need of keeping a second container just for it) (cherrypicked from affee140c6a8e1e9358be2aa0d0088ede218acaa) --- src/server/database/Database/MySQLConnection.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 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 1e0c65cb27c..ea9ce7eb46f 100644 --- a/src/server/database/Database/MySQLConnection.h +++ b/src/server/database/Database/MySQLConnection.h @@ -51,8 +51,6 @@ struct TC_DATABASE_API MySQLConnectionInfo std::string port_or_socket; }; -typedef std::map > PreparedStatementMap; - class TC_DATABASE_API MySQLConnection { template friend class DatabaseWorkerPool; @@ -95,13 +93,14 @@ class TC_DATABASE_API MySQLConnection MYSQL* GetHandle() { return m_Mysql; } MySQLPreparedStatement* GetPreparedStatement(uint32 index); - void PrepareStatement(uint32 index, const char* sql, ConnectionFlags flags); + void PrepareStatement(uint32 index, std::string const& sql, ConnectionFlags flags); virtual void DoPrepareStatements() = 0; protected: - std::vector> m_stmts; //! PreparedStatements storage - PreparedStatementMap m_queries; //! Query storage + typedef std::vector> PreparedStatementContainer; + + PreparedStatementContainer m_stmts; //! PreparedStatements storage bool m_reconnecting; //! Are we reconnecting? bool m_prepareError; //! Was there any error while preparing statements? -- cgit v1.2.3