--- /dev/null
+Return-Path: <bremner@tesseract.cs.unb.ca>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 213026DE158D\r
+ for <notmuch@notmuchmail.org>; Sun, 7 Jun 2015 08:05:40 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.217\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.217 tagged_above=-999 required=5 tests=[AWL=0.207, \r
+ T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id MmdXu6vCCVV8 for <notmuch@notmuchmail.org>;\r
+ Sun, 7 Jun 2015 08:05:38 -0700 (PDT)\r
+Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net\r
+ [87.98.215.224])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 57FF36DE1502\r
+ for <notmuch@notmuchmail.org>; Sun, 7 Jun 2015 08:05:38 -0700 (PDT)\r
+Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim\r
+ 4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)\r
+ id 1Z1c88-0004qU-Pv; Sun, 07 Jun 2015 15:04:56 +0000\r
+Received: (nullmailer pid 7854 invoked by uid 1000); Sun, 07 Jun 2015\r
+ 15:02:11 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 03/10] lib: add public accessor for database from query\r
+Date: Sun, 7 Jun 2015 17:01:56 +0200\r
+Message-Id: <1433689323-7520-4-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1433689323-7520-1-git-send-email-david@tethera.net>\r
+References: <1433689323-7520-1-git-send-email-david@tethera.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\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, 07 Jun 2015 15:05:40 -0000\r
+\r
+This is to make it easier for clients of the library to update to the\r
+new error code returning versions of notmuch_query_search_messages\r
+---\r
+ lib/Makefile.local | 2 +-\r
+ lib/notmuch.h | 6 ++++++\r
+ lib/query.cc | 6 ++++++\r
+ 3 files changed, 13 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/lib/Makefile.local b/lib/Makefile.local\r
+index f9ecd50..aa76b61 100644\r
+--- a/lib/Makefile.local\r
++++ b/lib/Makefile.local\r
+@@ -11,7 +11,7 @@ LIBNOTMUCH_VERSION_MAJOR = 4\r
+ # the time of release for any additions to the library interface,\r
+ # (and when it is incremented, the release version of the library should\r
+ # be reset to 0).\r
+-LIBNOTMUCH_VERSION_MINOR = 2\r
++LIBNOTMUCH_VERSION_MINOR = 3\r
+ \r
+ # The release version the library interface. This should be incremented at\r
+ # the time of release if there have been no changes to the interface, (but\r
+diff --git a/lib/notmuch.h b/lib/notmuch.h\r
+index c2ada4b..46115c8 100644\r
+--- a/lib/notmuch.h\r
++++ b/lib/notmuch.h\r
+@@ -708,6 +708,12 @@ const char *\r
+ notmuch_query_get_query_string (notmuch_query_t *query);\r
+ \r
+ /**\r
++ * Return the notmuch database of this query. See notmuch_query_create.\r
++ */\r
++notmuch_database_t *\r
++notmuch_query_get_database (notmuch_query_t *query);\r
++\r
++/**\r
+ * Exclude values for notmuch_query_set_omit_excluded. The strange\r
+ * order is to maintain backward compatibility: the old FALSE/TRUE\r
+ * options correspond to the new\r
+diff --git a/lib/query.cc b/lib/query.cc\r
+index 9cedb6a..5275b5a 100644\r
+--- a/lib/query.cc\r
++++ b/lib/query.cc\r
+@@ -654,3 +654,9 @@ notmuch_query_count_threads (notmuch_query_t *query)\r
+ \r
+ return count;\r
+ }\r
++\r
++notmuch_database_t *\r
++notmuch_query_get_database (notmuch_query_t *query)\r
++{\r
++ return query->notmuch;\r
++}\r
+-- \r
+2.1.4\r
+\r