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.
Still experimental and all that jazz, not recommended for production servers until feedback is given.
--HG--
branch : trunk
This commit is contained in:
@@ -1845,7 +1845,7 @@ void World::LoadAutobroadcasts()
|
||||
|
||||
Field *fields = result->Fetch();
|
||||
|
||||
std::string message = fields[0].GetCppString();
|
||||
std::string message = fields[0].GetString();
|
||||
|
||||
m_Autobroadcasts.push_back(message);
|
||||
|
||||
@@ -2319,7 +2319,7 @@ BanReturn World::BanCharacter(std::string name, std::string duration, std::strin
|
||||
if (!resultCharacter)
|
||||
return BAN_NOTFOUND; // Nobody to ban
|
||||
|
||||
guid = resultCharacter->GetUInt32(0);
|
||||
guid = (*resultCharacter)[0].GetUInt32();
|
||||
}
|
||||
else
|
||||
guid = pBanned->GetGUIDLow();
|
||||
@@ -2353,7 +2353,7 @@ bool World::RemoveBanCharacter(std::string name)
|
||||
if (!resultCharacter)
|
||||
return false;
|
||||
|
||||
guid = resultCharacter->GetUInt32(0);
|
||||
guid = (*resultCharacter)[0].GetUInt32();
|
||||
}
|
||||
else
|
||||
guid = pBanned->GetGUIDLow();
|
||||
@@ -2728,8 +2728,8 @@ void World::LoadDBVersion()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
m_DBVersion = fields[0].GetCppString();
|
||||
m_CreatureEventAIVersion = fields[1].GetCppString();
|
||||
m_DBVersion = fields[0].GetString();
|
||||
m_CreatureEventAIVersion = fields[1].GetString();
|
||||
|
||||
// will be overwrite by config values if different and non-0
|
||||
m_int_configs[CONFIG_CLIENTCACHE_VERSION] = fields[2].GetUInt32();
|
||||
|
||||
Reference in New Issue
Block a user