[geary: 2/4] Add some FTS table management methods to Geary.ImapDB.Database.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary: 2/4] Add some FTS table management methods to Geary.ImapDB.Database.
- Date: Fri, 21 Oct 2016 21:17:05 +0000 (UTC)
commit 07306e24836d6810a92e67d0e1382692f99e0d52
Author: Michael James Gratton <mike vee net>
Date: Fri Oct 14 19:23:30 2016 +1100
Add some FTS table management methods to Geary.ImapDB.Database.
src/engine/imap-db/imap-db-database.vala | 46 +++++++++++++++++++++++++++++-
1 files changed, 45 insertions(+), 1 deletions(-)
---
diff --git a/src/engine/imap-db/imap-db-database.vala b/src/engine/imap-db/imap-db-database.vala
index 3e2b50a..3fe0387 100644
--- a/src/engine/imap-db/imap-db-database.vala
+++ b/src/engine/imap-db/imap-db-database.vala
@@ -556,7 +556,51 @@ private class Geary.ImapDB.Database : Geary.Db.VersionedDatabase {
error("Error creating tokenizer table: %s", e.message);
}
}
-
+
+ /**
+ * Determines if the database's FTS table indexes are valid.
+ */
+ public bool fts_integrity_check() throws Error {
+ Db.Statement stmt = prepare("""
+ INSERT INTO MessageSearchTable(MessageSearchTable)
+ VALUES('integrity-check')
+ """);
+ bool passed = true;
+ try {
+ stmt.exec();
+ } catch (DatabaseError.CORRUPT err) {
+ passed = false;
+ }
+ return passed;
+ }
+
+ /**
+ * Rebuilds the database's FTS table index.
+ *
+ * This can be used to recover from corrupt indexs, as indicated
+ * by fts_integrity_check() returning false.
+ */
+ public void fts_rebuild() throws Error {
+ Db.Statement stmt = prepare("""
+ INSERT INTO MessageSearchTable(MessageSearchTable)
+ VALUES('rebuild')
+ """);
+ stmt.exec();
+ }
+
+ /**
+ * Optimises the database's FTS table index.
+ *
+ * This is an expensive call, as much as performing a VACCUM.
+ */
+ public void fts_optimize() throws Error {
+ Db.Statement stmt = prepare("""
+ INSERT INTO MessageSearchTable(MessageSearchTable)
+ VALUES('optimize')
+ """);
+ stmt.exec();
+ }
+
private void on_prepare_database_connection(Db.Connection cx) throws Error {
cx.set_busy_timeout_msec(Db.Connection.RECOMMENDED_BUSY_TIMEOUT_MSEC);
cx.set_foreign_keys(true);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]