From aa5197082f1567e37b85911752b92a489d6515c3 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 13 Apr 2023 20:35:18 +0300 Subject: DbxSqlite: query optimization --- plugins/Dbx_sqlite/src/dbevents.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'plugins/Dbx_sqlite/src/dbevents.cpp') diff --git a/plugins/Dbx_sqlite/src/dbevents.cpp b/plugins/Dbx_sqlite/src/dbevents.cpp index 5a287b03ad..48e3b6eb99 100644 --- a/plugins/Dbx_sqlite/src/dbevents.cpp +++ b/plugins/Dbx_sqlite/src/dbevents.cpp @@ -300,9 +300,12 @@ int CDbxSQLite::SetEventJson(MEVENT hDbEvent, const char *szSetting, DBVARIANT * if (hDbEvent == 0) return 1; - { mir_cslock lock(m_csDbAccess); - sqlite3_stmt *stmt = InitQuery("UPDATE events SET data=json_set(data, '$.?', ?) WHERE id = ?;", qEvEdit); - sqlite3_bind_text(stmt, 1, szSetting, (int)mir_strlen(szSetting), nullptr); + CMStringA tmp(FORMAT, "$.%s", szSetting); + { + mir_cslock lock(m_csDbAccess); + sqlite3_stmt *stmt = InitQuery("UPDATE events SET data=json_set(data, ?, ?) WHERE id = ?;", qEvEdit); + + sqlite3_bind_text(stmt, 1, tmp, tmp.GetLength(), nullptr); switch (dbv->type) { case DBVT_BYTE: sqlite3_bind_int(stmt, 2, dbv->bVal); -- cgit v1.2.3