SQL: Auth db data type cleanup logs, realmcharacters, realmlist, uptime / Storage engine switched to InnoDB Note:

As for the redundant `uptime`.`startstring` being removed, this page might be of interest how to generate time strings from unix timestamps
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_from-unixtime
This commit is contained in:
leak
2012-03-28 19:46:38 +02:00
parent 6237ddac34
commit 7309ee5621
9 changed files with 48 additions and 36 deletions
+18 -19
View File
@@ -140,11 +140,11 @@ DROP TABLE IF EXISTS `logs`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `logs` (
`time` int(14) NOT NULL,
`realm` int(4) NOT NULL,
`type` int(4) NOT NULL,
`string` text
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
`time` int(10) unsigned NOT NULL,
`realm` int(10) unsigned NOT NULL,
`type` tinyint(3) unsigned NOT NULL,
`string` text CHARACTER SET latin1
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -164,12 +164,12 @@ DROP TABLE IF EXISTS `realmcharacters`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `realmcharacters` (
`realmid` int(11) unsigned NOT NULL DEFAULT '0',
`acctid` bigint(20) unsigned NOT NULL,
`realmid` int(10) unsigned NOT NULL DEFAULT '0',
`acctid` int(10) unsigned NOT NULL,
`numchars` tinyint(3) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`realmid`,`acctid`),
KEY `acctid` (`acctid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Realm Character Tracker';
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Realm Character Tracker';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -189,19 +189,19 @@ DROP TABLE IF EXISTS `realmlist`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `realmlist` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(32) NOT NULL DEFAULT '',
`address` varchar(32) NOT NULL DEFAULT '127.0.0.1',
`port` int(11) NOT NULL DEFAULT '8085',
`address` varchar(15) NOT NULL DEFAULT '127.0.0.1',
`port` smallint(5) unsigned NOT NULL DEFAULT '8085',
`icon` tinyint(3) unsigned NOT NULL DEFAULT '0',
`flag` tinyint(3) unsigned NOT NULL DEFAULT '2',
`timezone` tinyint(3) unsigned NOT NULL DEFAULT '0',
`allowedSecurityLevel` tinyint(3) unsigned NOT NULL DEFAULT '0',
`population` float unsigned NOT NULL DEFAULT '0',
`gamebuild` int(11) unsigned NOT NULL DEFAULT '12340',
`gamebuild` int(10) unsigned NOT NULL DEFAULT '12340',
PRIMARY KEY (`id`),
UNIQUE KEY `idx_name` (`name`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Realm System';
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='Realm System';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -222,14 +222,13 @@ DROP TABLE IF EXISTS `uptime`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `uptime` (
`realmid` int(11) unsigned NOT NULL,
`starttime` bigint(20) unsigned NOT NULL DEFAULT '0',
`startstring` varchar(64) NOT NULL DEFAULT '',
`uptime` bigint(20) unsigned NOT NULL DEFAULT '0',
`realmid` int(10) unsigned NOT NULL,
`starttime` int(10) unsigned NOT NULL DEFAULT '0',
`uptime` int(10) unsigned NOT NULL DEFAULT '0',
`maxplayers` smallint(5) unsigned NOT NULL DEFAULT '0',
`revision` varchar(255) NOT NULL DEFAULT 'Trinitycore',
PRIMARY KEY (`realmid`,`starttime`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Uptime system';
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Uptime system';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -250,4 +249,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2012-03-28 16:44:39
-- Dump completed on 2012-03-28 18:26:06
+5
View File
@@ -0,0 +1,5 @@
ALTER TABLE `logs`
CHANGE `time` `time` INT(10) UNSIGNED NOT NULL,
CHANGE `realm` `realm` INT(10) UNSIGNED NOT NULL,
CHANGE `type` `type` TINYINT(3) UNSIGNED NOT NULL,
ROW_FORMAT=DEFAULT ENGINE=INNODB;
@@ -0,0 +1,4 @@
ALTER TABLE `realmcharacters`
CHANGE `realmid` `realmid` INT(10) UNSIGNED DEFAULT 0 NOT NULL,
CHANGE `acctid` `acctid` INT(10) UNSIGNED NOT NULL,
ROW_FORMAT=DEFAULT ENGINE=INNODB;
@@ -0,0 +1,6 @@
ALTER TABLE `realmlist`
CHANGE `id` `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
CHANGE `address` `address` VARCHAR(15) DEFAULT '127.0.0.1' NOT NULL,
CHANGE `port` `port` SMALLINT(5) UNSIGNED DEFAULT '8085' NOT NULL,
CHANGE `gamebuild` `gamebuild` INT(10) UNSIGNED DEFAULT '12340' NOT NULL,
ROW_FORMAT=DEFAULT ENGINE=INNODB;
@@ -0,0 +1,6 @@
ALTER TABLE `uptime`
DROP COLUMN `startstring`,
CHANGE `realmid` `realmid` INT(10) UNSIGNED NOT NULL,
CHANGE `starttime` `starttime` INT(10) UNSIGNED DEFAULT 0 NOT NULL,
CHANGE `uptime` `uptime` INT(10) UNSIGNED DEFAULT 0 NOT NULL,
ROW_FORMAT=DEFAULT ENGINE=INNODB;
+2 -2
View File
@@ -31,7 +31,7 @@ void RealmList::Initialize(uint32 updateInterval)
UpdateRealms(true);
}
void RealmList::UpdateRealm(uint32 ID, const std::string& name, const std::string& address, uint32 port, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float popu, uint32 build)
void RealmList::UpdateRealm(uint32 ID, const std::string& name, const std::string& address, uint16 port, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float popu, uint32 build)
{
// Create new if not exist or update existed
Realm& realm = m_realms[name];
@@ -82,7 +82,7 @@ void RealmList::UpdateRealms(bool init)
uint32 realmId = fields[0].GetUInt32();
const std::string& name = fields[1].GetString();
const std::string& address = fields[2].GetString();
uint32 port = fields[3].GetUInt32();
uint16 port = fields[3].GetUInt16();
uint8 icon = fields[4].GetUInt8();
RealmFlags flag = RealmFlags(fields[5].GetUInt8());
uint8 timezone = fields[6].GetUInt8();
+1 -1
View File
@@ -71,7 +71,7 @@ public:
private:
void UpdateRealms(bool init=false);
void UpdateRealm(uint32 ID, const std::string& name, const std::string& address, uint32 port, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float popu, uint32 build);
void UpdateRealm(uint32 ID, const std::string& name, const std::string& address, uint16 port, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float popu, uint32 build);
RealmMap m_realms;
uint32 m_UpdateInterval;
+4 -12
View File
@@ -1671,16 +1671,8 @@ void World::SetInitialWorldSettings()
m_gameTime = time(NULL);
m_startTime = m_gameTime;
tm local;
time_t curr;
time(&curr);
local=*(localtime(&curr)); // dereference and assign
char isoDate[128];
sprintf(isoDate, "%04d-%02d-%02d %02d:%02d:%02d",
local.tm_year+1900, local.tm_mon+1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec);
LoginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, startstring, uptime, revision) VALUES('%u', " UI64FMTD ", '%s', 0, '%s')",
realmID, uint64(m_startTime), isoDate, _FULLVERSION); // One-time query
LoginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, uptime, revision) VALUES(%u, %u, '%s', 0, '%s')",
realmID, uint32(m_startTime), _FULLVERSION); // One-time query
m_timers[WUPDATE_WEATHERS].SetInterval(1*IN_MILLISECONDS);
m_timers[WUPDATE_AUCTIONS].SetInterval(MINUTE*IN_MILLISECONDS);
@@ -1965,10 +1957,10 @@ void World::Update(uint32 diff)
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_UPTIME_PLAYERS);
stmt->setUInt64(0, uint64(tmpDiff));
stmt->setUInt32(0, tmpDiff);
stmt->setUInt16(1, uint16(maxOnlinePlayers));
stmt->setUInt32(2, realmID);
stmt->setUInt64(3, uint64(m_startTime));
stmt->setUInt32(3, uint32(m_startTime));
LoginDatabase.Execute(stmt);
}
+1 -1
View File
@@ -382,7 +382,7 @@ void Log::outDB(LogTypes type, const char * str)
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_LOG);
stmt->setInt32(0, realm);
stmt->setInt32(1, type);
stmt->setUInt8(1, uint8(type));
stmt->setString(2, logStr);
LoginDatabase.Execute(stmt);