From 89a3160416316af2ff0b8de9b247583a4ac103f8 Mon Sep 17 00:00:00 2001 From: aunsane Date: Sun, 23 Sep 2018 01:30:29 +0300 Subject: dbx_sqlite: fix events queries --- plugins/Dbx_sqlite/src/dbevents.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/Dbx_sqlite/src/dbevents.cpp b/plugins/Dbx_sqlite/src/dbevents.cpp index bff8362c41..d131681409 100644 --- a/plugins/Dbx_sqlite/src/dbevents.cpp +++ b/plugins/Dbx_sqlite/src/dbevents.cpp @@ -20,8 +20,8 @@ enum { }; static char *evt_stmts[SQL_EVT_STMT_NUM] = { - "select count(1) from events limit 1;", - "insert into events values (null, ?, ?, ?, ?, ?, ?, ?);", + "select count(1) from events where contactid = ? limit 1;", + "insert into events(contactid, module, timestamp, type, flags, size, blob) values (?, ?, ?, ?, ?, ?, ?);", "delete from events where id = ?;", "select size from events where id = ? limit 1;", "select module, timestamp, flags, type, size, blob from events where id = ? limit 1;", @@ -132,6 +132,9 @@ BOOL CDbxSQLite::DeleteEvent(MCONTACT hContact, MEVENT hDbEvent) LONG CDbxSQLite::GetBlobSize(MEVENT hDbEvent) { + if (hDbEvent == 0) + return -1; + mir_cslock lock(m_csDbAccess); sqlite3_stmt *stmt = evt_stmts_prep[SQL_EVT_STMT_BLOBSIZE]; sqlite3_bind_int(stmt, 1, hDbEvent); -- cgit v1.2.3