From 65dbc7082a60b67b76966259130aedc337af3eca Mon Sep 17 00:00:00 2001 From: Shauren Date: Wed, 26 Aug 2015 17:00:26 +0200 Subject: Core/DBLayer: Optimized prepared statement query results by eliminating unneeded buffer copies * Improved error logs for using incorrect Field getters to also include table name, field name and field index. --- src/server/database/Database/QueryResult.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/server/database/Database/QueryResult.h') diff --git a/src/server/database/Database/QueryResult.h b/src/server/database/Database/QueryResult.h index a61fb6331c1..0447ecaae5a 100644 --- a/src/server/database/Database/QueryResult.h +++ b/src/server/database/Database/QueryResult.h @@ -73,18 +73,18 @@ class PreparedResultSet Field* Fetch() const { ASSERT(m_rowPosition < m_rowCount); - return m_rows[uint32(m_rowPosition)]; + return const_cast(&m_rows[uint32(m_rowPosition) * m_fieldCount]); } - const Field & operator [] (uint32 index) const + Field const& operator[](uint32 index) const { ASSERT(m_rowPosition < m_rowCount); ASSERT(index < m_fieldCount); - return m_rows[uint32(m_rowPosition)][index]; + return m_rows[uint32(m_rowPosition) * m_fieldCount + index]; } protected: - std::vector m_rows; + std::vector m_rows; uint64 m_rowCount; uint64 m_rowPosition; uint32 m_fieldCount; @@ -92,12 +92,11 @@ class PreparedResultSet private: MYSQL_BIND* m_rBind; MYSQL_STMT* m_stmt; - MYSQL_RES* m_res; + MYSQL_RES* m_metadataResult; ///< Field metadata, returned by mysql_stmt_result_metadata my_bool* m_isNull; unsigned long* m_length; - void FreeBindBuffer(); void CleanUp(); bool _NextRow(); -- cgit v1.2.3