From fb7edbe76a928d134fd334e5bad68e32096e0424 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 2 Oct 2023 14:15:18 +0300 Subject: =?UTF-8?q?fixes=20#3700=20)dbx=5Fsqlite:=20=D1=83=D0=B4=D0=B0?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B8=D1=81=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=B8=D0=B8=20=D0=BC=D0=B5=D1=82=D0=B0=D0=BA=D0=BE=D0=BD=D1=82?= =?UTF-8?q?=D0=B0=D0=BA=D1=82=D0=B0=20=D0=BE=D1=81=D1=82=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D1=82=20=D0=BF=D1=83=D1=81=D1=82=D1=8B=D0=B5=20?= =?UTF-8?q?=D1=81=D0=BE=D0=B1=D1=8B=D1=82=D0=B8=D1=8F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/Dbx_sqlite/src/dbevents.cpp | 9 ++++----- plugins/Dbx_sqlite/src/dbintf.cpp | 3 +++ plugins/Dbx_sqlite/src/dbintf.h | 2 +- plugins/Dbx_sqlite/src/dbsettings.cpp | 9 ++++++--- plugins/Dbx_sqlite/src/version.h | 4 ++-- 5 files changed, 16 insertions(+), 11 deletions(-) (limited to 'plugins/Dbx_sqlite/src') diff --git a/plugins/Dbx_sqlite/src/dbevents.cpp b/plugins/Dbx_sqlite/src/dbevents.cpp index 70766e48b1..ac2261c60d 100644 --- a/plugins/Dbx_sqlite/src/dbevents.cpp +++ b/plugins/Dbx_sqlite/src/dbevents.cpp @@ -198,11 +198,10 @@ int CDbxSQLite::DeleteEventSrt(MCONTACT hContact, int64_t ts) return rc; } -int CDbxSQLite::DeleteEventSrt2(MCONTACT hContact, MEVENT hDbEvent) +int CDbxSQLite::DeleteEventSrt2(MEVENT hDbEvent) { - auto *stmt = InitQuery("DELETE FROM events_srt WHERE contact_id = ? AND id = ?;", qEvDelSrt2); - sqlite3_bind_int64(stmt, 1, hContact); - sqlite3_bind_int64(stmt, 2, hDbEvent); + auto *stmt = InitQuery("DELETE FROM events_srt WHERE id = ?;", qEvDelSrt2); + sqlite3_bind_int64(stmt, 1, hDbEvent); int rc = sqlite3_step(stmt); logError(rc, __FILE__, __LINE__); sqlite3_reset(stmt); @@ -239,7 +238,7 @@ BOOL CDbxSQLite::DeleteEvent(MEVENT hDbEvent) if (rc != SQLITE_DONE) return 1; - rc = DeleteEventSrt2(hContact, hDbEvent); + rc = DeleteEventSrt2(hDbEvent); if (rc != SQLITE_DONE) return 1; diff --git a/plugins/Dbx_sqlite/src/dbintf.cpp b/plugins/Dbx_sqlite/src/dbintf.cpp index a7596ec9bb..70d35e9fbf 100644 --- a/plugins/Dbx_sqlite/src/dbintf.cpp +++ b/plugins/Dbx_sqlite/src/dbintf.cpp @@ -61,6 +61,9 @@ 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));", nullptr, nullptr, nullptr); logError(rc, __FILE__, __LINE__); + rc = sqlite3_exec(m_db, "CREATE INDEX i1_srt ON events_srt(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 NOT NULL," "PRIMARY KEY(contact_id, module, setting)) WITHOUT ROWID;", nullptr, nullptr, nullptr); logError(rc, __FILE__, __LINE__); diff --git a/plugins/Dbx_sqlite/src/dbintf.h b/plugins/Dbx_sqlite/src/dbintf.h index 7f6447ffd7..85183f35a7 100644 --- a/plugins/Dbx_sqlite/src/dbintf.h +++ b/plugins/Dbx_sqlite/src/dbintf.h @@ -85,7 +85,7 @@ class CDbxSQLite : public MDatabaseCommon, public MIDatabaseChecker, public MZer int AddEventSrt(MEVENT, MCONTACT, int64_t ts); int DeleteEventMain(MEVENT); int DeleteEventSrt(MCONTACT, int64_t ts); - int DeleteEventSrt2(MCONTACT, MEVENT); + int DeleteEventSrt2(MEVENT); // settings void InitSettings(); diff --git a/plugins/Dbx_sqlite/src/dbsettings.cpp b/plugins/Dbx_sqlite/src/dbsettings.cpp index 691b3921f1..dfc3bddf85 100644 --- a/plugins/Dbx_sqlite/src/dbsettings.cpp +++ b/plugins/Dbx_sqlite/src/dbsettings.cpp @@ -127,11 +127,14 @@ void CDbxSQLite::InitSettings() dbv.bVal = 3; } - if (dbv.bVal < 4) { - int rc = sqlite3_exec(m_db, "CREATE INDEX i1_srt ON events_srt(contact_id, id);", 0, 0, 0); + if (dbv.bVal < 5) { + int rc = sqlite3_exec(m_db, "DROP INDEX IF EXISTS i1_srt;", 0, 0, 0); logError(rc, __FILE__, __LINE__); - dbv.bVal = 4; + rc = sqlite3_exec(m_db, "CREATE INDEX i1_srt ON events_srt(id);", 0, 0, 0); + logError(rc, __FILE__, __LINE__); + + dbv.bVal = 5; WriteContactSetting(0, "Compatibility", "Sqlite", &dbv); } } diff --git a/plugins/Dbx_sqlite/src/version.h b/plugins/Dbx_sqlite/src/version.h index 32cba5986e..1ec1dd66b4 100644 --- a/plugins/Dbx_sqlite/src/version.h +++ b/plugins/Dbx_sqlite/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 96 -#define __RELEASE_NUM 2 -#define __BUILD_NUM 4 +#define __RELEASE_NUM 4 +#define __BUILD_NUM 1 #include -- cgit v1.2.3