From 651d6857d7784f4f2a7412e0eae1681fc7ccd147 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Fri, 15 Feb 2013 18:12:47 -0200 Subject: MySQL Update Checker: Updated Added a primary key to the `sql_updates` table (special thanks to Trojal) Modified the parser to ignore new/empty lines and added support for "//" comments in the index file. Signed-off-by: shennetsind --- sql-files/main.sql | 3 ++- sql-files/upgrades/2013-02-15--18-06.sql | 3 +++ sql-files/upgrades/index.txt | 3 ++- src/common/sql.c | 3 +++ 4 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 sql-files/upgrades/2013-02-15--18-06.sql diff --git a/sql-files/main.sql b/sql-files/main.sql index fbdf40dde..42f57064e 100644 --- a/sql-files/main.sql +++ b/sql-files/main.sql @@ -639,7 +639,8 @@ CREATE TABLE IF NOT EXISTS `skill_homunculus` ( CREATE TABLE IF NOT EXISTS `sql_updates` ( `timestamp` int(11) unsigned NOT NULL, - `ignored` enum('Yes','No') NOT NULL DEFAULT 'No' + `ignored` enum('Yes','No') NOT NULL DEFAULT 'No', + PRIMARY KEY (`timestamp`) ) ENGINE=MyISAM; -- Existent updates to enter diff --git a/sql-files/upgrades/2013-02-15--18-06.sql b/sql-files/upgrades/2013-02-15--18-06.sql new file mode 100644 index 000000000..066693c70 --- /dev/null +++ b/sql-files/upgrades/2013-02-15--18-06.sql @@ -0,0 +1,3 @@ +#1360951560 +ALTER TABLE `sql_updates` ADD PRIMARY KEY(`timestamp`); +INSERT INTO `sql_updates` (`timestamp`) VALUES (1360951560); \ No newline at end of file diff --git a/sql-files/upgrades/index.txt b/sql-files/upgrades/index.txt index e0c49cbce..3d4df8c23 100644 --- a/sql-files/upgrades/index.txt +++ b/sql-files/upgrades/index.txt @@ -1 +1,2 @@ -2013-02-14--16-15.sql \ No newline at end of file +2013-02-14--16-15.sql +2013-02-15--18-06.sql \ No newline at end of file diff --git a/src/common/sql.c b/src/common/sql.c index fdb6e0114..c0ab19e4e 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -1031,6 +1031,9 @@ void Sql_HerculesUpdateCheck(Sql* self) { char timestamp[11];// "1360186680" (10) + 1 FILE* ufp;/* upgrade fp */ + if( line[0] == '\n' || ( line[0] == '/' && line[1] == '/' ) )/* skip \n and "//" comments */ + continue; + sprintf(path,"sql-files/upgrades/%s",line); if( !( ufp = fopen(path, "r") ) ) { -- cgit v1.2.3-60-g2f50