Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / ce / 94cd64c5cca99581a557d4abb5db398282330c
1 Return-Path: <m.walters@qmul.ac.uk>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 1D35E431FBC\r
6         for <notmuch@notmuchmail.org>; Sun, 27 Jul 2014 02:54:16 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.502\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.502 tagged_above=-999 required=5\r
12         tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
13         NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id Pp9Dr19U+OZr for <notmuch@notmuchmail.org>;\r
17         Sun, 27 Jul 2014 02:54:08 -0700 (PDT)\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 97910431FB6\r
22         for <notmuch@notmuchmail.org>; Sun, 27 Jul 2014 02:54:07 -0700 (PDT)\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
24         by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
25         (envelope-from <m.walters@qmul.ac.uk>)\r
26         id 1XBL9F-0004Fl-0B; Sun, 27 Jul 2014 10:54:05 +0100\r
27 Received: from 94.196.249.126.threembb.co.uk ([94.196.249.126] helo=localhost)\r
28         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)\r
29         (envelope-from <m.walters@qmul.ac.uk>)\r
30         id 1XBL98-0006EF-Eg; Sun, 27 Jul 2014 10:53:44 +0100\r
31 From: Mark Walters <markwalters1009@gmail.com>\r
32 To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
33 Subject: Re: [PATCH 05/14] lib: Database version 3: Introduce fine-grained\r
34         "features"\r
35 In-Reply-To: <1406433173-19169-6-git-send-email-amdragon@mit.edu>\r
36 References: <1406433173-19169-1-git-send-email-amdragon@mit.edu>\r
37         <1406433173-19169-6-git-send-email-amdragon@mit.edu>\r
38 User-Agent: Notmuch/0.15.2+615~g78e3a93 (http://notmuchmail.org) Emacs/23.4.1\r
39         (x86_64-pc-linux-gnu)\r
40 Date: Sun, 27 Jul 2014 10:53:25 +0100\r
41 Message-ID: <87silnyvoq.fsf@qmul.ac.uk>\r
42 MIME-Version: 1.0\r
43 Content-Type: text/plain; charset=us-ascii\r
44 X-Sender-Host-Address: 94.196.249.126\r
45 X-QM-Geographic: According to ripencc,\r
46         this message was delivered by a machine in Britain (UK) (GB).\r
47 X-QM-SPAM-Info: Sender has good ham record.  :)\r
48 X-QM-Body-MD5: 74279823180b19ebad2f59792d4c5cc2 (of first 20000 bytes)\r
49 X-SpamAssassin-Score: -0.0\r
50 X-SpamAssassin-SpamBar: /\r
51 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
52         determine if it is\r
53         spam. We require at least 5.0 points to mark a message as spam.\r
54         This message scored -0.0 points.\r
55         Summary of the scoring: \r
56         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
57         provider *      (markwalters1009[at]gmail.com)\r
58         * -0.0 AWL AWL: From: address is in the auto white-list\r
59 X-QM-Scan-Virus: ClamAV says the message is clean\r
60 X-BeenThere: notmuch@notmuchmail.org\r
61 X-Mailman-Version: 2.1.13\r
62 Precedence: list\r
63 List-Id: "Use and development of the notmuch mail system."\r
64         <notmuch.notmuchmail.org>\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
66         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
68 List-Post: <mailto:notmuch@notmuchmail.org>\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
72 X-List-Received-Date: Sun, 27 Jul 2014 09:54:16 -0000\r
73 \r
74 \r
75 On Sun, 27 Jul 2014, Austin Clements <amdragon@MIT.EDU> wrote:\r
76 > Previously, our database schema was versioned by a single number.\r
77 > Each database schema change had to occur "atomically" in Notmuch's\r
78 > development history: before some commit, Notmuch used version N, after\r
79 > that commit, it used version N+1.  Hence, each new schema version\r
80 > could introduce only one change, the task of developing a schema\r
81 > change fell on a single person, and it all had to happen and be\r
82 > perfect in a single commit series.  This made introducing a new schema\r
83 > version hard.  We've seen only two schema changes in the history of\r
84 > Notmuch.\r
85 \r
86 I like this series as a whole and I am happy with all the patches that I\r
87 haven't sent comments on. (Note, however, that I am not very familiar\r
88 with the database code.)\r
89 \r
90 There is one thing which confuses me in this patch:\r
91 \r
92 >\r
93 > This commit introduces database schema version 3; hopefully the last\r
94 > schema version we'll need for a while.  With this version, we switch\r
95 > from a single version number to "features": a set of named,\r
96 > independent aspects of the database schema.\r
97 >\r
98 > Features should make backwards compatibility easier.  For many things,\r
99 > it should be easy to support databases both with and without a\r
100 > feature, which will allow us to make upgrades optional and will enable\r
101 > "unstable" features that can be developed and tested over time.\r
102 >\r
103 > Features also make forwards compatibility easier.  The features\r
104 > recorded in a database include "compatibility flags," which can\r
105 > indicate to an older version of Notmuch when it must support a given\r
106 > feature to open the database for read or for write.  This lets us\r
107 > replace the old vague "I don't recognize this version, so something\r
108 > might go wrong, but I promise to try my best" warnings upon opening a\r
109 > database with an unknown version with precise errors.  If a database\r
110 > is safe to open for read/write despite unknown features, an older\r
111 > version will know that and issue no message at all.  If the database\r
112 > is not safe to open for read/write because of unknown features, an\r
113 > older version will know that, too, and can tell the user exactly which\r
114 > required features it lacks support for.\r
115 > ---\r
116 >  lib/database-private.h |  56 +++++++++++++++\r
117 >  lib/database.cc        | 189 +++++++++++++++++++++++++++++++++++++++++--------\r
118 >  2 files changed, 214 insertions(+), 31 deletions(-)\r
119 >\r
120 > diff --git a/lib/database-private.h b/lib/database-private.h\r
121 > index d3e65fd..323b9fe 100644\r
122 > --- a/lib/database-private.h\r
123 > +++ b/lib/database-private.h\r
124 > @@ -46,6 +46,11 @@ struct _notmuch_database {\r
125 >      int atomic_nesting;\r
126 >      Xapian::Database *xapian_db;\r
127 >  \r
128 > +    /* Bit mask of features used by this database.  Features are\r
129 > +     * named, independent aspects of the database schema.  This is a\r
130 > +     * bitwise-OR of NOTMUCH_FEATURE_* values (below). */\r
131 > +    unsigned int features;\r
132 > +\r
133 >      unsigned int last_doc_id;\r
134 >      uint64_t last_thread_id;\r
135 >  \r
136 > @@ -55,6 +60,57 @@ struct _notmuch_database {\r
137 >      Xapian::ValueRangeProcessor *date_range_processor;\r
138 >  };\r
139 >  \r
140 > +/* Bit masks for _notmuch_database::features. */\r
141 > +enum {\r
142 > +    /* If set, file names are stored in "file-direntry" terms.  If\r
143 > +     * unset, file names are stored in document data.\r
144 > +     *\r
145 > +     * Introduced: version 1.  Implementation support: both for read;\r
146 > +     * required for write. */\r
147 > +    NOTMUCH_FEATURE_FILE_TERMS = 1 << 0,\r
148 > +\r
149 > +    /* If set, directory timestamps are stored in documents with\r
150 > +     * XDIRECTORY terms and relative paths.  If unset, directory\r
151 > +     * timestamps are stored in documents with XTIMESTAMP terms and\r
152 > +     * absolute paths.\r
153 > +     *\r
154 > +     * Introduced: version 1.  Implementation support: required. */\r
155 > +    NOTMUCH_FEATURE_DIRECTORY_DOCS = 1 << 1,\r
156 > +\r
157 > +    /* If set, the from, subject, and message-id headers are stored in\r
158 > +     * message document values.  If unset, message documents *may*\r
159 > +     * have these values, but if the value is empty, it must be\r
160 > +     * retrieved from the message file.\r
161 > +     *\r
162 > +     * Introduced: optional in version 1, required as of version 3.\r
163 > +     * Implementation support: both.\r
164 > +     */\r
165 > +    NOTMUCH_FEATURE_FROM_SUBJECT_ID_VALUES = 1 << 2,\r
166 > +\r
167 > +    /* If set, folder terms are boolean and path terms exist.  If\r
168 > +     * unset, folder terms are probabilistic and stemmed and path\r
169 > +     * terms do not exist.\r
170 > +     *\r
171 > +     * Introduced: version 2.  Implementation support: required. */\r
172 > +    NOTMUCH_FEATURE_BOOL_FOLDER = 1 << 3,\r
173 > +};\r
174 > +\r
175 > +/* Prior to database version 3, features were implied by the database\r
176 > + * version number, so hard-code them for earlier versions. */\r
177 > +#define NOTMUCH_FEATURES_V0 (0)\r
178 > +#define NOTMUCH_FEATURES_V1 (NOTMUCH_FEATURES_V0 | NOTMUCH_FEATURE_FILE_TERMS | \\r
179 > +                          NOTMUCH_FEATURE_DIRECTORY_DOCS)\r
180 > +#define NOTMUCH_FEATURES_V2 (NOTMUCH_FEATURES_V1 | NOTMUCH_FEATURE_BOOL_FOLDER)\r
181 > +\r
182 > +/* Current database features.  If any of these are missing from a\r
183 > + * database, request an upgrade.\r
184 > + * NOTMUCH_FEATURE_FROM_SUBJECT_ID_VALUES is not included because\r
185 > + * upgrade doesn't currently introduce the feature (though brand new\r
186 > + * databases will have it). */\r
187 > +#define NOTMUCH_FEATURES_CURRENT \\r
188 > +    (NOTMUCH_FEATURE_FILE_TERMS | NOTMUCH_FEATURE_DIRECTORY_DOCS | \\r
189 > +     NOTMUCH_FEATURE_BOOL_FOLDER)\r
190 > +\r
191 >  /* Return the list of terms from the given iterator matching a prefix.\r
192 >   * The prefix will be stripped from the strings in the returned list.\r
193 >   * The list will be allocated using ctx as the talloc context.\r
194 > diff --git a/lib/database.cc b/lib/database.cc\r
195 > index 45c4260..03eef3e 100644\r
196 > --- a/lib/database.cc\r
197 > +++ b/lib/database.cc\r
198 > @@ -20,6 +20,7 @@\r
199 >  \r
200 >  #include "database-private.h"\r
201 >  #include "parse-time-vrp.h"\r
202 > +#include "string-util.h"\r
203 >  \r
204 >  #include <iostream>\r
205 >  \r
206 > @@ -42,7 +43,7 @@ typedef struct {\r
207 >      const char *prefix;\r
208 >  } prefix_t;\r
209 >  \r
210 > -#define NOTMUCH_DATABASE_VERSION 2\r
211 > +#define NOTMUCH_DATABASE_VERSION 3\r
212 >  \r
213 >  #define STRINGIFY(s) _SUB_STRINGIFY(s)\r
214 >  #define _SUB_STRINGIFY(s) #s\r
215 > @@ -151,6 +152,17 @@ typedef struct {\r
216 >   *                   changes are made to the database (such as by\r
217 >   *                   indexing new fields).\r
218 >   *\r
219 > + *   features        The set of features supported by this\r
220 > + *                   database. This consists of a set of\r
221 > + *                   '\n'-separated lines, where each is a feature\r
222 > + *                   name, a '\t', and compatibility flags.  If the\r
223 > + *                   compatibility flags contain 'w', then the\r
224 > + *                   opener must support this feature to safely\r
225 > + *                   write this database.  If the compatibility\r
226 > + *                   flags contain 'r', then the opener must\r
227 > + *                   support this feature to read this database.\r
228 > + *                   Introduced in database version 3.\r
229 > + *\r
230 >   *   last_thread_id  The last thread ID generated. This is stored\r
231 >   *                   as a 16-byte hexadecimal ASCII representation\r
232 >   *                   of a 64-bit unsigned integer. The first ID\r
233 > @@ -226,6 +238,7 @@ static prefix_t PROBABILISTIC_PREFIX[]= {\r
234 >      { "subject",             "XSUBJECT"},\r
235 >  };\r
236 >  \r
237 > +\r
238 >  const char *\r
239 >  _find_prefix (const char *name)\r
240 >  {\r
241 > @@ -251,6 +264,25 @@ _find_prefix (const char *name)\r
242 >      return "";\r
243 >  }\r
244 >  \r
245 > +static const struct\r
246 > +{\r
247 > +    /* NOTMUCH_FEATURE_* value. */\r
248 > +    unsigned int value;\r
249 > +    /* Feature name as it appears in the database.  This name should\r
250 > +     * be appropriate for displaying to the user if an older version\r
251 > +     * of notmuch doesn't support this feature. */\r
252 > +    const char *name;\r
253 > +    /* Compatibility flags when this feature is declared. */\r
254 > +    const char *flags;\r
255 > +} feature_names[] = {\r
256 > +    {NOTMUCH_FEATURE_FILE_TERMS,             "file terms", "rw"},\r
257 > +    {NOTMUCH_FEATURE_DIRECTORY_DOCS,         "directory documents", "rw"},\r
258 > +    /* Header values are not required for reading a database because a\r
259 > +     * reader can just refer to the message file. */\r
260 > +    {NOTMUCH_FEATURE_FROM_SUBJECT_ID_VALUES, "from/subject/ID values", "w"},\r
261 > +    {NOTMUCH_FEATURE_BOOL_FOLDER,            "boolean folder terms", "rw"},\r
262 > +};\r
263 > +\r
264 >  const char *\r
265 >  notmuch_status_to_string (notmuch_status_t status)\r
266 >  {\r
267 > @@ -591,6 +623,11 @@ notmuch_database_create (const char *path, notmuch_database_t **database)\r
268 >                                   &notmuch);\r
269 >      if (status)\r
270 >       goto DONE;\r
271 > +\r
272 > +    /* Upgrade doesn't add this feature to existing databases, but new\r
273 > +     * databases have it. */\r
274 > +    notmuch->features |= NOTMUCH_FEATURE_FROM_SUBJECT_ID_VALUES;\r
275 > +\r
276 \r
277 Does this mean that if the user wants this feature he has to dump,\r
278 delete the existing database, and restore? Is that just because no-one\r
279 has implemented upgrade for this feature or is it "hard" in some sense?\r
280 \r
281 A possibly related question: is there likely to be a case where the user\r
282 does not want to add/upgrade some feature? Would it be worth having an\r
283 explicit upgrade command which let the user choose which features to\r
284 upgrade? This is orthogonal to this series: I am just trying to get a\r
285 feel for how it will, or could, be used.\r
286 \r
287 Best wishes\r
288 \r
289 Mark\r
290 \r
291 >      status = notmuch_database_upgrade (notmuch, NULL, NULL);\r
292 >      if (status) {\r
293 >       notmuch_database_close(notmuch);\r
294 > @@ -619,6 +656,80 @@ _notmuch_database_ensure_writable (notmuch_database_t *notmuch)\r
295 >      return NOTMUCH_STATUS_SUCCESS;\r
296 >  }\r
297 >  \r
298 > +/* Parse a database features string from the given database version.\r
299 > + *\r
300 > + * For version < 3, this ignores the features string and returns a\r
301 > + * hard-coded set of features.\r
302 > + *\r
303 > + * If there are unrecognized features that are required to open the\r
304 > + * database in mode (which should be 'r' or 'w'), return a\r
305 > + * comma-separated list of unrecognized but required features in\r
306 > + * *incompat_out, which will be allocated from ctx.\r
307 > + */\r
308 > +static unsigned int\r
309 > +_parse_features (const void *ctx, const char *features, unsigned int version,\r
310 > +              char mode, char **incompat_out)\r
311 > +{\r
312 > +    unsigned int res = 0, namelen, i;\r
313 > +    size_t llen = 0;\r
314 > +    const char *flags;\r
315 > +\r
316 > +    /* Prior to database version 3, features were implied by the\r
317 > +     * version number. */\r
318 > +    if (version == 0)\r
319 > +     return NOTMUCH_FEATURES_V0;\r
320 > +    else if (version == 1)\r
321 > +     return NOTMUCH_FEATURES_V1;\r
322 > +    else if (version == 2)\r
323 > +     return NOTMUCH_FEATURES_V2;\r
324 > +\r
325 > +    /* Parse the features string */\r
326 > +    while ((features = strtok_len_c (features + llen, "\n", &llen)) != NULL) {\r
327 > +     flags = strchr (features, '\t');\r
328 > +     if (! flags || flags > features + llen)\r
329 > +         continue;\r
330 > +     namelen = flags - features;\r
331 > +\r
332 > +     for (i = 0; i < ARRAY_SIZE (feature_names); ++i) {\r
333 > +         if (strlen (feature_names[i].name) == namelen &&\r
334 > +             strncmp (feature_names[i].name, features, namelen) == 0) {\r
335 > +             res |= feature_names[i].value;\r
336 > +             break;\r
337 > +         }\r
338 > +     }\r
339 > +\r
340 > +     if (i == ARRAY_SIZE (feature_names)) {\r
341 > +         /* Unrecognized feature */\r
342 > +         const char *have = strchr (flags, mode);\r
343 > +         if (have && have < features + llen) {\r
344 > +             /* This feature is required to access this database in\r
345 > +              * 'mode', but we don't understand it. */\r
346 > +             if (! *incompat_out)\r
347 > +                 *incompat_out = talloc_strdup (ctx, "");\r
348 > +             *incompat_out = talloc_asprintf_append_buffer (\r
349 > +                 *incompat_out, "%s%.*s", **incompat_out ? ", " : "",\r
350 > +                 namelen, features);\r
351 > +         }\r
352 > +     }\r
353 > +    }\r
354 > +\r
355 > +    return res;\r
356 > +}\r
357 > +\r
358 > +static char *\r
359 > +_print_features (const void *ctx, unsigned int features)\r
360 > +{\r
361 > +    unsigned int i;\r
362 > +    char *res = talloc_strdup (ctx, "");\r
363 > +\r
364 > +    for (i = 0; i < ARRAY_SIZE (feature_names); ++i)\r
365 > +     if (features & feature_names[i].value)\r
366 > +         res = talloc_asprintf_append_buffer (\r
367 > +             res, "%s\t%s\n", feature_names[i].name, feature_names[i].flags);\r
368 > +\r
369 > +    return res;\r
370 > +}\r
371 > +\r
372 >  notmuch_status_t\r
373 >  notmuch_database_open (const char *path,\r
374 >                      notmuch_database_mode_t mode,\r
375 > @@ -627,7 +738,7 @@ notmuch_database_open (const char *path,\r
376 >      notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;\r
377 >      void *local = talloc_new (NULL);\r
378 >      notmuch_database_t *notmuch = NULL;\r
379 > -    char *notmuch_path, *xapian_path;\r
380 > +    char *notmuch_path, *xapian_path, *incompat_features;\r
381 >      struct stat st;\r
382 >      int err;\r
383 >      unsigned int i, version;\r
384 > @@ -686,39 +797,51 @@ notmuch_database_open (const char *path,\r
385 >       if (mode == NOTMUCH_DATABASE_MODE_READ_WRITE) {\r
386 >           notmuch->xapian_db = new Xapian::WritableDatabase (xapian_path,\r
387 >                                                              Xapian::DB_CREATE_OR_OPEN);\r
388 > -         version = notmuch_database_get_version (notmuch);\r
389 > -\r
390 > -         if (version > NOTMUCH_DATABASE_VERSION) {\r
391 > -             fprintf (stderr,\r
392 > -                      "Error: Notmuch database at %s\n"\r
393 > -                      "       has a newer database format version (%u) than supported by this\n"\r
394 > -                      "       version of notmuch (%u). Refusing to open this database in\n"\r
395 > -                      "       read-write mode.\n",\r
396 > -                      notmuch_path, version, NOTMUCH_DATABASE_VERSION);\r
397 > -             notmuch->mode = NOTMUCH_DATABASE_MODE_READ_ONLY;\r
398 > -             notmuch_database_destroy (notmuch);\r
399 > -             notmuch = NULL;\r
400 > -             status = NOTMUCH_STATUS_FILE_ERROR;\r
401 > -             goto DONE;\r
402 > -         }\r
403 > -\r
404 > -         if (version < NOTMUCH_DATABASE_VERSION)\r
405 > -             notmuch->needs_upgrade = TRUE;\r
406 >       } else {\r
407 >           notmuch->xapian_db = new Xapian::Database (xapian_path);\r
408 > -         version = notmuch_database_get_version (notmuch);\r
409 > -         if (version > NOTMUCH_DATABASE_VERSION)\r
410 > -         {\r
411 > -             fprintf (stderr,\r
412 > -                      "Warning: Notmuch database at %s\n"\r
413 > -                      "         has a newer database format version (%u) than supported by this\n"\r
414 > -                      "         version of notmuch (%u). Some operations may behave incorrectly,\n"\r
415 > -                      "         (but the database will not be harmed since it is being opened\n"\r
416 > -                      "         in read-only mode).\n",\r
417 > -                      notmuch_path, version, NOTMUCH_DATABASE_VERSION);\r
418 > -         }\r
419 >       }\r
420 >  \r
421 > +     /* Check version.  As of database version 3, we represent\r
422 > +      * changes in terms of features, so assume a version bump\r
423 > +      * means a dramatically incompatible change. */\r
424 > +     version = notmuch_database_get_version (notmuch);\r
425 > +     if (version > NOTMUCH_DATABASE_VERSION) {\r
426 > +         fprintf (stderr,\r
427 > +                  "Error: Notmuch database at %s\n"\r
428 > +                  "       has a newer database format version (%u) than supported by this\n"\r
429 > +                  "       version of notmuch (%u).\n",\r
430 > +                  notmuch_path, version, NOTMUCH_DATABASE_VERSION);\r
431 > +         notmuch->mode = NOTMUCH_DATABASE_MODE_READ_ONLY;\r
432 > +         notmuch_database_destroy (notmuch);\r
433 > +         notmuch = NULL;\r
434 > +         status = NOTMUCH_STATUS_FILE_ERROR;\r
435 > +         goto DONE;\r
436 > +     }\r
437 > +\r
438 > +     /* Check features. */\r
439 > +     incompat_features = NULL;\r
440 > +     notmuch->features = _parse_features (\r
441 > +         local, notmuch->xapian_db->get_metadata ("features").c_str (),\r
442 > +         version, mode == NOTMUCH_DATABASE_MODE_READ_WRITE ? 'w' : 'r',\r
443 > +         &incompat_features);\r
444 > +     if (incompat_features) {\r
445 > +         fprintf (stderr,\r
446 > +                  "Error: Notmuch database at %s\n"\r
447 > +                  "       requires features (%s)\n"\r
448 > +                  "       not supported by this version of notmuch.\n",\r
449 > +                  notmuch_path, incompat_features);\r
450 > +         notmuch->mode = NOTMUCH_DATABASE_MODE_READ_ONLY;\r
451 > +         notmuch_database_destroy (notmuch);\r
452 > +         notmuch = NULL;\r
453 > +         status = NOTMUCH_STATUS_FILE_ERROR;\r
454 > +         goto DONE;\r
455 > +     }\r
456 > +\r
457 > +     /* Do we want an upgrade? */\r
458 > +     if (mode == NOTMUCH_DATABASE_MODE_READ_WRITE &&\r
459 > +         NOTMUCH_FEATURES_CURRENT & ~notmuch->features)\r
460 > +         notmuch->needs_upgrade = TRUE;\r
461 > +\r
462 >       notmuch->last_doc_id = notmuch->xapian_db->get_lastdocid ();\r
463 >       last_thread_id = notmuch->xapian_db->get_metadata ("last_thread_id");\r
464 >       if (last_thread_id.empty ()) {\r
465 > @@ -1077,6 +1200,7 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,\r
466 >                                                  double progress),\r
467 >                         void *closure)\r
468 >  {\r
469 > +    void *local = talloc_new (NULL);\r
470 >      Xapian::WritableDatabase *db;\r
471 >      struct sigaction action;\r
472 >      struct itimerval timerval;\r
473 > @@ -1226,6 +1350,8 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,\r
474 >       notmuch_query_destroy (query);\r
475 >      }\r
476 >  \r
477 > +    notmuch->features |= NOTMUCH_FEATURES_CURRENT;\r
478 > +    db->set_metadata ("features", _print_features (local, notmuch->features));\r
479 >      db->set_metadata ("version", STRINGIFY (NOTMUCH_DATABASE_VERSION));\r
480 >      db->flush ();\r
481 >  \r
482 > @@ -1302,6 +1428,7 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,\r
483 >       sigaction (SIGALRM, &action, NULL);\r
484 >      }\r
485 >  \r
486 > +    talloc_free (local);\r
487 >      return NOTMUCH_STATUS_SUCCESS;\r
488 >  }\r
489 >  \r
490 > -- \r
491 > 2.0.0\r
492 >\r
493 > _______________________________________________\r
494 > notmuch mailing list\r
495 > notmuch@notmuchmail.org\r
496 > http://notmuchmail.org/mailman/listinfo/notmuch\r