[PATCH 08/12] lib/database: add NOTMUCH_FEATURE_MESSAGE_DATA
David Bremner
david at tethera.net
Fri Jun 22 18:42:43 PDT 2018
This feature is intended to mark the database as supporting a
key-value store in the document data area. The actual key-value store
is implemented in a subsequent commit.
---
lib/database-private.h | 8 +++++++-
lib/database.cc | 12 ++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/lib/database-private.h b/lib/database-private.h
index a499b259..3a15fd16 100644
--- a/lib/database-private.h
+++ b/lib/database-private.h
@@ -108,6 +108,12 @@ enum _notmuch_features {
*
* Introduced: version 3. */
NOTMUCH_FEATURE_LAST_MOD = 1 << 6,
+
+ /* If set, messages store a serialized string-map in their data
+ * area
+ *
+ * Introduced: version 3. */
+ NOTMUCH_FEATURE_MESSAGE_DATA = 1 << 7,
};
/* In C++, a named enum is its own type, so define bitwise operators
@@ -233,7 +239,7 @@ struct _notmuch_database {
#define NOTMUCH_FEATURES_CURRENT \
(NOTMUCH_FEATURE_FILE_TERMS | NOTMUCH_FEATURE_DIRECTORY_DOCS | \
NOTMUCH_FEATURE_BOOL_FOLDER | NOTMUCH_FEATURE_GHOSTS | \
- NOTMUCH_FEATURE_LAST_MOD)
+ NOTMUCH_FEATURE_LAST_MOD | NOTMUCH_FEATURE_MESSAGE_DATA )
/* Return the list of terms from the given iterator matching a prefix.
* The prefix will be stripped from the strings in the returned list.
diff --git a/lib/database.cc b/lib/database.cc
index 9cf8062c..47e903d5 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -383,6 +383,8 @@ static const struct {
"indexed MIME types", "w"},
{ NOTMUCH_FEATURE_LAST_MOD,
"modification tracking", "w"},
+ { NOTMUCH_FEATURE_MESSAGE_DATA,
+ "per message data", "rw"},
};
const char *
@@ -1342,6 +1344,16 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,
if (! notmuch_database_needs_upgrade (notmuch))
return NOTMUCH_STATUS_SUCCESS;
+ /*
+ * the upgrade for NOTMUCH_FEATURE_MESSAGE_DATA is actually done
+ * by NOTMUCH_FEATURE_FILE_TERMS
+ */
+ if ((new_features & NOTMUCH_FEATURE_MESSAGE_DATA) &&
+ !(target_features & NOTMUCH_FEATURE_FILE_TERMS)) {
+ _notmuch_database_log (notmuch, "inconsistent feature set");
+ return NOTMUCH_STATUS_UNSUPPORTED_OPERATION;
+ }
+
if (progress_notify) {
/* Set up our handler for SIGALRM */
memset (&action, 0, sizeof (struct sigaction));
--
2.17.1
More information about the notmuch
mailing list