Skip to content

Commit

Permalink
Fix readonly database open
Browse files Browse the repository at this point in the history
  • Loading branch information
lintest committed Oct 19, 2013
1 parent e64f2ab commit 949974c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sources/MyRuLib/FbDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,8 @@ void FbMasterDatabase::SetVersion(int iValue)

void FbMasterDatabase::UpgradeDatabase(int new_version)
{
if (IsReadOnly()) return;

FbSQLite3Transaction trans(this, WXSQLITE_TRANSACTION_IMMEDIATE);
int version = GetVersion();
while ( version < new_version ) {
Expand Down Expand Up @@ -718,6 +720,7 @@ void FbMainDatabase::CreateTableFTS(const wxString & name, const wxString & tabl

void FbMainDatabase::CreateFullText(bool force, FbThread * thread)
{
if (IsReadOnly()) return;
if ( !force && TableExists(wxT("fts_book_content")) ) return;
FbSQLite3Transaction trans(this, WXSQLITE_TRANSACTION_IMMEDIATE);
CreateTableFTS(wxT("book"), wxT("books"), wxT("title),LOW(description"), wxT(",dscr"));
Expand Down
6 changes: 6 additions & 0 deletions sources/MyRuLib/wx/FbSQLite3.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ class FbSQLite3Database: private wxSQLite3Database
FBSQLITE3_END(false)
}

bool IsReadOnly() {
FBSQLITE3_BEGIN
return wxSQLite3Database::IsReadOnly();
FBSQLITE3_END(true)
}

void Close() {
FBSQLITE3_BEGIN
return wxSQLite3Database::Close();
Expand Down

0 comments on commit 949974c

Please sign in to comment.