CharDB Schema/Cleanup: cleanup account_data and character_account_data tables:
* rename column account to accountId; * introduce prepared statements for both tables.
This commit is contained in:
@@ -75,7 +75,9 @@ AccountOpResult AccountMgr::DeleteAccount(uint32 accid)
|
||||
|
||||
// table realm specific but common for all characters of account for realm
|
||||
CharacterDatabase.PExecute("DELETE FROM character_tutorial WHERE account = '%u'",accid);
|
||||
CharacterDatabase.PExecute("DELETE FROM account_data WHERE account = '%u'",accid);
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ACCOUNT_DATA);
|
||||
stmt->setUInt32(0, accid);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
SQLTransaction trans = LoginDatabase.BeginTransaction();
|
||||
|
||||
|
||||
@@ -4630,7 +4630,9 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
|
||||
}
|
||||
|
||||
trans->PAppend("DELETE FROM characters WHERE guid = '%u'",guid);
|
||||
trans->PAppend("DELETE FROM character_account_data WHERE guid = '%u'",guid);
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_ACCOUNT_DATA);
|
||||
stmt->setUInt32(0, guid);
|
||||
trans->Append(stmt);
|
||||
trans->PAppend("DELETE FROM character_declinedname WHERE guid = '%u'",guid);
|
||||
trans->PAppend("DELETE FROM character_action WHERE guid = '%u'",guid);
|
||||
trans->PAppend("DELETE FROM character_aura WHERE guid = '%u'",guid);
|
||||
|
||||
@@ -166,7 +166,7 @@ bool LoginQueryHolder::Initialize()
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADTALENTS, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_ACCOUNTDATA);
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_ACCOUNT_DATA);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADACCOUNTDATA, stmt);
|
||||
|
||||
|
||||
@@ -596,7 +596,7 @@ void WorldSession::SendAuthWaitQue(uint32 position)
|
||||
|
||||
void WorldSession::LoadGlobalAccountData()
|
||||
{
|
||||
PreparedStatement *stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_ACCOUNT_DATA);
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_ACCOUNT_DATA);
|
||||
stmt->setUInt32(0, GetAccountId());
|
||||
LoadAccountData(CharacterDatabase.Query(stmt), GLOBAL_CACHE_MASK);
|
||||
}
|
||||
@@ -632,17 +632,14 @@ void WorldSession::LoadAccountData(PreparedQueryResult result, uint32 mask)
|
||||
while (result->NextRow());
|
||||
}
|
||||
|
||||
void WorldSession::SetAccountData(AccountDataType type, time_t time_, std::string data)
|
||||
void WorldSession::SetAccountData(AccountDataType type, time_t tm, std::string data)
|
||||
{
|
||||
uint32 id = 0;
|
||||
uint32 index = 0;
|
||||
if ((1 << type) & GLOBAL_CACHE_MASK)
|
||||
{
|
||||
uint32 acc = GetAccountId();
|
||||
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
trans->PAppend("DELETE FROM account_data WHERE account='%u' AND type='%u'", acc, type);
|
||||
CharacterDatabase.escape_string(data);
|
||||
trans->PAppend("INSERT INTO account_data VALUES ('%u','%u','%u','%s')", acc, type, (uint32)time_, data.c_str());
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
id = GetAccountId();
|
||||
index = CHAR_SET_ACCOUNT_DATA;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -650,14 +647,18 @@ void WorldSession::SetAccountData(AccountDataType type, time_t time_, std::strin
|
||||
if (!m_GUIDLow)
|
||||
return;
|
||||
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
trans->PAppend("DELETE FROM character_account_data WHERE guid='%u' AND type='%u'", m_GUIDLow, type);
|
||||
CharacterDatabase.escape_string(data);
|
||||
trans->PAppend("INSERT INTO character_account_data VALUES ('%u','%u','%u','%s')", m_GUIDLow, type, (uint32)time_, data.c_str());
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
id = m_GUIDLow;
|
||||
index = CHAR_SET_PLAYER_ACCOUNT_DATA;
|
||||
}
|
||||
|
||||
m_accountData[type].Time = time_;
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(index);
|
||||
stmt->setUInt32(0, id);
|
||||
stmt->setUInt8 (1, type);
|
||||
stmt->setUInt32(2, uint32(tm));
|
||||
stmt->setString(3, data);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
m_accountData[type].Time = tm;
|
||||
m_accountData[type].Data = data;
|
||||
}
|
||||
|
||||
|
||||
@@ -278,10 +278,11 @@ class WorldSession
|
||||
|
||||
// Account Data
|
||||
AccountData *GetAccountData(AccountDataType type) { return &m_accountData[type]; }
|
||||
void SetAccountData(AccountDataType type, time_t time_, std::string data);
|
||||
void SetAccountData(AccountDataType type, time_t tm, std::string data);
|
||||
void SendAccountDataTimes(uint32 mask);
|
||||
void LoadGlobalAccountData();
|
||||
void LoadAccountData(PreparedQueryResult result, uint32 mask);
|
||||
|
||||
void LoadTutorialsData();
|
||||
void SendTutorialsData();
|
||||
void SaveTutorialsData(SQLTransaction& trans);
|
||||
|
||||
Reference in New Issue
Block a user