unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Bug: counting messages twice after excluding tags yields different results
@ 2016-08-31  8:23 Lucas
  2016-08-31  9:21 ` Franz Fellner
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Lucas @ 2016-08-31  8:23 UTC (permalink / raw)
  To: notmuch


[-- Attachment #1.1: Type: text/plain, Size: 1625 bytes --]

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

[-- Attachment #1.2: test.py --]
[-- Type: text/x-python, Size: 606 bytes --]

#!/usr/bin/python3

import sys
import notmuch

query_string = sys.argv[1] if len(sys.argv) > 1 else 'tag:inbox or tag:spam'
tag_string = sys.argv[2] if len(sys.argv) > 2 else 'spam'

database = notmuch.Database(mode=notmuch.Database.MODE.READ_ONLY)
query = 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

[-- Attachment #1.3: test.c --]
[-- Type: text/x-c, Size: 982 bytes --]

#include<stdio.h>
#include<notmuch.h>

#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 = 0;

  notmuch_database_open(DB_PATH, NOTMUCH_DATABASE_MODE_READ_WRITE, &database);
  query = 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;
}

[-- Attachment #2: signature --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

-----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-----

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-03-05 11:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-31  8:23 Bug: counting messages twice after excluding tags yields different results Lucas
2016-08-31  9:21 ` Franz Fellner
2016-08-31 11:16   ` Lucas Hoffmann
2016-08-31 12:20     ` David Bremner
2016-08-31 12:56       ` Franz Fellner
2016-09-01  1:16         ` David Bremner
2016-09-03 12:50           ` [PATCH] lib doc: group query functions, add disclaimer David Bremner
2016-09-05 10:57 ` Bug: counting messages twice after excluding tags yields different results David Bremner
2017-03-05 11:41 ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).