diff options
| author | David Bremner <david@tethera.net> | 2018-11-17 10:08:59 -0400 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2019-05-25 06:56:16 -0300 |
| commit | 575493e78534f8fd241d663b8690a22d6885e0b1 (patch) | |
| tree | ad791ef6edb0247b9fa86f011c5a8e52436f131b /lib/database.cc | |
| parent | 4b9c03efc6e4cd4b083c18c98416218059d1b8d7 (diff) | |
lib: setup user headers in query parser
These tests will need to be updated if the Xapian
query print/debug format changes.
Diffstat (limited to 'lib/database.cc')
| -rw-r--r-- | lib/database.cc | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/database.cc b/lib/database.cc index 1753117f..dd1c1c7d 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -322,6 +322,42 @@ _setup_query_field_default (const prefix_t *prefix, notmuch_database_t *notmuch) notmuch->query_parser->add_boolean_prefix (prefix->name, prefix->prefix); } +const char * +_user_prefix (void *ctx, const char* name) +{ + return talloc_asprintf(ctx, "XU%s:", name); +} + +static notmuch_status_t +_setup_user_query_fields (notmuch_database_t *notmuch) +{ + notmuch_config_list_t *list; + notmuch_status_t status; + + status = notmuch_database_get_config_list (notmuch, CONFIG_HEADER_PREFIX, &list); + if (status) + return status; + + for (; notmuch_config_list_valid (list); notmuch_config_list_move_to_next (list)) { + + prefix_t query_field; + + const char *key = notmuch_config_list_key (list) + + sizeof (CONFIG_HEADER_PREFIX) - 1; + + query_field.name = talloc_strdup (notmuch, key); + query_field.prefix = _user_prefix (notmuch, key); + query_field.flags = NOTMUCH_FIELD_PROBABILISTIC + | NOTMUCH_FIELD_EXTERNAL; + + _setup_query_field_default (&query_field, notmuch); + } + + notmuch_config_list_destroy (list); + + return NOTMUCH_STATUS_SUCCESS; +} + #if HAVE_XAPIAN_FIELD_PROCESSOR static void _setup_query_field (const prefix_t *prefix, notmuch_database_t *notmuch) @@ -986,6 +1022,7 @@ notmuch_database_open_verbose (const char *path, _setup_query_field (prefix, notmuch); } } + status = _setup_user_query_fields (notmuch); } catch (const Xapian::Error &error) { IGNORE_RESULT (asprintf (&message, "A Xapian exception occurred opening database: %s\n", error.get_msg().c_str())); |
