From 3c6dc320308880bde4ef9eddd695db28a74aa0d9 Mon Sep 17 00:00:00 2001 From: Machiavelli Date: Fri, 24 Sep 2010 22:16:21 +0200 Subject: Core/DBLayer: - Rewrite Field class to be able to store both binary prepared statement data and data from adhoc query resultsets - Buffer the data of prepared statements using ResultSet and Field classes and let go of mysql c api structures after PreparedResultSet constructor. Fixes a race condition and thus a possible crash/data corruption (issue pointed out to Derex, basic suggestion by raczman) - Conform PreparedResultSet and ResultSet to the same design standards, and using Field class as data buffer class for both * NOTE: This means the fetching methods are uniform again, using ¨Field* fields = result->Fetch();¨ and access to elements trough fields[x]. * NOTE: for access to the correct row in prepared statements, ¨Field* fields = result->Fetch();¨ must ALWAYS be called inside the do { }while(result->NextRow()) loop. * NOTE: This means that Field::GetString() returns std::string object and Field::GetCString() returns const char* pointer. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Still experimental and all that jazz, not recommended for production servers until feedback is given. --HG-- branch : trunk --- src/server/game/Chat/Chat.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/server/game/Chat/Chat.cpp') diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index fd855fc82e1..a0175b43533 100644 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -814,9 +814,9 @@ ChatCommand * ChatHandler::getCommandTable() do { Field *fields = result->Fetch(); - std::string name = fields[0].GetCppString(); + std::string name = fields[0].GetString(); - SetDataForCommandInTable(commandTable, name.c_str(), fields[1].GetUInt16(), fields[2].GetCppString(), name); + SetDataForCommandInTable(commandTable, name.c_str(), fields[1].GetUInt16(), fields[2].GetString(), name); } while (result->NextRow()); } -- cgit v1.2.3