--- /dev/null
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id AB503431FBC\r
+ for <notmuch@notmuchmail.org>; Sat, 23 Aug 2014 17:59:00 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id 2Hr1+1xpMa5l for <notmuch@notmuchmail.org>;\r
+ Sat, 23 Aug 2014 17:58:53 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-1.mit.edu (dmz-mailsec-scanner-1.mit.edu\r
+ [18.9.25.12])\r
+ (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 84C23431FB6\r
+ for <notmuch@notmuchmail.org>; Sat, 23 Aug 2014 17:58:53 -0700 (PDT)\r
+X-AuditID: 1209190c-f795e6d000006c66-ef-53f938cc5799\r
+Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
+ (using TLS with cipher AES256-SHA (256/256 bits))\r
+ (Client did not present a certificate)\r
+ by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 94.84.27750.CC839F35; Sat, 23 Aug 2014 20:58:52 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+ by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id s7O0wqZq009560; \r
+ Sat, 23 Aug 2014 20:58:52 -0400\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+ (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s7O0woqS027618\r
+ (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
+ Sat, 23 Aug 2014 20:58:51 -0400\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1XLM8w-0001tA-HW; Sat, 23 Aug 2014 20:58:50 -0400\r
+From: Austin Clements <amdragon@mit.edu>\r
+To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v3 04/13] lib: Database version 3: Introduce fine-grained\r
+ "features"\r
+In-Reply-To: <87ppfqsv8s.fsf@maritornes.cs.unb.ca>\r
+References: <1406859003-11561-1-git-send-email-amdragon@mit.edu>\r
+ <1406859003-11561-5-git-send-email-amdragon@mit.edu>\r
+ <87ppfqsv8s.fsf@maritornes.cs.unb.ca>\r
+User-Agent: Notmuch/0.18.1+76~g58c9570 (http://notmuchmail.org) Emacs/23.4.1\r
+ (i486-pc-linux-gnu)\r
+Date: Sat, 23 Aug 2014 20:58:50 -0400\r
+Message-ID: <87fvgmg0tx.fsf@awakening.csail.mit.edu>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFnrAIsWRmVeSWpSXmKPExsUixG6nonvG4mewwdJflhY3WrsZLa7fnMns\r
+ wOTxbNUtZo8th94zBzBFcdmkpOZklqUW6dslcGXMnfybueC3cMX0Ca8ZGxif83cxcnJICJhI\r
+ LPv7gQXCFpO4cG89WxcjF4eQwGwmiU0r1rBAOBsZJZbfvscOUiUkcJpJ4sQKLojEEkaJ3lMN\r
+ YAk2AQ2J37cWM4HYIgJ2Ej0XzoPFhQUiJOZ83wO2glPASOLOsmmsEINmM0q07UoFsUUFEiRO\r
+ 9h9g7GLk4GARUJXo/c4FEuYFuu7t0jZ2CFtQ4uTMJ2BjmAW0JG78e8k0gVFgFpLULCSpBYxM\r
+ qxhlU3KrdHMTM3OKU5N1i5MT8/JSi3QN9XIzS/RSU0o3MYICklOSZwfjm4NKhxgFOBiVeHg/\r
+ XPwRLMSaWFZcmXuIUZKDSUmU95XGz2AhvqT8lMqMxOKM+KLSnNTiQ4wSHMxKIrzFZkA53pTE\r
+ yqrUonyYlDQHi5I471trq2AhgfTEktTs1NSC1CKYrAwHh5IE70xzoEbBotT01Iq0zJwShDQT\r
+ ByfIcB6g4Y9BaniLCxJzizPTIfKnGBWlxHk3giQEQBIZpXlwvbCE8YpRHOgVYd6VIFU8wGQD\r
+ 1/0KaDAT0ODpM76CDC5JREhJNTDanjqs9WKrRoZorE7+kmNHBfintS9/HbN3Ildo5raZlzfI\r
+ PmJT75z0fhOz8QXu9PJ3N2oVF5bNOrCoW0zs0uTpKz/sFZKZ0N/0T9Hi2/pXy1NyjB7/W7Ri\r
+ /vfpC9bcrPr46+aXP5win9bsZTWPTLvy6tER6Zt3XzfcWVraFSF48cuxTde/nPc+ZaHEUpyR\r
+ aKjFXFScCAB2WsD38wIAAA==\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 24 Aug 2014 00:59:00 -0000\r
+\r
+On Sat, 23 Aug 2014, David Bremner <david@tethera.net> wrote:\r
+> Austin Clements <amdragon@MIT.EDU> writes:\r
+>> \r
+>> + /* Bit mask of features used by this database. Features are\r
+>> + * named, independent aspects of the database schema. This is a\r
+>> + * bitwise-OR of NOTMUCH_FEATURE_* values (below). */\r
+>> + unsigned int features;\r
+>\r
+> Should we be using a fixed size integer (uint_32t or whatever) for\r
+> features? iirc the metadata in the database is actually a string, so I\r
+> guess arbitrary precision there.\r
+\r
+Right; this doesn't matter for the on-disk format because these don't\r
+appear on disk. But you're right that in principle we could overflow\r
+this, leading to subtle bugs. I moved the enum above struct\r
+_notmuch_database, gave it a name and bitwise operators for C++, and\r
+used that enum name everywhere, so precision should never be a problem.\r
+\r
+>> +/* Bit masks for _notmuch_database::features. */\r
+>> +enum {\r
+>> + /* If set, file names are stored in "file-direntry" terms. If\r
+>> + * unset, file names are stored in document data.\r
+>> + *\r
+>> + * Introduced: version 1. Implementation support: both for read;\r
+>> + * required for write. */\r
+>> + NOTMUCH_FEATURE_FILE_TERMS = 1 << 0,\r
+>\r
+> I agree with Jani that the Implementation support: part is a bit\r
+> mystifying without the commit message. Maybe part of the commit message\r
+> could migrate here? Or maybe just add a pointer to the comment in database.cc.\r
+\r
+I stripped these out because I don't think they're maintainable. See my\r
+reply to Jani.\r
+\r
+>> + if (! *incompat_out)\r
+>\r
+> Should we support passing NULL for incompat_out? or at least check for\r
+> it?\r
+\r
+Added a guard so it's safe to pass NULL.\r
+\r
+>> @@ -1048,7 +1164,8 @@ notmuch_database_get_version (notmuch_database_t *notmuch)\r
+>> notmuch_bool_t\r
+>> notmuch_database_needs_upgrade (notmuch_database_t *notmuch)\r
+>> {\r
+>> - return notmuch->needs_upgrade;\r
+>> + return notmuch->mode == NOTMUCH_DATABASE_MODE_READ_WRITE &&\r
+>> + (NOTMUCH_FEATURES_CURRENT & ~notmuch->features);\r
+>> }\r
+>\r
+> Maybe I'm not thinking hard enough here, but how does this deal with a\r
+> feature that is needed to open a database in read only mode? Maybe it\r
+> needs a comment for people not as clever as Austin ;).\r
+\r
+I'm not quite sure what you mean. notmuch_database_needs_upgrade\r
+returns false for read-only databases because you can't upgrade a\r
+read-only database. This was true before this patch, too, though it was\r
+less obvious. (Maybe that's not what you're asking?)\r