diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-01-21 16:45:18 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-01-21 16:45:18 +0000 |
commit | 7895577bd6c4d4bf98fa2933cbee42ea5c6a95a2 (patch) | |
tree | ffc8c2aa5a4bd99024c10d383354807e33e3f249 /src/libutil/sqlite_utils.c | |
parent | ab479b021bd9a6c5a452bef9ea036a5a98fe45ab (diff) | |
download | rspamd-7895577bd6c4d4bf98fa2933cbee42ea5c6a95a2.tar.gz rspamd-7895577bd6c4d4bf98fa2933cbee42ea5c6a95a2.zip |
Add dedicated function to checkpoint sqlite
Diffstat (limited to 'src/libutil/sqlite_utils.c')
-rw-r--r-- | src/libutil/sqlite_utils.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/libutil/sqlite_utils.c b/src/libutil/sqlite_utils.c index 76a708593..0d0d565c3 100644 --- a/src/libutil/sqlite_utils.c +++ b/src/libutil/sqlite_utils.c @@ -431,3 +431,37 @@ rspamd_sqlite3_open_or_create (rspamd_mempool_t *pool, const gchar *path, const return sqlite; } + +gboolean +rspamd_sqlite3_sync (sqlite3 *db, gint *wal_frames, gint *wal_checkpoints) +{ + gint wf = 0, wc = 0, mode; + +#ifdef SQLITE_OPEN_WAL +#ifdef SQLITE_CHECKPOINT_TRUNCATE + mode = SQLITE_CHECKPOINT_TRUNCATE; +#elif defined(SQLITE_CHECKPOINT_RESTART) + mode = SQLITE_CHECKPOINT_RESTART; +#elif defined(SQLITE_CHECKPOINT_FULL) + mode = SQLITE_CHECKPOINT_FULL; +#endif + /* Perform wal checkpoint (might be long) */ + if (sqlite3_wal_checkpoint_v2 (db, + NULL, + mode, + &wf, + &wc) != SQLITE_OK) { + return FALSE; + + } +#endif + + if (wal_frames) { + *wal_frames = wf; + } + if (wal_checkpoints) { + *wal_checkpoints = wc; + } + + return TRUE; +} |