{
.idx = RSPAMD_STAT_CACHE_UPDATE_LEARN,
.sql = "UPDATE learns SET flag=?1 WHERE digest=?2;",
- .args = "VI",
+ .args = "IV",
.stmt = NULL,
.result = SQLITE_DONE,
.ret = ""
rspamd_sqlite3_run_prstmt (pool, ctx->db, ctx->prstmt,
RSPAMD_STAT_CACHE_TRANSACTION_COMMIT);
+
if (rc == SQLITE_OK) {
/* We have some existing record in the table */
- if ((flag && is_spam) || (!flag && !is_spam)) {
+ if (!!flag == !!is_spam) {
/* Already learned */
+
ret = RSPAMD_LEARN_INGORE;
}
else {
/* Need to relearn */
- flag = is_spam ? 1 : 0;
+ flag = !!is_spam ? 1 : 0;
+
rspamd_sqlite3_run_prstmt (pool, ctx->db, ctx->prstmt,
RSPAMD_STAT_CACHE_TRANSACTION_START_IM);
- rspamd_sqlite3_run_prstmt (pool, ctx->db, ctx->prstmt,
- RSPAMD_STAT_CACHE_UPDATE_LEARN, (gint64)len, h, flag);
+ rc = rspamd_sqlite3_run_prstmt (pool, ctx->db, ctx->prstmt,
+ RSPAMD_STAT_CACHE_UPDATE_LEARN, flag, (gint64)len, h);
rspamd_sqlite3_run_prstmt (pool, ctx->db, ctx->prstmt,
RSPAMD_STAT_CACHE_TRANSACTION_COMMIT);
}
else {
/* Insert result new id */
- flag = is_spam ? 1 : 0;
+ flag = !!is_spam ? 1 : 0;
rspamd_sqlite3_run_prstmt (pool, ctx->db, ctx->prstmt,
RSPAMD_STAT_CACHE_TRANSACTION_START_IM);
rspamd_sqlite3_run_prstmt (pool, ctx->db, ctx->prstmt,