X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fdbsetup.cpp;h=1316bb28c1533e5d8dec09dd7a83763fb1c5c75d;hb=e662ea47fba8715474851ceebacba400984ee433;hp=1b037f7dac0b0cc372eef39e1da646cf2d09d036;hpb=221236a4d3aac4144529d418ce368db5c98facb0;p=fms.git diff --git a/src/dbsetup.cpp b/src/dbsetup.cpp index 1b037f7..1316bb2 100644 --- a/src/dbsetup.cpp +++ b/src/dbsetup.cpp @@ -430,6 +430,7 @@ void SetupDB() // MessageInserter will insert a record into this temp table which the MessageListInserter will query for and insert a MessageList when needed db->Execute("CREATE TEMPORARY TABLE IF NOT EXISTS tmpMessageListInsert(\ + MessageListInsertID INTEGER PRIMARY KEY,\ LocalIdentityID INTEGER,\ Date DATETIME\ );"); @@ -602,7 +603,24 @@ const bool VerifyDB() } else { - return false; + // try to reindex and vacuum database in case of index corruption + st=db->Prepare("REINDEX;"); + st.Step(); + st=db->Prepare("VACUUM;"); + st.Step(); + + // check integrity again + st=db->Prepare("PRAGMA integrity_check;"); + st.Step(); + st.ResultText(0,res); + if(res=="ok") + { + return true; + } + else + { + return false; + } } } else @@ -610,3 +628,20 @@ const bool VerifyDB() return false; } } + +const std::string TestDBIntegrity() +{ + std::string result=""; + + SQLite3DB::DB *db=SQLite3DB::DB::Instance(); + SQLite3DB::Statement st=db->Prepare("PRAGMA integrity_check;"); + st.Step(); + while(st.RowReturned()) + { + std::string text=""; + st.ResultText(0,text); + result+=text; + st.Step(); + } + return result; +}