mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[9906] More user friendly output at DB version check fail.
Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
c018563669
commit
2ee1bb5219
3 changed files with 71 additions and 16 deletions
|
|
@ -5,17 +5,23 @@ Copyright (c) 2005-2010 MaNGOS <http://getmangos.com/>
|
||||||
See the COPYING file for copying conditions.
|
See the COPYING file for copying conditions.
|
||||||
|
|
||||||
== Database Updates ==
|
== Database Updates ==
|
||||||
|
|
||||||
This folder contains SQL files which will apply required updates to your MySQL
|
This folder contains SQL files which will apply required updates to your MySQL
|
||||||
database, whenever the MaNGOS database structure has been changed or extended.
|
database, whenever the MaNGOS database structure has been changed or extended.
|
||||||
|
|
||||||
To see if you need an update, the file names have been given a fixed structure
|
To see if you need an update, the file names have been given a fixed structure
|
||||||
that should enable you to see if you need an update or not.
|
that should enable you to see if you need an update or not.
|
||||||
|
|
||||||
=== File name descriptin ===
|
=== File Name Description ===
|
||||||
File names are divided into two parts. First part is the revision+counter
|
|
||||||
that show commit revision that will be compatible with database after apply update.
|
File names are divided into two parts.
|
||||||
Counter set order in sql updates apply for same revision.
|
|
||||||
The second part of the name of the database and the table that needs and update or has been added.
|
First part is the revision and counter that shows the commit revision that
|
||||||
|
will be compatible with the database after apply that particular update.
|
||||||
|
Counter sets the order to apply sql updates for the same revision.
|
||||||
|
|
||||||
|
The second part of the name is the database and the table that needs an update or has been added.
|
||||||
|
|
||||||
See an example below:
|
See an example below:
|
||||||
|
|
||||||
6936_01_mangos_spell_chain.sql
|
6936_01_mangos_spell_chain.sql
|
||||||
|
|
@ -27,18 +33,19 @@ See an example below:
|
||||||
| | Name of affected DB (default recommended name)
|
| | Name of affected DB (default recommended name)
|
||||||
| | Can be: characters, mangos, realmd
|
| | Can be: characters, mangos, realmd
|
||||||
| |
|
| |
|
||||||
| Counter show number of sql update in updates list for provided revision
|
| Counter show number of sql updates in updates list for provided revision
|
||||||
| and set proper order for sql updates for same revision
|
| and set proper order for sql updates for same revision
|
||||||
|
|
|
|
||||||
MaNGOS commit revison related to sql update.
|
MaNGOS commit revision related to sql update.
|
||||||
It included in commit description in form [6936] as you can see at http://github.com/mangos/mangos/commits/master
|
It included in commit description in form [6936] as you can see at http://github.com/mangos/mangos/commits/master
|
||||||
|
|
||||||
After appling this update DB compatiable with database that include this sql update.
|
After applying an update the DB is compatible with the mangos revision of this sql update.
|
||||||
SQL update include special protection against multiply and wrong order SQL updates apply.
|
SQL updates include special protection against multiple and wrong order of update application.
|
||||||
So attempt apply sql update to more old DB without previous SQL update in list for targeted database
|
|
||||||
or to DB with already applied this or later SQL update will generate error and not applied.
|
|
||||||
|
|
||||||
=== For commiters ====
|
Attempts to apply sql updates to an older DB without previous SQL updates in list for the database
|
||||||
|
or to DB with already applied this or later SQL update will generate an error and not be applied.
|
||||||
|
|
||||||
|
=== For Commiters ====
|
||||||
|
|
||||||
MaNGOS sources include special tool ( contrib/git_id ) for generation revision info
|
MaNGOS sources include special tool ( contrib/git_id ) for generation revision info
|
||||||
in commit notes and in src/shared/revision_nr.h file. It have option '-s' that let set
|
in commit notes and in src/shared/revision_nr.h file. It have option '-s' that let set
|
||||||
|
|
|
||||||
|
|
@ -204,6 +204,18 @@ bool Database::CheckRequiredField( char const* table_name, char const* required_
|
||||||
// check fail, prepare readabale error message
|
// check fail, prepare readabale error message
|
||||||
|
|
||||||
// search current required_* field in DB
|
// search current required_* field in DB
|
||||||
|
const char* db_name;
|
||||||
|
if(!strcmp(table_name, "db_version"))
|
||||||
|
db_name = "WORLD";
|
||||||
|
else if(!strcmp(table_name, "character_db_version"))
|
||||||
|
db_name = "CHARACTER";
|
||||||
|
else if(!strcmp(table_name, "realmd_db_version"))
|
||||||
|
db_name = "REALMD";
|
||||||
|
else
|
||||||
|
db_name = "UNKNOWN";
|
||||||
|
|
||||||
|
char const* req_sql_update_name = required_name+strlen("required_");
|
||||||
|
|
||||||
QueryNamedResult* result2 = PQueryNamed("SELECT * FROM %s LIMIT 1",table_name);
|
QueryNamedResult* result2 = PQueryNamed("SELECT * FROM %s LIMIT 1",table_name);
|
||||||
if(result2)
|
if(result2)
|
||||||
{
|
{
|
||||||
|
|
@ -220,13 +232,49 @@ bool Database::CheckRequiredField( char const* table_name, char const* required_
|
||||||
|
|
||||||
delete result2;
|
delete result2;
|
||||||
|
|
||||||
|
std::string cur_sql_update_name = reqName.substr(strlen("required_"),reqName.npos);
|
||||||
|
|
||||||
if(!reqName.empty())
|
if(!reqName.empty())
|
||||||
sLog.outErrorDb("Table `%s` have field `%s` but expected `%s`! Not all sql updates applied?",table_name,reqName.c_str(),required_name);
|
{
|
||||||
|
sLog.outErrorDb("The table `%s` in your [%s] database indicates that this database is out of date!",table_name,db_name);
|
||||||
|
sLog.outErrorDb("");
|
||||||
|
sLog.outErrorDb(" [A] You have: --> `%s.sql`",cur_sql_update_name.c_str());
|
||||||
|
sLog.outErrorDb("");
|
||||||
|
sLog.outErrorDb(" [B] You need: --> `%s.sql`",req_sql_update_name);
|
||||||
|
sLog.outErrorDb("");
|
||||||
|
sLog.outErrorDb("You must apply all updates after [A] to [B] to use mangos with this database.");
|
||||||
|
sLog.outErrorDb("These updates are included in the sql/updates folder.");
|
||||||
|
sLog.outErrorDb("Please read the included [README] in sql/updates for instructions on updating.");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
sLog.outErrorDb("Table `%s` not have required_* field but expected `%s`! Not all sql updates applied?",table_name,required_name);
|
{
|
||||||
|
sLog.outErrorDb("The table `%s` in your [%s] database is missing its version info.",table_name,db_name);
|
||||||
|
sLog.outErrorDb("MaNGOS cannot find the version info needed to check that the db is up to date.",table_name,db_name);
|
||||||
|
sLog.outErrorDb("");
|
||||||
|
sLog.outErrorDb("This revision of MaNGOS requires a database updated to:");
|
||||||
|
sLog.outErrorDb("`%s.sql`",req_sql_update_name);
|
||||||
|
sLog.outErrorDb("");
|
||||||
|
|
||||||
|
if(!strcmp(db_name, "WORLD"))
|
||||||
|
sLog.outErrorDb("Post this error to your database provider forum or find a solution there.");
|
||||||
|
else
|
||||||
|
sLog.outErrorDb("Reinstall your [%s] database with the included sql file in the sql folder.",db_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sLog.outErrorDb("Table `%s` fields list query fail but expected have `%s`! No records in `%s`?",table_name,required_name,table_name);
|
{
|
||||||
|
sLog.outErrorDb("The table `%s` in your [%s] database is missing or corrupt.",table_name,db_name);
|
||||||
|
sLog.outErrorDb("MaNGOS cannot find the version info needed to check that the db is up to date.",table_name,db_name);
|
||||||
|
sLog.outErrorDb("");
|
||||||
|
sLog.outErrorDb("This revision of mangos requires a database updated to:");
|
||||||
|
sLog.outErrorDb("`%s.sql`",req_sql_update_name);
|
||||||
|
sLog.outErrorDb("");
|
||||||
|
|
||||||
|
if(!strcmp(db_name, "WORLD"))
|
||||||
|
sLog.outErrorDb("Post this error to your database provider forum or find a solution there.");
|
||||||
|
else
|
||||||
|
sLog.outErrorDb("Reinstall your [%s] database with the included sql file in the sql folder.",db_name);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "9905"
|
#define REVISION_NR "9906"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue