Skip to content

Commit

Permalink
Remove character data blob.
Browse files Browse the repository at this point in the history
Update will create backup in data_backup table, just in case...
You can drop this when you think you don't need it anymore.
(I would recommend you to keep it for a few days/weeks)

Signed-off-by: hunuza <hunuza@gmail.com>
  • Loading branch information
hunuza committed Mar 27, 2010
1 parent a73e510 commit d65cf5b
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 183 deletions.
4 changes: 3 additions & 1 deletion sql/characters.sql
Expand Up @@ -193,7 +193,6 @@ DROP TABLE IF EXISTS `characters`;
CREATE TABLE `characters` (
`guid` int(11) unsigned NOT NULL default '0' COMMENT 'Global Unique Identifier',
`account` int(11) unsigned NOT NULL default '0' COMMENT 'Account Identifier',
`data` longtext,
`name` varchar(12) NOT NULL default '',
`race` tinyint(3) unsigned NOT NULL default '0',
`class` tinyint(3) unsigned NOT NULL default '0',
Expand Down Expand Up @@ -252,6 +251,9 @@ CREATE TABLE `characters` (
`power7` int(10) UNSIGNED NOT NULL default '0',
`specCount` tinyint(3) UNSIGNED NOT NULL default '1',
`activeSpec` tinyint(3) UNSIGNED NOT NULL default '0',
`exploredZones` longtext,
`equipmentCache` longtext,
`ammoId` int(10) UNSIGNED NOT NULL default '0',
PRIMARY KEY (`guid`),
KEY `idx_account` (`account`),
KEY `idx_online` (`online`),
Expand Down
27 changes: 27 additions & 0 deletions sql/updates/9999_01_characters_characters.sql
@@ -0,0 +1,27 @@
ALTER TABLE characters
ADD COLUMN `exploredZones` longtext AFTER activeSpec,
ADD COLUMN `equipmentCache` longtext AFTER exploredZones,
ADD COLUMN `ammoId` int(10) UNSIGNED NOT NULL default '0' AFTER equipmentCache;

UPDATE characters SET
exploredZones = SUBSTRING(data,
length(SUBSTRING_INDEX(data, ' ', 1041))+2,
length(SUBSTRING_INDEX(data, ' ', 1168+1))- length(SUBSTRING_INDEX(data, ' ', 1041)) - 1),
equipmentCache = SUBSTRING(data,
length(SUBSTRING_INDEX(data, ' ', 283))+2,
length(SUBSTRING_INDEX(data, ' ', 320+1))- length(SUBSTRING_INDEX(data, ' ', 283)) - 1),
ammoId = SUBSTRING(data,
length(SUBSTRING_INDEX(data, ' ', 1198))+2,
length(SUBSTRING_INDEX(data, ' ', 1198+1))- length(SUBSTRING_INDEX(data, ' ', 1198)) - 1);

CREATE TABLE `data_backup` (
`guid` int(11) unsigned NOT NULL default '0' COMMENT 'Global Unique Identifier',
`data` longtext,
PRIMARY KEY (`guid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO data_backup (guid, data) (SELECT guid, data FROM characters);


ALTER TABLE characters
DROP COLUMN data;
12 changes: 6 additions & 6 deletions src/game/CharacterHandler.cpp
Expand Up @@ -68,11 +68,11 @@ bool LoginQueryHolder::Initialize()

// NOTE: all fields in `characters` must be read to prevent lost character data at next save in case wrong DB structure.
// !!! NOTE: including unused `zone`,`online`
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADFROM, "SELECT guid, account, data, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags,"
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADFROM, "SELECT guid, account, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags,"
"position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost,"
"resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty,"
"arenaPoints, totalHonorPoints, todayHonorPoints, yesterdayHonorPoints, totalKills, todayKills, yesterdayKills, chosenTitle, knownCurrencies, watchedFaction, drunk,"
"health, power1, power2, power3, power4, power5, power6, power7, specCount, activeSpec FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid));
"health, power1, power2, power3, power4, power5, power6, power7, specCount, activeSpec, exploredZones, equipmentCache, ammoId FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid));
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGROUP, "SELECT groupId FROM group_member WHERE memberGuid ='%u'", GUID_LOPART(m_guid));
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES, "SELECT id, permanent, map, difficulty, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = '%u'", GUID_LOPART(m_guid));
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADAURAS, "SELECT caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'", GUID_LOPART(m_guid));
Expand Down Expand Up @@ -145,7 +145,7 @@ void WorldSession::HandleCharEnum(QueryResult * result)
do
{
uint32 guidlow = (*result)[0].GetUInt32();
sLog.outDetail("Loading char guid %u from account %u.", guidlow, GetAccountId());
sLog.outDetail("Build enum data for char guid %u from account %u.", guidlow, GetAccountId());
if(Player::BuildEnumData(result, &data))
++num;
}
Expand All @@ -170,7 +170,7 @@ void WorldSession::HandleCharEnumOpcode( WorldPacket & /*recv_data*/ )
// 8 9 10 11 12 13 14
"characters.zone, characters.map, characters.position_x, characters.position_y, characters.position_z, guild_member.guildid, characters.playerFlags, "
// 15 16 17 18 19
"characters.at_login, character_pet.entry, character_pet.modelid, character_pet.level, characters.data "
"characters.at_login, character_pet.entry, character_pet.modelid, character_pet.level, characters.equipmentCache "
"FROM characters LEFT JOIN character_pet ON characters.guid=character_pet.owner AND character_pet.slot='%u' "
"LEFT JOIN guild_member ON characters.guid = guild_member.guid "
"WHERE characters.account = '%u' ORDER BY characters.guid"
Expand All @@ -180,8 +180,8 @@ void WorldSession::HandleCharEnumOpcode( WorldPacket & /*recv_data*/ )
"SELECT characters.guid, characters.name, characters.race, characters.class, characters.gender, characters.playerBytes, characters.playerBytes2, characters.level, "
// 8 9 10 11 12 13 14
"characters.zone, characters.map, characters.position_x, characters.position_y, characters.position_z, guild_member.guildid, characters.playerFlags, "
// 15 16 17 18 19 20
"characters.at_login, character_pet.entry, character_pet.modelid, character_pet.level, characters.data, character_declinedname.genitive "
// 15 16 17 18 19 20
"characters.at_login, character_pet.entry, character_pet.modelid, character_pet.level, characters.equipmentCache, character_declinedname.genitive "
"FROM characters LEFT JOIN character_pet ON characters.guid = character_pet.owner AND character_pet.slot='%u' "
"LEFT JOIN character_declinedname ON characters.guid = character_declinedname.guid "
"LEFT JOIN guild_member ON characters.guid = guild_member.guid "
Expand Down

13 comments on commit d65cf5b

@nerzhul
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also remove titles bye bye titles :) epic failed :)

@waza123
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ALTER TABLE characters DROP COLUMN data;

sounds bad.

@luisalvarado
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will help a lot in web management pages.

@PatSmuk
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you actually read the commit, you would see that all character data is backed-up. Nothing is actually lost, unless you choose to drop the back-ups it makes. These back-ups are used in the later commit to make titles work again.

@Tasssadar
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, I cant believe that its already everything in other columns/tables, good work!

@kero99
Copy link

@kero99 kero99 commented on d65cf5b Mar 28, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yessssssssssssssss!!!! good work!! more performance to db!!, now if we kill item_instance blob... db will fly!! ^^. Good work devel

@nanouniko
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow kero, i want think, how is possible remove item_instance, maybe create a single table like arcemu playeritems who store the data character_inventory & item_instance, nice change this would be!

Cya!

@luisalvarado
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nanouniko - You know what, i was thinking that a long time ago. Merge both tables into one which could help in managing the items cause they share similar information.

@hunuza
Copy link
Contributor Author

@hunuza hunuza commented on d65cf5b Mar 29, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

item_instance is not only used by character_inventory but also by other tables like mail_items, so you can't merge them into one...

@luisalvarado
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hunuza - Thanks for the tip.

@themegosh
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow guys, congrats... a pretty big milestone imo

@nanouniko
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so i like to know, how arcemu can?

@hunuza
Copy link
Contributor Author

@hunuza hunuza commented on d65cf5b Mar 30, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know about arcemu, but they probably have a different database design...

Please sign in to comment.