gint fd;
struct rspamd_fuzzy_backend *backend;
static const char sqlite_wal[] = "PRAGMA journal_mode=\"wal\";",
- fallback_journal[] = "PRAGMA journal_mode=\"off\";";
+ fallback_journal[] = "PRAGMA journal_mode=\"off\";",
+ foreign_keys[] = "PRAGMA foreign_keys=\"ON\";";
int rc;
if (path == NULL) {
sqlite3_exec (backend->db, fallback_journal, NULL, NULL, NULL);
}
+ if ((rc = sqlite3_exec (backend->db, foreign_keys, NULL, NULL, NULL)) !=
+ SQLITE_OK) {
+ msg_warn_fuzzy_backend ("foreign keys are not supported", rc);
+ }
+
/* Cleanup database */
rspamd_fuzzy_backend_run_simple (RSPAMD_FUZZY_BACKEND_VACUUM, backend, NULL);
gchar lock_path[PATH_MAX], dbdir[PATH_MAX], *pdir;
static const char sqlite_wal[] = "PRAGMA journal_mode=\"wal\";",
exclusive_lock_sql[] = "PRAGMA locking_mode=\"exclusive\";",
- fsync_sql[] = "PRAGMA synchronous=1;";
+ fsync_sql[] = "PRAGMA synchronous=1;",
+ foreign_keys[] = "PRAGMA foreign_keys=\"ON\";";
gboolean create = FALSE, has_lock = FALSE;
flags = SQLITE_OPEN_READWRITE;
sqlite3_errmsg (sqlite));
}
+ if ((rc = sqlite3_exec (sqlite, foreign_keys, NULL, NULL, NULL)) !=
+ SQLITE_OK) {
+ msg_warn_pool ("cannot enable foreign keys: %s",
+ sqlite3_errmsg (sqlite));
+ }
+
if (has_lock) {
msg_debug_pool ("removing lock from %s", lock_path);
rspamd_file_unlock (lock_fd, FALSE);