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/authserver/Realms/RealmList.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/server/authserver/Realms') diff --git a/src/server/authserver/Realms/RealmList.cpp b/src/server/authserver/Realms/RealmList.cpp index 493614bc963..665fe7b6aee 100644 --- a/src/server/authserver/Realms/RealmList.cpp +++ b/src/server/authserver/Realms/RealmList.cpp @@ -86,21 +86,22 @@ void RealmList::UpdateRealms(bool init) { do { - uint32 realmId = result->GetUInt32(0); - const std::string& name = result->GetString(1); - const std::string& address = result->GetString(2); - uint32 port = result->GetUInt32(3); - uint8 icon = result->GetUInt8(4); - uint8 color = result->GetUInt8(5); - uint8 timezone = result->GetUInt8(6); - uint8 allowedSecurityLevel = result->GetUInt8(7); - float pop = result->GetFloat(8); - uint32 build = result->GetUInt32(9); + Field* fields = result->Fetch(); + uint32 realmId = fields[0].GetUInt32(); + const std::string& name = fields[1].GetString(); + const std::string& address = fields[2].GetString(); + uint32 port = fields[3].GetUInt32(); + uint8 icon = fields[4].GetUInt8(); + uint8 color = fields[5].GetUInt8(); + uint8 timezone = fields[6].GetUInt8(); + uint8 allowedSecurityLevel = fields[7].GetUInt8(); + float pop = fields[8].GetFloat(); + uint32 build = fields[9].GetUInt32(); UpdateRealm(realmId, name, address, port, icon, color, timezone, (allowedSecurityLevel <= SEC_ADMINISTRATOR ? AccountTypes(allowedSecurityLevel) : SEC_ADMINISTRATOR), pop, build); if (init) - sLog.outString("Added realm \"%s\".", result->GetString(1).c_str()); + sLog.outString("Added realm \"%s\".", fields[1].GetCString()); } while (result->NextRow()); } -- cgit v1.2.3