summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2023-01-15 21:17:02 +0300
committerGeorge Hazan <ghazan@miranda.im>2023-01-15 21:17:24 +0300
commit6f5be7c2b68feec33679ce236c562ba0e71f8e40 (patch)
treeceff000887096b800c9e66cbbc6c561a157e8885 /plugins
parent500326ed697b2e90efa3772675f6a67fc3562548 (diff)
fixes #3302 (История временно пропадает после удаление субконтакта из метаконтакта)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Dbx_sqlite/src/dbevents.cpp48
-rw-r--r--plugins/Dbx_sqlite/src/version.h2
2 files changed, 24 insertions, 26 deletions
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 <stdver.h>