summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2021-12-03lib/config: don't overwrite database.path if the caller passed itDavid Bremner
If the user passed a path, and we opened it, then we consider that definitive definition of "database.path". This makes libnotmuch respond more gracefully to certain erroneous combinations of NOTMUCH_CONFIG settings and config file contents.
2021-12-03lib/open: track which parameters are passedDavid Bremner
This will be used to fine tune the loading of configuration for certain special configuration items (initially just "database.path").
2021-10-30lib/load_config: deallocate / NULL database on fatal errorDavid Bremner
This fixes a potential memory leak, and makes the behaviour of notmuch_database_load_config (somewhat) consistent with n_d_{open,create} with config.
2021-10-30lib/load_config: document expectations for db on error, add testsDavid Bremner
This is a bit different than n_d_{open,create}_with_config, since there are several non-zero status codes where we do want to return a non-NULL database structure.
2021-10-30lib/create: fix memory leak, ensure *database=NULL on errorDavid Bremner
This code previously relied on _finish_open to free the notmuch struct on errors (except for the case of database == NULL, which was a potential double free). When we removed those frees from _finish_open, we introduced a (small) memory leak. In this commit, fix the memory leak, and harmonize the on-error behaviour with n_d_open_with_config.
2021-10-30lib/create: document expectations for db on error, add testsDavid Bremner
It seems sensible to harmonize the behaviour with n_d_open_with_config. In this commit we just assert the desired behaviour.
2021-10-30lib/open: fix potential double-free, ensure *database=NULL on errorDavid Bremner
During refactoring for 0.32, the code that set notmuch=NULL on various errors was moved into _finish_open. This meant that the the code which relied on that to set *database to NULL on error was no longer correct. It also introduced a potential double free, since the notmuch struct was deallocated inside _finish_open (via n_d_destroy). In this commit we revert to "allocator frees", and leave any cleanup to the caller of _finish_open. This allows us to get back the behaviour of setting *database to NULL with a small change. Other callers of _finish_open will need free notmuch on errors.
2021-10-30lib: document n_o_w_config can return NOTMUCH_STATUS_NO_CONFIGDavid Bremner
This should be treated as fatal by callers, since we didn't succeed in opening a Xapian database.
2021-10-15lib: bump lib minor version to 5David Bremner
One new function (and an enum) was added to the API/ABI.
2021-09-10Merge tag '0.33.1'David Bremner
notmuch 0.33.1 release
2021-09-10lib: use 'localhost' rather than fqdn for default mail address.David Bremner
As discussed in the thread starting at [1], the fully qualified domain name is a bit tricky to get reproducibly, might reveal information people prefer to keep private, and somewhat unlikely to provide reliable mail routing. The new approach of $current_username@localhost is better for the first two considerations, and probably at least as good as a test mail address. [1]: id:87sfyibqhj.fsf@tethera.net
2021-09-04lib/parse-sexp: apply macrosDavid Bremner
Macros implement lazy evaluation and lexical scope. The former is needed to make certain natural constructs work sensibly (e.g. (tag ,param)) but the latter is mainly future-proofing in case the DSL is is extended to allow local bindings. For technical background, see chapters 6 and 17 of [1] (or some other intermediate programming languages textbook). [1] http://cs.brown.edu/courses/cs173/2012/book/
2021-09-04lib/parse-sexp: thread environment argument through parserDavid Bremner
No functionality change, just an extra argument carried everywhere.
2021-09-04lib/parse-sexp: support saved s-expression queriesDavid Bremner
It turns out there is not really much code in query-fp.cc useful for supporting the new syntax. The code we could potentially factor out amounts to calling notmuch_database_get_config; both the key construction and the parsing of the results are specific to the query syntax involved.
2021-09-04lib/parse-sexp: handle saved queriesDavid Bremner
This provides functionality analogous to query: in the Xapian QueryParser based parser. Perhaps counterintuitively, the saved queries currently have to be in the original query syntax (i.e. not s-expressions).
2021-09-04lib: factor out expansion of saved queries.David Bremner
This is intended to allow use outside of the Xapian query parser.
2021-09-04lib/parse-sexp: parse user headersDavid Bremner
One subtle aspect is the replacement of _find_prefix with _notmuch_database_prefix, which understands user headers. Otherwise the code mainly consists of creating a fake prefix record (since the user prefixes are not in the prefix table) and error handling.
2021-09-04lib/parse-sexp: support infix subqueriesDavid Bremner
This is necessary so that programs can take infix syntax queries from a user and use the sexp query syntax to construct e.g. a refinement of that query.
2021-09-04lib/parse-sexp: expand queriesDavid Bremner
The code here is just gluing together _notmuch_query_expand with the existing sexp parser infrastructure.
2021-09-04lib/thread-fp: factor out query expansion, rewrite in XapianDavid Bremner
It will be convenient not to have to construct a notmuch query object when parsing subqueries, so the commit rewrites the query expansion (currently only used for thread:{} queries) using only Xapian. As a bonus it seems about 15% faster in initial experiments.
2021-09-04lib/query: factor out _notmuch_query_string_to_xapian_queryDavid Bremner
When dealing with recursive queries (i.e. thread:{foo}) it turns out to be useful just to deal with the underlying Xapian objects, and not wrap them in notmuch objects.
2021-09-04lib: generate actual Xapian query for "*" and ""David Bremner
The previous code had the somewhat bizarre effect that the (notmuch specific) query string was "*" (interpreted as MatchAll) and the allegedly parsed xapian_query was "MatchNothing". This commit also reduces code duplication.
2021-09-04lib/parse-sexp: support regular expressionsDavid Bremner
At least to the degree that the Xapian QueryParser based parser also supports them. Support short alias 'rx' as it seems to make more complex queries nicer to read.
2021-09-04lib: factor out query construction from regexpDavid Bremner
This will allow re-use of this code outside of the Xapian query parser.
2021-09-04lib/query: generalize exclude handling to s-expression queriesDavid Bremner
In fact most of the code path is in common, only the caching of terms in the query needs to be added for s-expression queries.
2021-09-04lib/parse-sexp: handle unprefixed terms.David Bremner
This is equivalent to adding the same field name "" for multiple prefixes in the Xapian query parser, but we have to explicitely construct the resulting query.
2021-09-04lib/parse-sexp: add '*' as syntactic sugar for '(starts-with "")'David Bremner
Users that insist on using a literal '*' as a tag, can continue to do so by quoting it when searching.
2021-09-04lib/parse-sexp: 'starts-with' wildcard searchesDavid Bremner
The many tests potentially overkill, but they could catch typos in the prefixes table. As a simplifying assumption, for now we assume a single argument to the wildcard operator, as this matches the Xapian semantics. The name 'starts-with' is chosen to emphasize the supported case of wildcards in currrent (1.4.x) Xapian.
2021-09-04lib/parse-sexp: add term prefix backed fieldsDavid Bremner
We use "boolean" to describe fields that should generate terms literally without stemming or phrase splitting. This terminology might not be ideal but it is already enshrined in notmuch-search-terms(7).
2021-09-04lib/parse-sexp: support phrase queries.David Bremner
Anything that is quoted or not purely word characters is considered a phrase. Phrases are not stemmed, because the stems do not have positional information in the database. It is less efficient to scan the term twice, but it avoids a second pass to add prefixes, so maybe it balances out. In any case, it seems unlikely query parsing is very often a bottleneck.
2021-09-04lib/parse-sexp: support subject fieldDavid Bremner
The broken tests are because we do not yet handle phrase searches.
2021-09-04lib/parse-sexp: support and, not, and or.David Bremner
All operations and (Xapian) fields will eventually have an entry in the prefixes table. The flags field is just a placeholder for now, but will eventually distinguish between various kinds of prefixes.
2021-09-04lib/parse-sexp: stem unquoted atomsDavid Bremner
This is somewhat less DWIM than the Xapian query parser, but it has the advantage of simplicity.
2021-09-04lib: leave stemmer object accessibleDavid Bremner
This enables using the same stemmer in both query parsers.
2021-09-04lib/parse-sexp: parse single terms and the empty list.David Bremner
There is not much of a parser here yet, but it already does some useful error reporting. Most functionality sketched in the documentation is not implemented yet; detailed documentation will follow with the implementation.
2021-09-04lib: add new status code for query syntax errors.David Bremner
This will help provide more meaningful error messages without special casing on the client side.
2021-09-04lib: define notmuch_query_create_with_syntaxDavid Bremner
Set the parsing syntax when the (notmuch) query object is created. Initially the library always returns a trivial query that matches all messages when using s-expression syntax. It seems better to select the syntax at query creation time because the lazy parsing is an implementation detail.
2021-09-04lib: split notmuch_query_createDavid Bremner
Most of the function will be re-usable when creating a query from an s-expression.
2021-09-04configure: optional library sfsexpDavid Bremner
The configure part is essentially the same as the other checks using pkg-config. Since the optional inclusion of this feature changes what options are available to the user, include it in the "built_with" pseudo-configuration keys.
2021-08-29lib: consider all instances of Delivered-To headerHannu Hartikainen
When using notmuch-reply and guessing the From: address from Delivered-To headers, I had the wrong address chosen today. This was because the messages from the notmuch list contain these headers in this order: Delivered-To: hannu.hartikainen@gmail.com ... Delivered-To: hannu@hrtk.in In my .notmuch-config I have the following configuration: primary_email=hannu@hrtk.in other_email=hannu.hartikainen@gmail.com;... Before this change, notmuch-reply would guess From: @gmail.com because that is the first Delivered-To header present. After the change, the primary address is chosen as I would expect.
2021-08-18Merge tag 'debian/0.32.3-1'David Bremner
notmuch release 0.32.3-1 for unstable (sid) [dgit] [dgit distro=debian no-split --quilt=linear]
2021-08-17lib/open: look in MAILDIR for database, as documented.David Bremner
This fixes the bug id:87bl9lx864.fsf@kisara.moe
2021-08-17lib: bump libnotmuch minor versionAustin Ray
Notmuch 0.32 corresponds to libnotmuch 5.4 as indicated by docstrings; however, the minor number wasn't bumped. Any libnotmuch downstream consumer using the LIBNOTMUCH_CHECK_VERSION macro to support multiple versions won't be able to access the new 5.4 functions. Signed-off-by: Austin Ray <austin@austinray.io>
2021-08-17lib: correct deprecated db open functions' docsAustin Ray
Both notmuch_database_open() and notmuch_database_open_verbose()'s documentation state they call notmuch_database_open_with_config() with config_path=NULL; however, their implementations pass an empty string. The empty string is the correct value to maintain their original behavior of not loading the user's configuration so their documentation is incorrect.
2021-06-27lib: update transaction documentationDavid Bremner
Partly this is to recognize the semantics we inherit from Xapian, partly to mention the new autocommit feature.
2021-06-27lib: autocommit after some number of completed transactionsDavid Bremner
This change addresses two known issues with large sets of changes to the database. The first is that as reported by Steven Allen [1], notmuch commits are not "flushed" when they complete, which means that if there is an open transaction when the database closes (or e.g. the program crashes) then all changes since the last commit will be discarded (nothing is irrecoverably lost for "notmuch new", as the indexing process just restarts next time it is run). This does not really "fix" the issue reported in [1]; that seems rather difficult given how transactions work in Xapian. On the other hand, with the default settings, this should mean one only loses less than a minutes worth of work. The second issue is the occasionally reported "storm" of disk writes when notmuch finishes. I don't yet have a test for this, but I think committing as we go should reduce the amount of work when finalizing the database. [1]: id:20151025210215.GA3754@stebalien.com
2021-06-27lib/config: add NOTMUCH_CONFIG_AUTOCOMMITDavid Bremner
This will be used to control how often atomic transactions are committed.
2021-06-27database/close: remove misleading code / commentDavid Bremner
Unfortunately, it doesn't make a difference if we call cancel_transaction or not, all uncommited changes are discarded if there is an open (unflushed) transaction.
2021-06-27lib/database: fix style mistake.David Bremner
The spacing of the declaration was wrong in ea30110.
2021-06-25Merge branch 'release'David Bremner