From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 48AD66DE014D for ; Wed, 31 Aug 2016 02:17:52 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.503 X-Spam-Level: X-Spam-Status: No, score=-0.503 tagged_above=-999 required=5 tests=[AWL=0.317, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 23PyJvrQKMvJ for ; Wed, 31 Aug 2016 02:17:50 -0700 (PDT) Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) by arlo.cworth.org (Postfix) with ESMTPS id 84D376DE0130 for ; Wed, 31 Aug 2016 02:17:50 -0700 (PDT) Received: by mail-wm0-f47.google.com with SMTP id 1so28922581wmz.1 for ; Wed, 31 Aug 2016 02:17:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:subject:to:references:in-reply-to:mime-version:date:message-id; bh=ydkYB5L3mkbk5yarSLLvhu7579T5svGKH9f3ZN2oh4k=; b=nb5UI0yzKcsiZE0TaGNpeHayBkfs1SdXnJePQq6wiD7CZqtl3pF5/Gdzmiqm0WUUov 3bJ7oSPWK+j+y3sPXNv3K9gc9b4j/0p2xVvpclcYJ7E1urfenm57dAIM/PJX3lp+EECN opncRZyTlhpUEcc3EXs7z2I64ti1EFCJrKdoKx8ze7Np4z0EcCOcuj55GTttPN+tIpH0 Z8XQbL0iC6xpGPZa83loKGDUEwiaL2/GmalUtYQXWk3mmaTrTqgzn1UQruKqLwpC6IGK ee/vVY/5RqUnYZCTPZe4sGR10mxOtka9R9h6eC++5H/hzaLdce6M9LEQB9dFgS8XCucD NVvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:subject:to:references:in-reply-to :mime-version:date:message-id; bh=ydkYB5L3mkbk5yarSLLvhu7579T5svGKH9f3ZN2oh4k=; b=QYCIbeunR8O3CBvBah2IFle00mX1xIA/P+CI4O/DTL/IbbwLxsjtB5FDst9YYwskS9 FQTvI7p2qEqFO0sAtPHO6mozfTqVr0BdAUNH56mMoMDWbfUyWHtvqNtoeJdOUr0v0CMn /0O2CzuOsZoayHnJurkBp9XJeDq1fxBnNMXgowXD6ZcKrff9kRT89umKLY+If4Aem4pB 5oHX6xW7UNk5oNwNe6DODfd3quzL743VUGJEFWYm7NGuhnTee46UxFoGGTVcZ7p5rNC2 SDR79M5zkMK9NLU8M7pTX2A95uCy9jouLEVktMz2F9XNLTS6XKGlq7emrIl0N463ZEkL ewwg== X-Gm-Message-State: AE9vXwOrvjtLF9kGEz4E+XFe5Ii0c+syFAQLS7q7GTqHTXt9TjYhNYrGyB/TQqcXYuz8FA== X-Received: by 10.194.84.234 with SMTP id c10mr7963939wjz.34.1472635068684; Wed, 31 Aug 2016 02:17:48 -0700 (PDT) Received: from localhost (p579BAD04.dip0.t-ipconnect.de. [87.155.173.4]) by smtp.gmail.com with ESMTPSA id n131sm22656776wmd.3.2016.08.31.02.17.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Aug 2016 02:17:47 -0700 (PDT) From: Franz Fellner Subject: Re: Bug: counting messages twice after excluding tags yields different results To: Lucas , notmuch@notmuchmail.org References: <147263183913.27784.12274024193186585889@mbp> In-Reply-To: <147263183913.27784.12274024193186585889@mbp> MIME-Version: 1.0 Date: Wed, 31 Aug 2016 09:21:18 +0000 Message-Id: <1.472.635.278-ner-3.934@TP_L520> Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Aug 2016 09:17:52 -0000 Your problem: the example sucks ;) If the query searches for a tag you also have in exclude_tags (in your case: spam) the exclude gets ignored. Change your query to just "is:inbox" and magically "spam" really gets excluded. However it is better to create fresh query objects for each new query. I remember there are operations on query objects that are destructive. That's why users of the notmuch API usually create seperate queriy objects for counting messages/threads and getting the results. On Wed, 31 Aug 2016 10:23:59 +0200, Lucas wrote: > Dear list members, > > I think I found a bug or at least undocumented behaviour in the notmuch > library. I would like to report this here. Originally I found the bug > in the python library but I attached a c program that shows the same > behaviour. I am running notmuch version 0.22.1 from the Arch Linux > repositories. > > The setup: > 1. chose a query string, e.g. "is:inbox or is:spam" > 2. chose a tag to exclude that is matched by the query, e.g. "spam" > 3. open the database > 4. create a query > 5. check the message or thread count any number of times > 6. exclude the tag from the query > 7. check the message or thread count any number of times > > The result: > - In step 5 the result stays the same if I repeatedly call > notmuch_query_count_messages_st or query.count_messages. > - In step 7 the count is different between the first call and all > subsequent calls. But neither seems correct to me. I always get the > same number as in step 5 for the first call and 0 afterwards. > > Expected result: > - subsequent calls to notmuch_query_count_messages_st or > query.count_messages should yield the same result > - the exclusion should change the count to the actual amount (for > "is:inbox or is:spam" I get 891 and for a plain "is:inbox" I get 58, > which never shows up in step 7) > > Attached you can find a python and a c program that exhibit this > behaviour. Please compile the c program with > > cc -DDB_PATH=\"/path/to/your/mail\" -lnotmuch test.c > > My question: > Is this documented somewhere? Is it actually a bug or is it already > fixed in a newer version? > > Thank you for developing notmuch! > > Lucas > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > https://notmuchmail.org/mailman/listinfo/notmuch > > --