aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/sqlite_utils.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-09-28 10:40:43 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-09-28 10:40:43 +0100
commit762aeb28d3086386baf6b87bf8fb35198757aeec (patch)
tree6261e503616a4af3bb126b3904baca4ef4623871 /src/libutil/sqlite_utils.c
parentc698e465d766a9c48014150ebb96a7f92aee7cca (diff)
downloadrspamd-762aeb28d3086386baf6b87bf8fb35198757aeec.tar.gz
rspamd-762aeb28d3086386baf6b87bf8fb35198757aeec.zip
Enable foreign keys in sqlite3.
Diffstat (limited to 'src/libutil/sqlite_utils.c')
-rw-r--r--src/libutil/sqlite_utils.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libutil/sqlite_utils.c b/src/libutil/sqlite_utils.c
index 0dea2edc2..d677a0dc2 100644
--- a/src/libutil/sqlite_utils.c
+++ b/src/libutil/sqlite_utils.c
@@ -249,7 +249,8 @@ rspamd_sqlite3_open_or_create (rspamd_mempool_t *pool, const gchar *path, const
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;
@@ -377,6 +378,12 @@ rspamd_sqlite3_open_or_create (rspamd_mempool_t *pool, const gchar *path, const
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);