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 A2DE86DE014D for ; Wed, 31 Aug 2016 04:16:47 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.64 X-Spam-Level: X-Spam-Status: No, score=-0.64 tagged_above=-999 required=5 tests=[AWL=0.180, 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 weKYq4BfvFMd for ; Wed, 31 Aug 2016 04:16:47 -0700 (PDT) Received: from mail-wm0-f45.google.com (mail-wm0-f45.google.com [74.125.82.45]) by arlo.cworth.org (Postfix) with ESMTPS id 928656DE0130 for ; Wed, 31 Aug 2016 04:16:46 -0700 (PDT) Received: by mail-wm0-f45.google.com with SMTP id c133so27596344wmd.1 for ; Wed, 31 Aug 2016 04:16:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:content-disposition:from:user-agent:to:references :in-reply-to:message-id:subject:date; bh=ir6n6rg3I3Xwt6vzkf7P7vRCUXiIEJTBpVorFNB2hUk=; b=YWSUBTf2KlGssWZPwGLX6BQztRNnDWAGOMgSvWnsE8DwK1lctSszb/Rx9BJfErpHXJ X21hLGUUl+IbJhXkKpGMgX90pXY/7S/Kf8KZSajgdYj6dOq+qbD5PrJCE4YPZ2uv645n 4+1gSl+BEeliBeE/hGOSedmWqXHCKTJ9SAHH0CrDmNyICVmf41KgE5rb0F++8k1H8zdH ixk9OuBzi0N667ZrRf4f02L2+nSYj/WGF21XciwRv5LaguxZRnCekR1yQ4p4tNCSm2EZ BngBPnOKiGK61AJ8JlOw8xKO75QBwt6nUoQ9L9h0l9st8/HYdFC03/db0N/XU0vjw3rc vGJA== 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:from:user-agent :to:references:in-reply-to:message-id:subject:date; bh=ir6n6rg3I3Xwt6vzkf7P7vRCUXiIEJTBpVorFNB2hUk=; b=mhqZlgwPzw9G6QwGiLU3voHf6cT6JtBvx/6l2f32ptBSa3UqoEiZeQt0FojA9DcB/b bY3SocjsobDL+Ga0JndvR4WmhM1BpWWqznKGxA2oflfTOL1rXXXLxXvl+FL81MzILAr8 0O9BN/4umBPlAFbxs6HsEOTBQToMaYk6TfTXSkaW7CrCvvM/19ITYTRaT4IgJW4vNcmH o34OA4Ry4ntVVZMG/PdIp+uMTUFsjIt4eLnTYP/NHkEo9H48/VIarf5EjhRVA1LxsGt/ 6/MnIbf5swa6mRaPo3R1zsvW7OAOkAHY6q9arDym6cbH+LO93XJSOttchw0Hs1PvC4Ro ZdRA== X-Gm-Message-State: AE9vXwOnWVySV6qdzrDL4rumoZUtKMMCyndcvb+oQ1bBAwh6jWjf1hYwSTZBCyu1nG1eCw== X-Received: by 10.194.238.42 with SMTP id vh10mr9303933wjc.111.1472642204356; Wed, 31 Aug 2016 04:16:44 -0700 (PDT) Received: from localhost (x55b58219.dyn.telefonica.de. [85.181.130.25]) by smtp.googlemail.com with ESMTPSA id wr2sm4075039wjb.12.2016.08.31.04.16.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Aug 2016 04:16:43 -0700 (PDT) Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha256"; boundary="===============4168694334014740833==" MIME-Version: 1.0 Content-Disposition: inline From: Lucas Hoffmann User-Agent: alot/0.3.6 To: Franz Fellner , notmuch@notmuchmail.org References: <147263183913.27784.12274024193186585889@mbp> <1.472.635.278-ner-3.934@TP_L520> In-Reply-To: <1.472.635.278-ner-3.934@TP_L520> Message-ID: <147264220228.31988.2941265478027864869@mbp> Subject: Re: Bug: counting messages twice after excluding tags yields different results Date: Wed, 31 Aug 2016 13:16:42 +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 11:16:47 -0000 --===============4168694334014740833== Content-Type: multipart/mixed; boundary="===============2490117944300029223==" MIME-Version: 1.0 --===============2490117944300029223== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Thank you Franz, sadly your reply did not convince me: Quoting Franz Fellner (2016-08-31 11:21:18) > Your problem: the example sucks ;) No, I must object :( > If the query searches for a tag you also have in exclude_tags (in your > case: spam) the exclude gets ignored. Is that documented? Because it is not what I would expect. You might be right as I see this when counting messages for the first time after excluding the tag. But from the second run on I get a count of 0 which is not explained by your comment. > Change your query to just "is:inbox" and magically "spam" really gets > excluded. I know (and mentioned below, step 2) that this bug only appears when the tag is also mentioned in the query. (For the record it also happens when the query is "is:inbox and not is:spam".) I originally found the bug when writing a program that reads the default config file and uses its search.exclude_tags value. Additionally the user might set a query and exclusion tags from the command line. So even if I can fix the example the problem persists. So I would rather have the notmuch library be correctly documented or behave in an sane way than manually parse and fix queries and exclude tags. Please note that my example is just that: an example to demonstrate the behaviour. So I don't think the correct answer to my report is "fix your query/example". > 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. Again: Is that documented? Strangely enough counting is non destructive before calling notmuch_query_add_tag_exclude. And if any of these operations is destructive I would expect any further calls to the same function to return an error. I updated the example c program to check for this but did not see any error. The new version is attached. Hopefully I was able to clarify my concern. Best wishes, Lucas > 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=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 --===============2490117944300029223== Content-Type: text/x-c; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="example.c" #include #include #ifndef DB_PATH # define DB_PATH "/home/luc/mail" #endif #define print_error(success) \ if (success !=3D NOTMUCH_STATUS_SUCCESS) \ printf("Notmuch error: %s\n", notmuch_status_to_string(success)) int main(int argc, char** argv) { notmuch_database_t* database =3D NULL; notmuch_query_t* query =3D NULL; unsigned int count =3D 0; notmuch_status_t success =3D NOTMUCH_STATUS_SUCCESS; char* query_string =3D "is:inbox or is:spam"; char* exclude_string =3D "spam"; if (argc > 1) { query_string =3D argv[1]; } if (argc > 2) { exclude_string =3D argv[2]; } success =3D notmuch_database_open(DB_PATH, NOTMUCH_DATABASE_MODE_READ_WRI= TE, &database); print_error(success); query =3D notmuch_query_create(database, query_string); success =3D notmuch_query_count_messages_st(query, &count); print_error(success); printf("1. run of notmuch_query_count_messages_st yields %d\n", count); success =3D notmuch_query_count_messages_st(query, &count); print_error(success); printf("2. run of notmuch_query_count_messages_st yields %d\n", count); printf("Excluding '%s'\n", exclude_string); notmuch_query_add_tag_exclude(query, exclude_string); success =3D notmuch_query_count_messages_st(query, &count); print_error(success); printf("3. run of notmuch_query_count_messages_st yields %d\n", count); success =3D notmuch_query_count_messages_st(query, &count); print_error(success); printf("4. run of notmuch_query_count_messages_st yields %d\n", count); return 0; } --===============2490117944300029223==-- --===============4168694334014740833== 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----- iQEcBAABCAAGBQJXxryaAAoJEGC3H8cAGkGhyvwH/1/F2c/PkCyQK8OCvSi08ZuG wOew9123TxTOpLBRheoAO1aWqEVMONjm8cIRhrHqaZNSVyKjKD1snsiNwhmF42+B dhBC3ufxb0x/FEtFxWALJfG8geDJASLbDEu7RQCfnoXhGLze0FQ/SqbTT5pa5aJB bBMe2UKKoXog2oA/FjZxMMI4FIWjbQXHoVus43WYgVT3LRPEcpa6IzovYGVU7vwR ExDFihEig/L1vgJvT4CqJBRpQGyKekUH/8eBKPmjarFG4zhVf7c0uW5KvboExTKx dZWSYBlJb/ALqi/yfP8eD6tnxIos/uJoblm7Srv39Jb1LQmk5n/B3mnQopdxyTI= =mU8F -----END PGP SIGNATURE----- --===============4168694334014740833==--