--- /dev/null
+Return-Path: <jani@nikula.org>\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 1BB04431FB6\r
+ for <notmuch@notmuchmail.org>; Tue, 28 Oct 2014 10:36:25 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 az0uozS+Ssur for <notmuch@notmuchmail.org>;\r
+ Tue, 28 Oct 2014 10:36:17 -0700 (PDT)\r
+Received: from mail-wg0-f44.google.com (mail-wg0-f44.google.com\r
+ [74.125.82.44]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ 422CE431FBC for <notmuch@notmuchmail.org>; Tue, 28 Oct 2014 10:36:17 -0700\r
+ (PDT)\r
+Received: by mail-wg0-f44.google.com with SMTP id y10so19954wgg.31\r
+ for <notmuch@notmuchmail.org>; Tue, 28 Oct 2014 10:36:16 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:subject:in-reply-to:references\r
+ :user-agent:date:message-id:mime-version:content-type;\r
+ bh=qfq7qQvWejqq1t3l6g5khj8MfYtpFTuXfTF349GV+5o=;\r
+ b=Q5Qghj3h7laJlto4elLkFSQfg8HgT/b3tgcEJJ3P5d+kJ5FYk2cUXZ2Xi8KhLMsoxC\r
+ JOu5DQ9BUC7LpdH5TzWEs/Vu+R6P8fJCjn89J/Z2rOrOcHuZwhFz9H2m4aqOtWuupDMR\r
+ TKixcapa1PYgvIkqdTQPslfMgya2m2FJ4Lg3jJ5GEXU2Mfx7i5v1AyhkKtazM2rnLEbB\r
+ kgB7KNzGaUsVC1fX27QxggV5aJAY3BlylxmIasMUNwHIRYiYcAZRax6/EXKU//n7eNmM\r
+ t/scMCaj/OSjOmfV2yUBfBHIjI8qsRc/gahJqihcdLWBBa3TV25i6zb2U0MZFl682odk\r
+ kjVQ==\r
+X-Gm-Message-State:\r
+ ALoCoQnL/OZLrw1EZRWaxclhJjboUSdrdWytpLJb/Hfq0kG7k2rxq9pNBCKKk+amaOfygflm2QOK\r
+X-Received: by 10.194.185.167 with SMTP id fd7mr6306758wjc.108.1414517774439; \r
+ Tue, 28 Oct 2014 10:36:14 -0700 (PDT)\r
+Received: from localhost (dsl-hkibrasgw2-58c36d-48.dhcp.inet.fi.\r
+ [88.195.109.48])\r
+ by mx.google.com with ESMTPSA id eu8sm11205161wic.1.2014.10.28.10.36.13\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Tue, 28 Oct 2014 10:36:13 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: Sergei Shilovsky <sshilovsky@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] lib: make notmuch_query_count_messages exact\r
+In-Reply-To: <1413304374-17997-1-git-send-email-jani@nikula.org>\r
+References: <1413298112-19912-2-git-send-email-sshilovsky@gmail.com>\r
+ <1413304374-17997-1-git-send-email-jani@nikula.org>\r
+User-Agent: Notmuch/0.18.2+148~g0318cd3 (http://notmuchmail.org) Emacs/24.3.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Tue, 28 Oct 2014 19:36:11 +0200\r
+Message-ID: <87lho0nlkk.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\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: Tue, 28 Oct 2014 17:36:25 -0000\r
+\r
+On Tue, 14 Oct 2014, Jani Nikula <jani@nikula.org> wrote:\r
+> Our tests have expected this to be exact all along, but maybe\r
+> inaccuracies only show up with big databases.\r
+\r
+>From my IRC logs on Thu Oct 16 2014\r
+\r
+j4ni olly: does this do what it claims?\r
+ http://mid.gmane.org/1413304374-17997-1-git-send-email-jani@nikula.org\r
+olly j4ni: not really\r
+olly if you don't set check at least it defaults to the number of\r
+ requested matches\r
+olly so the code part is effectively a no-op\r
+olly but the reported number will be exact already so the comment\r
+ changes are right\r
+olly i guess you could argue there's some merit in passing it explicitly\r
+ in case someone decreases the request number of results\r
+\r
+> ---\r
+> devel/TODO | 5 -----\r
+> lib/notmuch.h | 6 +++---\r
+> lib/query.cc | 7 ++++++-\r
+> 3 files changed, 9 insertions(+), 9 deletions(-)\r
+>\r
+> diff --git a/devel/TODO b/devel/TODO\r
+> index 1cf4089f1d93..116194d82ad1 100644\r
+> --- a/devel/TODO\r
+> +++ b/devel/TODO\r
+> @@ -188,11 +188,6 @@ into the shared-library interface.\r
+> Audit all libnotmuch entry points to ensure that all Xapian calls are\r
+> wrapped in a try/catch block.\r
+> \r
+> -Fix the "count" functionality to be exact as Olly explained in IRC:\r
+> -\r
+> - ojwb> cworth: if you set the check_at_least parameter to the\r
+> - database size, get_matches_estimated() will be exact\r
+> -\r
+> Fix the threading of a message that has a References: header but no\r
+> In-Reply-To: header (see id:"87lixxnxpb.fsf@yoom.home.cworth.org").\r
+> \r
+> diff --git a/lib/notmuch.h b/lib/notmuch.h\r
+> index dae041640fdb..6091082617e7 100644\r
+> --- a/lib/notmuch.h\r
+> +++ b/lib/notmuch.h\r
+> @@ -893,10 +893,10 @@ void\r
+> notmuch_threads_destroy (notmuch_threads_t *threads);\r
+> \r
+> /**\r
+> - * Return an estimate of the number of messages matching a search.\r
+> + * Return the number of messages matching a search.\r
+> *\r
+> - * This function performs a search and returns Xapian's best\r
+> - * guess as to number of matching messages.\r
+> + * This function performs a search and returns the number of matching\r
+> + * messages.\r
+> *\r
+> * If a Xapian exception occurs, this function may return 0 (after\r
+> * printing a message).\r
+> diff --git a/lib/query.cc b/lib/query.cc\r
+> index 60ff8bd9a39e..ce26e3f3e4ed 100644\r
+> --- a/lib/query.cc\r
+> +++ b/lib/query.cc\r
+> @@ -557,7 +557,12 @@ notmuch_query_count_messages (notmuch_query_t *query)\r
+> \r
+> enquire.set_query (final_query);\r
+> \r
+> - mset = enquire.get_mset (0, notmuch->xapian_db->get_doccount ());\r
+> + /*\r
+> + * Set the checkatleast parameter to the number of documents\r
+> + * in the database to make get_matches_estimated() exact.\r
+> + */\r
+> + mset = enquire.get_mset (0, notmuch->xapian_db->get_doccount (),\r
+> + notmuch->xapian_db->get_doccount ());\r
+> \r
+> count = mset.get_matches_estimated();\r
+> \r
+> -- \r
+> 2.1.1\r