aboutsummaryrefslogtreecommitdiff
path: root/src/server/database/Database/MySQLConnection.h
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2017-03-01 22:20:53 -0300
committerShauren <shauren.trinity@gmail.com>2019-08-17 20:04:14 +0200
commitd131bd1da0bf1b835ef912713dd7444361aa0089 (patch)
treeeaf996d245eb0d7b1ad525841050a1fb4336dbb9 /src/server/database/Database/MySQLConnection.h
parent60663d1374beef3103f4787152654034fa4a8897 (diff)
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)
Diffstat (limited to 'src/server/database/Database/MySQLConnection.h')
-rw-r--r--src/server/database/Database/MySQLConnection.h9
1 files changed, 4 insertions, 5 deletions
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<uint32 /*index*/, std::pair<std::string /*query*/, ConnectionFlags /*sync/async*/> > PreparedStatementMap;
-
class TC_DATABASE_API MySQLConnection
{
template <class T> 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<std::unique_ptr<MySQLPreparedStatement>> m_stmts; //! PreparedStatements storage
- PreparedStatementMap m_queries; //! Query storage
+ typedef std::vector<std::unique_ptr<MySQLPreparedStatement>> PreparedStatementContainer;
+
+ PreparedStatementContainer m_stmts; //! PreparedStatements storage
bool m_reconnecting; //! Are we reconnecting?
bool m_prepareError; //! Was there any error while preparing statements?