From 6f5be7c2b68feec33679ce236c562ba0e71f8e40 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 15 Jan 2023 21:17:02 +0300 Subject: =?UTF-8?q?fixes=20#3302=20(=D0=98=D1=81=D1=82=D0=BE=D1=80=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=B2=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD=D0=BE=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=BF=D0=B0=D0=B4=D0=B0=D0=B5=D1=82=20=D0=BF?= =?UTF-8?q?=D0=BE=D1=81=D0=BB=D0=B5=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D1=81=D1=83=D0=B1=D0=BA=D0=BE=D0=BD=D1=82=D0=B0?= =?UTF-8?q?=D0=BA=D1=82=D0=B0=20=D0=B8=D0=B7=20=D0=BC=D0=B5=D1=82=D0=B0?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=82=D0=B0=D0=BA=D1=82=D0=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/Dbx_sqlite/src/dbevents.cpp | 48 ++++++++++++++++++------------------- plugins/Dbx_sqlite/src/version.h | 2 +- 2 files changed, 24 insertions(+), 26 deletions(-) (limited to 'plugins') diff --git a/plugins/Dbx_sqlite/src/dbevents.cpp b/plugins/Dbx_sqlite/src/dbevents.cpp index c4af7cf487..15836d29a5 100644 --- a/plugins/Dbx_sqlite/src/dbevents.cpp +++ b/plugins/Dbx_sqlite/src/dbevents.cpp @@ -565,39 +565,37 @@ MEVENT CDbxSQLite::FindPrevEvent(MCONTACT hContact, MEVENT hDbEvent) BOOL CDbxSQLite::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) { - //TODO: test this - mir_cslock lock(m_csDbAccess); - sqlite3_stmt *stmt = InitQuery("SELECT id, timestamp FROM events WHERE contact_id = ?;", qEvMetaMerge); - sqlite3_bind_int64(stmt, 1, ccSub->contactID); - int rc = sqlite3_step(stmt); - logError(rc, __FILE__, __LINE__); - while (rc == SQLITE_ROW) { - sqlite3_stmt *stmt2 = InitQuery(add_event_sort_query, qEvAddSrt); - sqlite3_bind_int64(stmt2, 1, sqlite3_column_int64(stmt, 0)); - sqlite3_bind_int64(stmt2, 2, ccMeta->contactID); - sqlite3_bind_int64(stmt2, 3, sqlite3_column_int64(stmt, 1)); - int rc2 = sqlite3_step(stmt2); - logError(rc2, __FILE__, __LINE__); - sqlite3_reset(stmt2); - rc = sqlite3_step(stmt); + { mir_cslock lock(m_csDbAccess); + sqlite3_stmt *stmt = InitQuery( + "INSERT INTO events_srt(id, contact_id, timestamp) " + "SELECT id, ?, timestamp from events_srt where contact_id = ?;", qEvMetaMerge); + sqlite3_bind_int64(stmt, 1, ccMeta->contactID); + sqlite3_bind_int64(stmt, 2, ccSub->contactID); + int rc = sqlite3_step(stmt); logError(rc, __FILE__, __LINE__); + sqlite3_reset(stmt); + if (rc != SQLITE_DONE) + return FALSE; } - sqlite3_reset(stmt); DBFlush(); return TRUE; } -BOOL CDbxSQLite::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *) +BOOL CDbxSQLite::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) { - mir_cslock lock(m_csDbAccess); - sqlite3_stmt *stmt = InitQuery("DELETE FROM events_srt WHERE contact_id = ?;", qEvMetaSplit); - sqlite3_bind_int64(stmt, 1, ccMeta->contactID); - int rc = sqlite3_step(stmt); - logError(rc, __FILE__, __LINE__); - sqlite3_reset(stmt); - if (rc != SQLITE_DONE) - return 1; + { mir_cslock lock(m_csDbAccess); + sqlite3_stmt *stmt = InitQuery( + "DELETE FROM events_srt WHERE contact_id = ? " + "AND id IN (SELECT id from events_srt WHERE contact_id = ?);", qEvMetaSplit); + sqlite3_bind_int64(stmt, 1, ccMeta->contactID); + sqlite3_bind_int64(stmt, 2, ccSub->contactID); + int rc = sqlite3_step(stmt); + logError(rc, __FILE__, __LINE__); + sqlite3_reset(stmt); + if (rc != SQLITE_DONE) + return FALSE; + } DBFlush(); return TRUE; diff --git a/plugins/Dbx_sqlite/src/version.h b/plugins/Dbx_sqlite/src/version.h index dd6c90b600..83e808b7c4 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 2 +#define __BUILD_NUM 3 #include -- cgit v1.2.3