diff options
author | George Hazan <ghazan@miranda.im> | 2021-04-03 16:46:09 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2021-04-03 16:46:09 +0300 |
commit | dd212611826b7c44e8a3c6cd2209b46d7cd03177 (patch) | |
tree | cb7c81b58576b18af8eeb7f0537aab89e6348524 /plugins/Dbx_sqlite/src/dbintf.cpp | |
parent | 9c11d6918afda6c9b326a794d25f65496ced081a (diff) |
fix of crazy problems in SQLITE when two instances of database are running at a time
Diffstat (limited to 'plugins/Dbx_sqlite/src/dbintf.cpp')
-rwxr-xr-x | plugins/Dbx_sqlite/src/dbintf.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/plugins/Dbx_sqlite/src/dbintf.cpp b/plugins/Dbx_sqlite/src/dbintf.cpp index 6fd1c9b6a1..1ae2834f1e 100755 --- a/plugins/Dbx_sqlite/src/dbintf.cpp +++ b/plugins/Dbx_sqlite/src/dbintf.cpp @@ -12,16 +12,15 @@ CDbxSQLite::CDbxSQLite(const wchar_t *pwszFileName, bool bReadOnly, bool bShared CDbxSQLite::~CDbxSQLite() { - int rc = sqlite3_exec(m_db, "commit;", nullptr, nullptr, nullptr); - logError(rc, __FILE__, __LINE__); + if (m_bTranStarted) { + int rc = sqlite3_exec(m_db, "commit;", nullptr, nullptr, nullptr); + logError(rc, __FILE__, __LINE__); + } UninitEvents(); - UninitContacts(); - UninitSettings(); - UninintEncryption(); if (m_db) { - rc = sqlite3_close(m_db); + int rc = sqlite3_close(m_db); logError(rc, __FILE__, __LINE__); m_db = nullptr; @@ -43,7 +42,7 @@ int CDbxSQLite::Create() rc = sqlite3_exec(m_db, "CREATE TABLE contacts (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT);", nullptr, nullptr, nullptr); logError(rc, __FILE__, __LINE__); - rc = sqlite3_exec(m_db, "CREATE TABLE crypto (id INTEGER NOT NULL PRIMARY KEY, data ANY NOT NULL);", nullptr, nullptr, nullptr); + rc = sqlite3_exec(m_db, "CREATE TABLE crypto (id INTEGER NOT NULL PRIMARY KEY, data NOT NULL);", nullptr, nullptr, nullptr); logError(rc, __FILE__, __LINE__); rc = sqlite3_exec(m_db, "CREATE TABLE events (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, contact_id INTEGER NOT NULL, module TEXT NOT NULL," @@ -60,7 +59,7 @@ int CDbxSQLite::Create() rc = sqlite3_exec(m_db, "CREATE TABLE events_srt (id INTEGER NOT NULL, contact_id INTEGER NOT NULL, timestamp INTEGER, PRIMARY KEY(contact_id, timestamp, id));", nullptr, nullptr, nullptr); logError(rc, __FILE__, __LINE__); - rc = sqlite3_exec(m_db, "CREATE TABLE settings (contact_id INTEGER NOT NULL, module TEXT NOT NULL, setting TEXT NOT NULL, type INTEGER NOT NULL, value ANY," + rc = sqlite3_exec(m_db, "CREATE TABLE settings (contact_id INTEGER NOT NULL, module TEXT NOT NULL, setting TEXT NOT NULL, type INTEGER NOT NULL, value NOT NULL," "PRIMARY KEY(contact_id, module, setting)) WITHOUT ROWID;", nullptr, nullptr, nullptr); logError(rc, __FILE__, __LINE__); @@ -146,6 +145,7 @@ int CDbxSQLite::Load() if (InitCrypt()) return EGROKPRF_CANTREAD; + m_bTranStarted = true; rc = sqlite3_exec(m_db, "begin transaction;", nullptr, nullptr, nullptr); logError(rc, __FILE__, __LINE__); return EGROKPRF_NOERROR; |