diff options
-rw-r--r-- | src/libstat/backends/sqlite3_backend.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/libstat/backends/sqlite3_backend.c b/src/libstat/backends/sqlite3_backend.c index 90c184ae3..2d8ae1921 100644 --- a/src/libstat/backends/sqlite3_backend.c +++ b/src/libstat/backends/sqlite3_backend.c @@ -427,7 +427,7 @@ rspamd_sqlite3_learn_token (struct rspamd_task *task, struct token_node_s *tok, if (rspamd_sqlite3_run_prstmt (bk->sqlite, bk->prstmt, RSPAMD_STAT_BACKEND_SET_TOKEN, - idx, rt->user_id, rt->lang_id, iv) == SQLITE_OK) { + idx, rt->user_id, rt->lang_id, iv) != SQLITE_OK) { return FALSE; } @@ -482,6 +482,13 @@ rspamd_sqlite3_inc_learns (struct rspamd_task *task, gpointer runtime, rspamd_sqlite3_run_prstmt (bk->sqlite, bk->prstmt, RSPAMD_STAT_BACKEND_INC_LEARNS, SQLITE3_DEFAULT, SQLITE3_DEFAULT); + + if (bk->in_transaction) { + rspamd_sqlite3_run_prstmt (bk->sqlite, bk->prstmt, + RSPAMD_STAT_BACKEND_TRANSACTION_COMMIT); + bk->in_transaction = FALSE; + } + rspamd_sqlite3_run_prstmt (bk->sqlite, bk->prstmt, RSPAMD_STAT_BACKEND_GET_LEARNS, &res); @@ -501,6 +508,13 @@ rspamd_sqlite3_dec_learns (struct rspamd_task *task, gpointer runtime, rspamd_sqlite3_run_prstmt (bk->sqlite, bk->prstmt, RSPAMD_STAT_BACKEND_DEC_LEARNS, SQLITE3_DEFAULT, SQLITE3_DEFAULT); + + if (bk->in_transaction) { + rspamd_sqlite3_run_prstmt (bk->sqlite, bk->prstmt, + RSPAMD_STAT_BACKEND_TRANSACTION_COMMIT); + bk->in_transaction = FALSE; + } + rspamd_sqlite3_run_prstmt (bk->sqlite, bk->prstmt, RSPAMD_STAT_BACKEND_GET_LEARNS, &res); |