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

* Re: Bug: counting messages twice after excluding tags yields different results
  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-09-05 10:57 ` Bug: counting messages twice after excluding tags yields different results David Bremner
  2017-03-05 11:41 ` David Bremner
  2 siblings, 1 reply; 9+ messages in thread
From: Franz Fellner @ 2016-08-31  9:21 UTC (permalink / raw)
  To: Lucas, notmuch

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 <luc.lists@gmail.com> 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
> 
> 
-- 

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

* Re: Bug: counting messages twice after excluding tags yields different results
  2016-08-31  9:21 ` Franz Fellner
@ 2016-08-31 11:16   ` Lucas Hoffmann
  2016-08-31 12:20     ` David Bremner
  0 siblings, 1 reply; 9+ messages in thread
From: Lucas Hoffmann @ 2016-08-31 11:16 UTC (permalink / raw)
  To: Franz Fellner, notmuch


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

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 <luc.lists@gmail.com> 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

[-- Attachment #1.2: example.c --]
[-- Type: text/x-c, Size: 1577 bytes --]

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

#ifndef DB_PATH
# define DB_PATH "/home/luc/mail"
#endif

#define print_error(success) \
  if (success != NOTMUCH_STATUS_SUCCESS) \
    printf("Notmuch error: %s\n", notmuch_status_to_string(success))

int main(int argc, char** argv) {
  notmuch_database_t* database = NULL;
  notmuch_query_t* query = NULL;
  unsigned int count = 0;
  notmuch_status_t success = NOTMUCH_STATUS_SUCCESS;
  char* query_string = "is:inbox or is:spam";
  char* exclude_string = "spam";

  if (argc > 1) {
    query_string = argv[1];
  }
  if (argc > 2) {
    exclude_string = argv[2];
  }

  success = notmuch_database_open(DB_PATH, NOTMUCH_DATABASE_MODE_READ_WRITE, &database);
  print_error(success);
  query = notmuch_query_create(database, query_string);

  success = notmuch_query_count_messages_st(query, &count);
  print_error(success);
  printf("1. run of notmuch_query_count_messages_st yields %d\n", count);
  success = 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 = notmuch_query_count_messages_st(query, &count);
  print_error(success);
  printf("3. run of notmuch_query_count_messages_st yields %d\n", count);
  success = 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;
}

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

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

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

* Re: Bug: counting messages twice after excluding tags yields different results
  2016-08-31 11:16   ` Lucas Hoffmann
@ 2016-08-31 12:20     ` David Bremner
  2016-08-31 12:56       ` Franz Fellner
  0 siblings, 1 reply; 9+ messages in thread
From: David Bremner @ 2016-08-31 12:20 UTC (permalink / raw)
  To: Lucas Hoffmann, Franz Fellner, notmuch

Lucas Hoffmann <luc.lists@gmail.com> writes:

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

Yes, it is documented in notmuch-config(1)

d

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

* Re: Bug: counting messages twice after excluding tags yields different results
  2016-08-31 12:20     ` David Bremner
@ 2016-08-31 12:56       ` Franz Fellner
  2016-09-01  1:16         ` David Bremner
  0 siblings, 1 reply; 9+ messages in thread
From: Franz Fellner @ 2016-08-31 12:56 UTC (permalink / raw)
  To: David Bremner, Lucas Hoffmann, notmuch

On Wed, 31 Aug 2016 09:20:52 -0300, David Bremner <david@tethera.net> wrote:
> Lucas Hoffmann <luc.lists@gmail.com> writes:
> 
> > 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.
> 
> Yes, it is documented in notmuch-config(1)

And for "destructiveness" see the implementation in lib/query.cc _notmuch_exclude_tags:
It replaces every matching tag in query_string and exclude_tags with an empty string ""
in the exclude terms. This most likely results in <match_all_documents> which can be
seen as a bug, if you want; removing would be better but also more expensive.

For a quick test run your test program with different queries/exclude_tags with
NOTMUCH_DEBUG_QUERY (man notmuch) set to a non-empty value and look what happens ;)

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

* Re: Bug: counting messages twice after excluding tags yields different results
  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
  0 siblings, 1 reply; 9+ messages in thread
From: David Bremner @ 2016-09-01  1:16 UTC (permalink / raw)
  To: Franz Fellner, Lucas Hoffmann, notmuch

Franz Fellner <alpine.art.de@gmail.com> writes:

> On Wed, 31 Aug 2016 09:20:52 -0300, David Bremner <david@tethera.net> wrote:
>> Lucas Hoffmann <luc.lists@gmail.com> writes:
>> 
>> > 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.
>> 
>> Yes, it is documented in notmuch-config(1)
>
> And for "destructiveness" see the implementation in lib/query.cc _notmuch_exclude_tags:
> It replaces every matching tag in query_string and exclude_tags with an empty string ""
> in the exclude terms. This most likely results in <match_all_documents> which can be
> seen as a bug, if you want; removing would be better but also more expensive.

Maybe more programming effort, but I guess not more expensive in
performance? It is not clear that this is worth fixing, since the
destructiveness makes re-using queries inadvisable.  Are there any
non-destructive operations on queries (that it seems reasonable to
commit to being non-destructive)? Otherwise, I guess we could just add a
blanket warning to the API docs.

d

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

* [PATCH] lib doc: group query functions, add disclaimer
  2016-09-01  1:16         ` David Bremner
@ 2016-09-03 12:50           ` David Bremner
  0 siblings, 0 replies; 9+ messages in thread
From: David Bremner @ 2016-09-03 12:50 UTC (permalink / raw)
  To: David Bremner, Franz Fellner, Lucas Hoffmann, notmuch

The destructiveness is somewhat surprising, so emphasize it with an
extra remark in the docs.
---
 lib/notmuch.h | 144 +++++++++++++++++++++++++++++++---------------------------
 1 file changed, 78 insertions(+), 66 deletions(-)

diff --git a/lib/notmuch.h b/lib/notmuch.h
index 2faa146..954060d 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -686,6 +686,70 @@ notmuch_tags_t *
 notmuch_database_get_all_tags (notmuch_database_t *db);
 
 /**
+ * Is the given 'threads' iterator pointing at a valid thread.
+ *
+ * When this function returns TRUE, notmuch_threads_get will return a
+ * valid object. Whereas when this function returns FALSE,
+ * notmuch_threads_get will return NULL.
+ *
+ * If passed a NULL pointer, this function returns FALSE
+ *
+ * See the documentation of notmuch_query_search_threads for example
+ * code showing how to iterate over a notmuch_threads_t object.
+ */
+notmuch_bool_t
+notmuch_threads_valid (notmuch_threads_t *threads);
+
+/**
+ * Get the current thread from 'threads' as a notmuch_thread_t.
+ *
+ * Note: The returned thread belongs to 'threads' and has a lifetime
+ * identical to it (and the query to which it belongs).
+ *
+ * See the documentation of notmuch_query_search_threads for example
+ * code showing how to iterate over a notmuch_threads_t object.
+ *
+ * If an out-of-memory situation occurs, this function will return
+ * NULL.
+ */
+notmuch_thread_t *
+notmuch_threads_get (notmuch_threads_t *threads);
+
+/**
+ * Move the 'threads' iterator to the next thread.
+ *
+ * If 'threads' is already pointing at the last thread then the
+ * iterator will be moved to a point just beyond that last thread,
+ * (where notmuch_threads_valid will return FALSE and
+ * notmuch_threads_get will return NULL).
+ *
+ * See the documentation of notmuch_query_search_threads for example
+ * code showing how to iterate over a notmuch_threads_t object.
+ */
+void
+notmuch_threads_move_to_next (notmuch_threads_t *threads);
+
+/**
+ * Destroy a notmuch_threads_t object.
+ *
+ * It's not strictly necessary to call this function. All memory from
+ * the notmuch_threads_t object will be reclaimed when the
+ * containing query object is destroyed.
+ */
+void
+notmuch_threads_destroy (notmuch_threads_t *threads);
+
+/**
+ * @name Queries
+ *
+ * @remark The caller should assume that any notmuch_query_* function
+ * without an appropriate const declaration is destructive in its
+ * query argument. In particular calling
+ * notmuch_query_{count,search}_* on the same query may lead to
+ * surprising results.
+ */
+/**@{*/
+/**
  * Create a new query for 'database'.
  *
  * Here, 'database' should be an open database, (see
@@ -736,6 +800,19 @@ typedef enum {
     NOTMUCH_SORT_UNSORTED
 } notmuch_sort_t;
 
+
+/**
+ * Destroy a notmuch_query_t along with any associated resources.
+ *
+ * This will in turn destroy any notmuch_threads_t and
+ * notmuch_messages_t objects generated by this query, (and in
+ * turn any notmuch_thread_t and notmuch_message_t objects generated
+ * from those results, etc.), if such objects haven't already been
+ * destroyed.
+ */
+void
+notmuch_query_destroy (notmuch_query_t *query);
+
 /**
  * Return the query_string of this query. See notmuch_query_create.
  */
@@ -927,72 +1004,6 @@ notmuch_messages_t *
 notmuch_query_search_messages (notmuch_query_t *query);
 
 /**
- * Destroy a notmuch_query_t along with any associated resources.
- *
- * This will in turn destroy any notmuch_threads_t and
- * notmuch_messages_t objects generated by this query, (and in
- * turn any notmuch_thread_t and notmuch_message_t objects generated
- * from those results, etc.), if such objects haven't already been
- * destroyed.
- */
-void
-notmuch_query_destroy (notmuch_query_t *query);
-
-/**
- * Is the given 'threads' iterator pointing at a valid thread.
- *
- * When this function returns TRUE, notmuch_threads_get will return a
- * valid object. Whereas when this function returns FALSE,
- * notmuch_threads_get will return NULL.
- *
- * If passed a NULL pointer, this function returns FALSE
- *
- * See the documentation of notmuch_query_search_threads for example
- * code showing how to iterate over a notmuch_threads_t object.
- */
-notmuch_bool_t
-notmuch_threads_valid (notmuch_threads_t *threads);
-
-/**
- * Get the current thread from 'threads' as a notmuch_thread_t.
- *
- * Note: The returned thread belongs to 'threads' and has a lifetime
- * identical to it (and the query to which it belongs).
- *
- * See the documentation of notmuch_query_search_threads for example
- * code showing how to iterate over a notmuch_threads_t object.
- *
- * If an out-of-memory situation occurs, this function will return
- * NULL.
- */
-notmuch_thread_t *
-notmuch_threads_get (notmuch_threads_t *threads);
-
-/**
- * Move the 'threads' iterator to the next thread.
- *
- * If 'threads' is already pointing at the last thread then the
- * iterator will be moved to a point just beyond that last thread,
- * (where notmuch_threads_valid will return FALSE and
- * notmuch_threads_get will return NULL).
- *
- * See the documentation of notmuch_query_search_threads for example
- * code showing how to iterate over a notmuch_threads_t object.
- */
-void
-notmuch_threads_move_to_next (notmuch_threads_t *threads);
-
-/**
- * Destroy a notmuch_threads_t object.
- *
- * It's not strictly necessary to call this function. All memory from
- * the notmuch_threads_t object will be reclaimed when the
- * containing query object is destroyed.
- */
-void
-notmuch_threads_destroy (notmuch_threads_t *threads);
-
-/**
  * Return the number of messages matching a search.
  *
  * This function performs a search and returns the number of matching
@@ -1059,6 +1070,7 @@ NOTMUCH_DEPRECATED(4,3)
 unsigned int
 notmuch_query_count_threads (notmuch_query_t *query);
 
+/**@}*/
 /**
  * Get the thread ID of 'thread'.
  *
-- 
2.9.3

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

* Re: Bug: counting messages twice after excluding tags yields different results
  2016-08-31  8:23 Bug: counting messages twice after excluding tags yields different results Lucas
  2016-08-31  9:21 ` Franz Fellner
@ 2016-09-05 10:57 ` David Bremner
  2017-03-05 11:41 ` David Bremner
  2 siblings, 0 replies; 9+ messages in thread
From: David Bremner @ 2016-09-05 10:57 UTC (permalink / raw)
  To: Lucas, notmuch

Lucas <luc.lists@gmail.com> writes:

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

I noticed that notmuch-reply.c actually uses a query in this way
(calling search after calling count on the same query). So this is a
bug, either in the query routines, or in notmuch-reply.

d

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

* Re: Bug: counting messages twice after excluding tags yields different results
  2016-08-31  8:23 Bug: counting messages twice after excluding tags yields different results Lucas
  2016-08-31  9:21 ` Franz Fellner
  2016-09-05 10:57 ` Bug: counting messages twice after excluding tags yields different results David Bremner
@ 2017-03-05 11:41 ` David Bremner
  2 siblings, 0 replies; 9+ messages in thread
From: David Bremner @ 2017-03-05 11:41 UTC (permalink / raw)
  To: Lucas, notmuch

Lucas <luc.lists@gmail.com> writes:

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

This bug should be fixed in commit  dfacfe14, which will be part of
notmuch 0.24. Thanks for your clear report and test case.

d

^ 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).