summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2016-07-08 02:21:04 +0200
committerGitHub <noreply@github.com>2016-07-08 02:21:04 +0200
commit72a06cdfa933534319a99cecc781b56acecce9cd (patch)
tree38e440734065a76cdf36dc74b1011687cd5d8927
parenta088c365019a92251c7163a2379cfcdce8bedd12 (diff)
parent6a84cbb2d527a0fb263a9104690bcfcb24f182e1 (diff)
downloadhercules-72a06cdfa933534319a99cecc781b56acecce9cd.tar.gz
hercules-72a06cdfa933534319a99cecc781b56acecce9cd.tar.bz2
hercules-72a06cdfa933534319a99cecc781b56acecce9cd.tar.xz
hercules-72a06cdfa933534319a99cecc781b56acecce9cd.zip
Merge pull request #1344 from 4144/sqlfix
Replace in sql files fields with default date/datetime into default N…
-rw-r--r--sql-files/logs.sql16
-rw-r--r--sql-files/main.sql14
-rw-r--r--sql-files/upgrades/2016-07-08--02-42.sql35
-rw-r--r--sql-files/upgrades/2016-07-08--02-51.sql30
-rw-r--r--sql-files/upgrades/eAthena-logs-upgrade.sql9
-rw-r--r--sql-files/upgrades/eAthena-main-upgrade.sql14
-rw-r--r--sql-files/upgrades/index.txt2
-rw-r--r--sql-files/upgrades/rAthena-logs-upgrade.sql8
-rw-r--r--sql-files/upgrades/rAthena-main-upgrade.sql13
-rw-r--r--src/login/account_sql.c4
10 files changed, 129 insertions, 16 deletions
diff --git a/sql-files/logs.sql b/sql-files/logs.sql
index ab722a2fe..71c1ce86b 100644
--- a/sql-files/logs.sql
+++ b/sql-files/logs.sql
@@ -43,7 +43,7 @@
CREATE TABLE IF NOT EXISTS `atcommandlog` (
`atcommand_id` MEDIUMINT(9) UNSIGNED NOT NULL AUTO_INCREMENT,
- `atcommand_date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `atcommand_date` DATETIME NULL,
`account_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`char_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`char_name` VARCHAR(25) NOT NULL DEFAULT '',
@@ -60,7 +60,7 @@ CREATE TABLE IF NOT EXISTS `atcommandlog` (
CREATE TABLE IF NOT EXISTS `branchlog` (
`branch_id` MEDIUMINT(9) UNSIGNED NOT NULL AUTO_INCREMENT,
- `branch_date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `branch_date` DATETIME NULL,
`account_id` INT(11) NOT NULL DEFAULT '0',
`char_id` INT(11) NOT NULL DEFAULT '0',
`char_name` VARCHAR(25) NOT NULL DEFAULT '',
@@ -76,7 +76,7 @@ CREATE TABLE IF NOT EXISTS `branchlog` (
CREATE TABLE IF NOT EXISTS `chatlog` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
- `time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `time` DATETIME NULL,
`type` ENUM('O','W','P','G','M') NOT NULL DEFAULT 'O',
`type_id` INT(11) NOT NULL DEFAULT '0',
`src_charid` INT(11) NOT NULL DEFAULT '0',
@@ -96,7 +96,7 @@ CREATE TABLE IF NOT EXISTS `chatlog` (
--
CREATE TABLE IF NOT EXISTS `loginlog` (
- `time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `time` DATETIME NULL,
`ip` VARCHAR(15) NOT NULL DEFAULT '',
`user` VARCHAR(23) NOT NULL DEFAULT '',
`rcode` TINYINT(4) NOT NULL DEFAULT '0',
@@ -110,7 +110,7 @@ CREATE TABLE IF NOT EXISTS `loginlog` (
CREATE TABLE IF NOT EXISTS `mvplog` (
`mvp_id` MEDIUMINT(9) UNSIGNED NOT NULL AUTO_INCREMENT,
- `mvp_date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `mvp_date` DATETIME NULL,
`kill_char_id` INT(11) NOT NULL DEFAULT '0',
`monster_id` SMALLINT(6) NOT NULL DEFAULT '0',
`prize` INT(11) NOT NULL DEFAULT '0',
@@ -125,7 +125,7 @@ CREATE TABLE IF NOT EXISTS `mvplog` (
CREATE TABLE IF NOT EXISTS `npclog` (
`npc_id` MEDIUMINT(9) UNSIGNED NOT NULL AUTO_INCREMENT,
- `npc_date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `npc_date` DATETIME NULL,
`account_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`char_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`char_name` VARCHAR(25) NOT NULL DEFAULT '',
@@ -142,7 +142,7 @@ CREATE TABLE IF NOT EXISTS `npclog` (
CREATE TABLE IF NOT EXISTS `picklog` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
- `time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `time` DATETIME NULL,
`char_id` INT(11) NOT NULL DEFAULT '0',
`type` ENUM('M','P','L','T','V','S','N','C','A','R','G','E','B','O','I','X','D','U','K','Y','Z','W','Q','J','H','@','0','1','2') NOT NULL DEFAULT 'P',
`nameid` INT(11) NOT NULL DEFAULT '0',
@@ -164,7 +164,7 @@ CREATE TABLE IF NOT EXISTS `picklog` (
CREATE TABLE IF NOT EXISTS `zenylog` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
- `time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `time` DATETIME NULL,
`char_id` INT(11) NOT NULL DEFAULT '0',
`src_id` INT(11) NOT NULL DEFAULT '0',
`type` ENUM('T','V','P','M','S','N','D','C','A','E','I','B') NOT NULL DEFAULT 'S',
diff --git a/sql-files/main.sql b/sql-files/main.sql
index e2717cdc5..fe25fb100 100644
--- a/sql-files/main.sql
+++ b/sql-files/main.sql
@@ -236,7 +236,7 @@ CREATE TABLE IF NOT EXISTS `char_reg_str_db` (
--
CREATE TABLE IF NOT EXISTS `charlog` (
- `time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `time` DATETIME NULL,
`char_msg` VARCHAR(255) NOT NULL DEFAULT 'char select',
`account_id` INT(11) NOT NULL DEFAULT '0',
`char_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
@@ -511,7 +511,7 @@ CREATE TABLE IF NOT EXISTS `homunculus` (
--
CREATE TABLE IF NOT EXISTS `interlog` (
- `time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `time` DATETIME NULL,
`log` VARCHAR(255) NOT NULL DEFAULT ''
) ENGINE=MyISAM;
@@ -546,8 +546,8 @@ CREATE TABLE IF NOT EXISTS `inventory` (
CREATE TABLE IF NOT EXISTS `ipbanlist` (
`list` VARCHAR(255) NOT NULL DEFAULT '',
- `btime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
- `rtime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `btime` DATETIME NULL,
+ `rtime` DATETIME NULL,
`reason` VARCHAR(255) NOT NULL DEFAULT '',
KEY (`list`)
) ENGINE=MyISAM;
@@ -567,9 +567,9 @@ CREATE TABLE IF NOT EXISTS `login` (
`unban_time` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`expiration_time` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`logincount` MEDIUMINT(9) UNSIGNED NOT NULL DEFAULT '0',
- `lastlogin` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `lastlogin` DATETIME NULL,
`last_ip` VARCHAR(100) NOT NULL DEFAULT '',
- `birthdate` DATE NOT NULL DEFAULT '0000-00-00',
+ `birthdate` DATE NULL,
`character_slots` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
`pincode` VARCHAR(4) NOT NULL DEFAULT '',
`pincode_change` INT(11) UNSIGNED NOT NULL DEFAULT '0',
@@ -825,6 +825,8 @@ INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1440688342); -- 2015-08-2
INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1450241859); -- 2015-12-16--12-57.sql
INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1450367880); -- 2015-12-17--15-58.sql
INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1457638175); -- 2016-03-10--22-18.sql
+INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1467934919); -- 2016-07-08--02-42.sql
+INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1467935469); -- 2016-07-08--02-51.sql
--
-- Table structure for table `storage`
diff --git a/sql-files/upgrades/2016-07-08--02-42.sql b/sql-files/upgrades/2016-07-08--02-42.sql
new file mode 100644
index 000000000..94ca7e6db
--- /dev/null
+++ b/sql-files/upgrades/2016-07-08--02-42.sql
@@ -0,0 +1,35 @@
+#1467934919
+
+-- This file is part of Hercules.
+-- http://herc.ws - http://github.com/HerculesWS/Hercules
+--
+-- Copyright (C) 2015-2016 Hercules Dev Team
+--
+-- Hercules is free software: you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation, either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ALTER TABLE `charlog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `interlog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `ipbanlist` MODIFY `btime` DATETIME NULL;
+ALTER TABLE `ipbanlist` MODIFY `rtime` DATETIME NULL;
+ALTER TABLE `login` MODIFY `lastlogin` DATETIME NULL;
+ALTER TABLE `login` MODIFY `birthdate` DATE NULL;
+
+UPDATE `charlog` SET `time` = NULL WHERE `time` = '0000-00-00 00:00:00';
+UPDATE `interlog` SET `time` = NULL WHERE `time` = '0000-00-00 00:00:00';
+UPDATE `ipbanlist` SET `btime` = NULL WHERE `btime` = '0000-00-00 00:00:00';
+UPDATE `ipbanlist` SET `rtime` = NULL WHERE `rtime` = '0000-00-00 00:00:00';
+UPDATE `login` SET `lastlogin` = NULL WHERE `lastlogin` = '0000-00-00 00:00:00';
+UPDATE `login` SET `birthdate` = NULL WHERE `birthdate` = '0000-00-00';
+
+INSERT INTO `sql_updates` (`timestamp`) VALUES (1467934919)
diff --git a/sql-files/upgrades/2016-07-08--02-51.sql b/sql-files/upgrades/2016-07-08--02-51.sql
new file mode 100644
index 000000000..8ecf1a25f
--- /dev/null
+++ b/sql-files/upgrades/2016-07-08--02-51.sql
@@ -0,0 +1,30 @@
+#1467935469
+
+-- This file is part of Hercules.
+-- http://herc.ws - http://github.com/HerculesWS/Hercules
+--
+-- Copyright (C) 2015-2016 Hercules Dev Team
+--
+-- Hercules is free software: you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation, either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ALTER TABLE `atcommandlog` MODIFY `atcommand_date` DATETIME NULL;
+ALTER TABLE `branchlog` MODIFY `branch_date` DATETIME NULL;
+ALTER TABLE `chatlog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `loginlog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `mvplog` MODIFY `mvp_date` DATETIME NULL;
+ALTER TABLE `npclog` MODIFY `npc_date` DATETIME NULL;
+ALTER TABLE `picklog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `zenylog` MODIFY `time` DATETIME NULL;
+
+INSERT INTO `sql_updates` (`timestamp`) VALUES (1467935469)
diff --git a/sql-files/upgrades/eAthena-logs-upgrade.sql b/sql-files/upgrades/eAthena-logs-upgrade.sql
index 09ed4d8d0..014f119e3 100644
--- a/sql-files/upgrades/eAthena-logs-upgrade.sql
+++ b/sql-files/upgrades/eAthena-logs-upgrade.sql
@@ -42,3 +42,12 @@ ALTER TABLE `zenylog` MODIFY `type` ENUM('M','T','V','S','N','A','E','B','I','D'
-- Add 'P' and 'C' types in `zenylog`
ALTER TABLE `zenylog` MODIFY `type` ENUM('T','V','P','M','S','N','D','C','A','E','I','B') NOT NULL DEFAULT 'S';
+
+ALTER TABLE `atcommandlog` MODIFY `atcommand_date` DATETIME NULL;
+ALTER TABLE `branchlog` MODIFY `branch_date` DATETIME NULL;
+ALTER TABLE `chatlog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `loginlog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `mvplog` MODIFY `mvp_date` DATETIME NULL;
+ALTER TABLE `npclog` MODIFY `npc_date` DATETIME NULL;
+ALTER TABLE `picklog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `zenylog` MODIFY `time` DATETIME NULL;
diff --git a/sql-files/upgrades/eAthena-main-upgrade.sql b/sql-files/upgrades/eAthena-main-upgrade.sql
index 64b22bfe9..647c9e004 100644
--- a/sql-files/upgrades/eAthena-main-upgrade.sql
+++ b/sql-files/upgrades/eAthena-main-upgrade.sql
@@ -111,3 +111,17 @@ ALTER TABLE `inventory` CHANGE `nsiuid` `unique_id` BIGINT( 20 ) NOT NULL DEFAUL
ALTER TABLE `mail` CHANGE `nsiuid` `unique_id` BIGINT( 20 ) NOT NULL DEFAULT '0';
ALTER TABLE `storage` CHANGE `nsiuid` `unique_id` BIGINT( 20 ) NOT NULL DEFAULT '0';
+
+ALTER TABLE `charlog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `interlog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `ipbanlist` MODIFY `btime` DATETIME NULL;
+ALTER TABLE `ipbanlist` MODIFY `rtime` DATETIME NULL;
+ALTER TABLE `login` MODIFY `lastlogin` DATETIME NULL;
+ALTER TABLE `login` MODIFY `birthdate` DATE NULL;
+
+UPDATE `charlog` SET `time` = NULL WHERE `time` = '0000-00-00 00:00:00';
+UPDATE `interlog` SET `time` = NULL WHERE `time` = '0000-00-00 00:00:00';
+UPDATE `ipbanlist` SET `btime` = NULL WHERE `btime` = '0000-00-00 00:00:00';
+UPDATE `ipbanlist` SET `rtime` = NULL WHERE `rtime` = '0000-00-00 00:00:00';
+UPDATE `login` SET `lastlogin` = NULL WHERE `lastlogin` = '0000-00-00 00:00:00';
+UPDATE `login` SET `birthdate` = NULL WHERE `birthdate` = '0000-00-00';
diff --git a/sql-files/upgrades/index.txt b/sql-files/upgrades/index.txt
index 6e81bd199..b0347ab72 100644
--- a/sql-files/upgrades/index.txt
+++ b/sql-files/upgrades/index.txt
@@ -30,3 +30,5 @@
2015-08-27--20-42.sql
2015-12-17--15-58.sql
2016-03-10--22-18.sql
+2016-07-08--02-42.sql
+2016-07-08--02-51.sql
diff --git a/sql-files/upgrades/rAthena-logs-upgrade.sql b/sql-files/upgrades/rAthena-logs-upgrade.sql
index 5e9dbf60c..09a571818 100644
--- a/sql-files/upgrades/rAthena-logs-upgrade.sql
+++ b/sql-files/upgrades/rAthena-logs-upgrade.sql
@@ -40,3 +40,11 @@ ALTER TABLE `picklog` MODIFY `card0` INT(11) NOT NULL DEFAULT '0';
ALTER TABLE `picklog` MODIFY `card1` INT(11) NOT NULL DEFAULT '0';
ALTER TABLE `picklog` MODIFY `card2` INT(11) NOT NULL DEFAULT '0';
ALTER TABLE `picklog` MODIFY `card3` INT(11) NOT NULL DEFAULT '0';
+ALTER TABLE `atcommandlog` MODIFY `atcommand_date` DATETIME NULL;
+ALTER TABLE `branchlog` MODIFY `branch_date` DATETIME NULL;
+ALTER TABLE `chatlog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `loginlog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `mvplog` MODIFY `mvp_date` DATETIME NULL;
+ALTER TABLE `npclog` MODIFY `npc_date` DATETIME NULL;
+ALTER TABLE `picklog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `zenylog` MODIFY `time` DATETIME NULL;
diff --git a/sql-files/upgrades/rAthena-main-upgrade.sql b/sql-files/upgrades/rAthena-main-upgrade.sql
index e214e8d34..5dd6111a5 100644
--- a/sql-files/upgrades/rAthena-main-upgrade.sql
+++ b/sql-files/upgrades/rAthena-main-upgrade.sql
@@ -337,3 +337,16 @@ INSERT INTO `global_acc_reg_str_db` (`account_id`, `key`, `index`, `value`) SELE
-- Dropping now useless table
DROP TABLE `global_reg_value`;
+ALTER TABLE `charlog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `interlog` MODIFY `time` DATETIME NULL;
+ALTER TABLE `ipbanlist` MODIFY `btime` DATETIME NULL;
+ALTER TABLE `ipbanlist` MODIFY `rtime` DATETIME NULL;
+ALTER TABLE `login` MODIFY `lastlogin` DATETIME NULL;
+ALTER TABLE `login` MODIFY `birthdate` DATE NULL;
+
+UPDATE `charlog` SET `time` = NULL WHERE `time` = '0000-00-00 00:00:00';
+UPDATE `interlog` SET `time` = NULL WHERE `time` = '0000-00-00 00:00:00';
+UPDATE `ipbanlist` SET `btime` = NULL WHERE `btime` = '0000-00-00 00:00:00';
+UPDATE `ipbanlist` SET `rtime` = NULL WHERE `rtime` = '0000-00-00 00:00:00';
+UPDATE `login` SET `lastlogin` = NULL WHERE `lastlogin` = '0000-00-00 00:00:00';
+UPDATE `login` SET `birthdate` = NULL WHERE `birthdate` = '0000-00-00';
diff --git a/src/login/account_sql.c b/src/login/account_sql.c
index 195a10233..1e19b5a37 100644
--- a/src/login/account_sql.c
+++ b/src/login/account_sql.c
@@ -606,9 +606,9 @@ static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int acc
SQL->GetData(sql_handle, 7, &data, NULL); acc->unban_time = atol(data);
SQL->GetData(sql_handle, 8, &data, NULL); acc->expiration_time = atol(data);
SQL->GetData(sql_handle, 9, &data, NULL); acc->logincount = (unsigned int)strtoul(data, NULL, 10);
- SQL->GetData(sql_handle, 10, &data, NULL); safestrncpy(acc->lastlogin, data, sizeof(acc->lastlogin));
+ SQL->GetData(sql_handle, 10, &data, NULL); safestrncpy(acc->lastlogin, data != NULL ? data : "", sizeof(acc->lastlogin));
SQL->GetData(sql_handle, 11, &data, NULL); safestrncpy(acc->last_ip, data, sizeof(acc->last_ip));
- SQL->GetData(sql_handle, 12, &data, NULL); safestrncpy(acc->birthdate, data, sizeof(acc->birthdate));
+ SQL->GetData(sql_handle, 12, &data, NULL); safestrncpy(acc->birthdate, data != NULL ? data : "", sizeof(acc->birthdate));
SQL->GetData(sql_handle, 13, &data, NULL); acc->char_slots = (uint8)atoi(data);
SQL->GetData(sql_handle, 14, &data, NULL); safestrncpy(acc->pincode, data, sizeof(acc->pincode));
SQL->GetData(sql_handle, 15, &data, NULL); acc->pincode_change = (unsigned int)atol(data);