RSPAMD_STAT_BACKEND_GET_LEARNS,
RSPAMD_STAT_BACKEND_GET_LANGUAGE,
RSPAMD_STAT_BACKEND_GET_USER,
- RSPAMD_STAT_BACKEND_INSERT_LANGUAGE,
RSPAMD_STAT_BACKEND_INSERT_USER,
+ RSPAMD_STAT_BACKEND_INSERT_LANGUAGE,
RSPAMD_STAT_BACKEND_SAVE_TOKENIZER,
RSPAMD_STAT_BACKEND_LOAD_TOKENIZER,
RSPAMD_STAT_BACKEND_NTOKENS,
static struct rspamd_sqlite3_prstmt prepared_stmts[RSPAMD_STAT_BACKEND_MAX] =
{
- {
+ [RSPAMD_STAT_BACKEND_TRANSACTION_START_IM] = {
.idx = RSPAMD_STAT_BACKEND_TRANSACTION_START_IM,
.sql = "BEGIN IMMEDIATE TRANSACTION;",
.args = "",
.result = SQLITE_DONE,
.ret = ""
},
- {
+ [RSPAMD_STAT_BACKEND_TRANSACTION_START_DEF] = {
.idx = RSPAMD_STAT_BACKEND_TRANSACTION_START_DEF,
.sql = "BEGIN DEFERRED TRANSACTION;",
.args = "",
.result = SQLITE_DONE,
.ret = ""
},
- {
+ [RSPAMD_STAT_BACKEND_TRANSACTION_START_EXCL] = {
.idx = RSPAMD_STAT_BACKEND_TRANSACTION_START_EXCL,
.sql = "BEGIN EXCLUSIVE TRANSACTION;",
.args = "",
.result = SQLITE_DONE,
.ret = ""
},
- {
+ [RSPAMD_STAT_BACKEND_TRANSACTION_COMMIT] = {
.idx = RSPAMD_STAT_BACKEND_TRANSACTION_COMMIT,
.sql = "COMMIT;",
.args = "",
.result = SQLITE_DONE,
.ret = ""
},
- {
+ [RSPAMD_STAT_BACKEND_TRANSACTION_ROLLBACK] = {
.idx = RSPAMD_STAT_BACKEND_TRANSACTION_ROLLBACK,
.sql = "ROLLBACK;",
.args = "",
.result = SQLITE_DONE,
.ret = ""
},
- {
+ [RSPAMD_STAT_BACKEND_GET_TOKEN] = {
.idx = RSPAMD_STAT_BACKEND_GET_TOKEN,
.sql = "SELECT value FROM tokens "
"LEFT JOIN languages ON tokens.language=languages.id "
.result = SQLITE_ROW,
.ret = "I"
},
- {
+ [RSPAMD_STAT_BACKEND_SET_TOKEN] = {
.idx = RSPAMD_STAT_BACKEND_SET_TOKEN,
.sql = "INSERT OR REPLACE INTO tokens (token, user, language, value, modified) "
"VALUES (?1, ?2, ?3, ?4, strftime('%s','now'));",
.result = SQLITE_DONE,
.ret = ""
},
- {
+ [RSPAMD_STAT_BACKEND_INC_LEARNS] = {
.idx = RSPAMD_STAT_BACKEND_INC_LEARNS,
.sql = "UPDATE languages SET learns=learns + 1 WHERE id=?1;"
"UPDATE users SET learns=learns + 1 WHERE id=?2;",
.result = SQLITE_DONE,
.ret = ""
},
- {
+ [RSPAMD_STAT_BACKEND_DEC_LEARNS] = {
.idx = RSPAMD_STAT_BACKEND_DEC_LEARNS,
.sql = "UPDATE languages SET learns=learns - 1 WHERE id=?1;"
"UPDATE users SET learns=learns - 1 WHERE id=?2;",
.result = SQLITE_DONE,
.ret = ""
},
- {
+ [RSPAMD_STAT_BACKEND_GET_LEARNS] = {
.idx = RSPAMD_STAT_BACKEND_GET_LEARNS,
.sql = "SELECT sum(learns) FROM languages;",
.stmt = NULL,
.result = SQLITE_ROW,
.ret = "I"
},
- {
+ [RSPAMD_STAT_BACKEND_GET_LANGUAGE] = {
.idx = RSPAMD_STAT_BACKEND_GET_LANGUAGE,
.sql = "SELECT id FROM languages WHERE name=?1;",
.stmt = NULL,
.result = SQLITE_ROW,
.ret = "I"
},
- {
+ [RSPAMD_STAT_BACKEND_GET_USER] = {
.idx = RSPAMD_STAT_BACKEND_GET_USER,
.sql = "SELECT id FROM users WHERE name=?1;",
.stmt = NULL,
.result = SQLITE_ROW,
.ret = "I"
},
- {
+ [RSPAMD_STAT_BACKEND_INSERT_USER] = {
.idx = RSPAMD_STAT_BACKEND_INSERT_USER,
.sql = "INSERT INTO users (name, learns) VALUES (?1, 0);",
.stmt = NULL,
.result = SQLITE_DONE,
.ret = "L"
},
- {
+ [RSPAMD_STAT_BACKEND_INSERT_LANGUAGE] = {
.idx = RSPAMD_STAT_BACKEND_INSERT_LANGUAGE,
.sql = "INSERT INTO languages (name, learns) VALUES (?1, 0);",
.stmt = NULL,
.result = SQLITE_DONE,
.ret = "L"
},
- {
+ [RSPAMD_STAT_BACKEND_SAVE_TOKENIZER] = {
.idx = RSPAMD_STAT_BACKEND_SAVE_TOKENIZER,
.sql = "INSERT INTO tokenizer(data) VALUES (?1);",
.stmt = NULL,
.result = SQLITE_DONE,
.ret = ""
},
- {
+ [RSPAMD_STAT_BACKEND_LOAD_TOKENIZER] = {
.idx = RSPAMD_STAT_BACKEND_LOAD_TOKENIZER,
.sql = "SELECT data FROM tokenizer;",
.stmt = NULL,
.result = SQLITE_ROW,
.ret = "B"
},
- {
+ [RSPAMD_STAT_BACKEND_NTOKENS] = {
.idx = RSPAMD_STAT_BACKEND_NTOKENS,
.sql = "SELECT COUNT(*) FROM tokens;",
.stmt = NULL,
.result = SQLITE_ROW,
.ret = "I"
},
- {
+ [RSPAMD_STAT_BACKEND_NLANGUAGES] = {
.idx = RSPAMD_STAT_BACKEND_NLANGUAGES,
.sql = "SELECT COUNT(*) FROM languages;",
.stmt = NULL,
.result = SQLITE_ROW,
.ret = "I"
},
- {
+ [RSPAMD_STAT_BACKEND_NUSERS] = {
.idx = RSPAMD_STAT_BACKEND_NUSERS,
.sql = "SELECT COUNT(*) FROM users;",
.stmt = NULL,
}
if (rt->user_id == -1) {
- rt->user_id = rspamd_sqlite3_get_user (bk, task, TRUE);
+ if (bk->enable_users) {
+ rt->user_id = rspamd_sqlite3_get_user (bk, task, TRUE);
+ }
+ else {
+ rt->user_id = 0;
+ }
}
if (rt->lang_id == -1) {
- rt->lang_id = rspamd_sqlite3_get_language (bk, task, TRUE);
+ if (bk->enable_languages) {
+ rt->lang_id = rspamd_sqlite3_get_language (bk, task, TRUE);
+ }
+ else {
+ rt->lang_id = 0;
+ }
}
iv = res->value;