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 276B76DE014D for ; Wed, 31 Aug 2016 01:24:04 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.819 X-Spam-Level: X-Spam-Status: No, score=-0.819 tagged_above=-999 required=5 tests=[AWL=0.001, 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 uez8et9rJ9TX for ; Wed, 31 Aug 2016 01:24:03 -0700 (PDT) Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by arlo.cworth.org (Postfix) with ESMTPS id F346B6DE0130 for ; Wed, 31 Aug 2016 01:24:02 -0700 (PDT) Received: by mail-wm0-f65.google.com with SMTP id i138so6402701wmf.3 for ; Wed, 31 Aug 2016 01:24:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:content-disposition:to:message-id:from:user-agent :subject:date; bh=4pfaEgLOhm3w9WnSQozcAmNc/ScEKdYAUMe4fDbVSgM=; b=PpSbpf0R5Nn7qeheRuDHbwM5mq5/Hmjc1X7aik7RR6ZthGU5/e4KufGb2ngsaxquPT mZn+0z8KRb+uuDaqpschSi/PsOMAKWqMO8+BKMd/Mc7VuaSbS8WIpUweKTXBiQaQKoTS v9fCqAvCYPg8HpRk+4/AEhreYrFsnEhCBNmPJvzmhVwYveBtNIaQ1qu4ERF3j6hsZGfW iU+cHo5+2U1N21wO/8O2Nj3vKLZf9WPlrWN9NrJQvdSuvdBhA/1XsD1/0jvJzT1ImLXc bkMMr8+UDnN56rlBMU04QiS9jWRCB1XZjq2hPwVXltb2E7G2/FMkBaXXvAZrqS5WN8wX dAYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:content-disposition:to:message-id :from:user-agent:subject:date; bh=4pfaEgLOhm3w9WnSQozcAmNc/ScEKdYAUMe4fDbVSgM=; b=BBKxqHG+PvZJSX0JfKsxlmE9Gqx0v973c7e0Y101bb6og5ehnYAeE4Yh2H2aqo7GWF ph8b42rd6xvdFuaDXeGzjWEiCgkhswmmU3B5PsFJ8cNNiGN16JxC5bnvzCLZwI8Rm/IF cYM3fC5Eevj4IkMqcGkud7C9saEF4ZSbD6ATkoxBJLHU/XX8lnxT9dlPdkPiyVrdl4GF tJk4AqiQ+tOjVBXVZgJrWJG4/urkYAdkd9kJ2pMsoDyM9GR8dvrQJKyOd7YNxqMM8w+D jkloLEZvEwsW6Rkyv1Z3iwev3KnZYIkNNKe5Hnu56Fe545z4PVuihUvj9vQts9+fynUZ +2qg== X-Gm-Message-State: AE9vXwNfsBQwWYCvMqRgvIq2Ccz9X1Y8y3YJe4RZZyZ9t53uLJ55UpUwF0qJZJOwtQSwIQ== X-Received: by 10.28.214.130 with SMTP id n124mr8108029wmg.37.1472631841141; Wed, 31 Aug 2016 01:24:01 -0700 (PDT) Received: from localhost (x55b58219.dyn.telefonica.de. [85.181.130.25]) by smtp.googlemail.com with ESMTPSA id o2sm43225143wjo.3.2016.08.31.01.24.00 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Aug 2016 01:24:00 -0700 (PDT) Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha256"; boundary="===============1712482432260395517==" MIME-Version: 1.0 Content-Disposition: inline To: notmuch@notmuchmail.org Message-ID: <147263183913.27784.12274024193186585889@mbp> From: Lucas User-Agent: alot/0.3.6 Subject: Bug: counting messages twice after excluding tags yields different results Date: Wed, 31 Aug 2016 10:23:59 +0200 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 08:24:04 -0000 --===============1712482432260395517== Content-Type: multipart/mixed; boundary="===============7866866641697575941==" MIME-Version: 1.0 --===============7866866641697575941== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=3D\"/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 --===============7866866641697575941== Content-Type: text/x-python; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="test.py" #!/usr/bin/python3 import sys import notmuch query_string =3D sys.argv[1] if len(sys.argv) > 1 else 'tag:inbox or tag:sp= am' tag_string =3D sys.argv[2] if len(sys.argv) > 2 else 'spam' database =3D notmuch.Database(mode=3Dnotmuch.Database.MODE.READ_ONLY) query =3D notmuch.Query(database, query_string) print("{} messages".format(query.count_messages())) print("{} messages".format(query.count_messages())) print("Exclude '{}'".format(tag_string)) query.exclude_tag(tag_string) print("{} messages".format(query.count_messages())) print("{} messages".format(query.count_messages())) del database --===============7866866641697575941== Content-Type: text/x-c; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="test.c" #include #include #ifndef DB_PATH # define DB_PATH "/home/luc/mail" #endif int main(int argc, char** argv) { notmuch_database_t* database; notmuch_query_t* query; unsigned int count =3D 0; notmuch_database_open(DB_PATH, NOTMUCH_DATABASE_MODE_READ_WRITE, &databas= e); query =3D notmuch_query_create(database, "is:inbox or is:spam"); notmuch_query_count_messages_st(query, &count); printf("1. run of notmuch_query_count_messages_st yields %d\n", count); notmuch_query_count_messages_st(query, &count); printf("2. run of notmuch_query_count_messages_st yields %d\n", count); printf("Excluding 'spam'\n"); notmuch_query_add_tag_exclude(query, "spam"); notmuch_query_count_messages_st(query, &count); printf("3. run of notmuch_query_count_messages_st yields %d\n", count); notmuch_query_count_messages_st(query, &count); printf("4. run of notmuch_query_count_messages_st yields %d\n", count); return 0; } --===============7866866641697575941==-- --===============1712482432260395517== MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Description: signature Content-Type: application/pgp-signature; name="signature.asc"; charset="us-ascii" -----BEGIN PGP SIGNATURE----- iQEcBAABCAAGBQJXxpQfAAoJEGC3H8cAGkGhsKEH/3LqETH9zo8u/IL5Rei/AxRO v6yaDkHXS6ziLkFW7mOmaLhXjn9Fsah15hBHnO42osWBJM7IWZdnJgmITnF13JTe 9hE/5raDtrnNZBE6c+0A47nhQwwWcykNnMEGTSyU+lKOfRCz40NGqizJvLh5/5ii 6LvvImnZ0/+06hqkKOgbKapyi6TcX0JXPUyx+l599OZxB+2SC+ujz7l3rgx6Gid5 jtYlt7OqMzHYoUOPPP1rq0ednmzIFnIBGKh3Q62dpUuf5W3FLYVV1O4vJcGmJYIb LyEhHyh/OKOmJg/KDG57RV2vkZs5sGWt3fejDgoM9mSSRc41mWrY5OYEWyCpgCY= =rCn3 -----END PGP SIGNATURE----- --===============1712482432260395517==--