[Dovecot] SEARCH NOT not working
I think I've found the source of a bug which I first saw when running dovecot and pine (or alpine), which I finally tracked down by doing a protocol trace. In the IMAP session, the SEARCH command appears to have a problem with sets of messages and/or the NOT operator.
Probably the best way to show this is by doing operations on a folder with ten messages in it.
a select ten
FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted.
10 EXISTS
0 RECENT
OK [UNSEEN 1] First unseen.
OK [UIDVALIDITY 1190450101] UIDs valid
OK [UIDNEXT 11] Predicted next UID a OK [READ-WRITE] Select completed.
Now, start doing some basic searches using message sets:
b search (1:10)
SEARCH 1 2 3 4 5 6 7 8 9 10 b OK Search completed.
OK, so far so good. Try the inverse:
c search not (1:10)
SEARCH c OK Search completed.
OK.
d search not (1,10)
SEARCH d OK Search completed.
Hmm, should have output 2..9.
e search not (2,10)
SEARCH 1 e OK Search completed.
Hmm.. that should have been 1, 3..9.
f search not (2:10)
SEARCH 1 f OK Search completed.
OK, expected.
g search not (1,9)
SEARCH 10 g OK Search completed.
Seems to affect other end of the range as well.
h search not (2,9)
SEARCH 1 3 4 5 6 7 8 10 h OK Search completed.
OK working again.
On Fri, 2007-09-21 at 23:57 -1000, Julian Cowley wrote:
I think I've found the source of a bug which I first saw when running dovecot and pine (or alpine), which I finally tracked down by doing a protocol trace. In the IMAP session, the SEARCH command appears to have a problem with sets of messages and/or the NOT operator.
Thanks, fixed: http://hg.dovecot.org/dovecot-1.0/rev/d144e54f09e6
On Sat, 22 Sep 2007, Timo Sirainen wrote:
On Fri, 2007-09-21 at 23:57 -1000, Julian Cowley wrote:
I think I've found the source of a bug which I first saw when running dovecot and pine (or alpine), which I finally tracked down by doing a protocol trace. In the IMAP session, the SEARCH command appears to have a problem with sets of messages and/or the NOT operator.
Thanks, fixed: http://hg.dovecot.org/dovecot-1.0/rev/d144e54f09e6
Thanks. That fixed all of the test cases I had, but now I've found something new when using NOT on overlapping ranges:
a search 1:*
- SEARCH 1 2 3 4 5 6 7 8 9 10 a OK Search completed.
b search 1:7 4:10
- SEARCH 4 5 6 7 b OK Search completed.
c search not (1:7 4:10)
- SEARCH c OK Search completed.
On Sat, 2007-09-22 at 22:14 -1000, Julian Cowley wrote:
On Sat, 22 Sep 2007, Timo Sirainen wrote:
On Fri, 2007-09-21 at 23:57 -1000, Julian Cowley wrote:
I think I've found the source of a bug which I first saw when running dovecot and pine (or alpine), which I finally tracked down by doing a protocol trace. In the IMAP session, the SEARCH command appears to have a problem with sets of messages and/or the NOT operator.
Thanks, fixed: http://hg.dovecot.org/dovecot-1.0/rev/d144e54f09e6
Thanks. That fixed all of the test cases I had, but now I've found something new when using NOT on overlapping ranges:
Perhaps I should have just dropped the NOT optimizations, but instead I added more..
http://hg.dovecot.org/dovecot-1.0/rev/fa89431f893e http://hg.dovecot.org/dovecot-1.0/rev/92b2bd6b6c2d http://hg.dovecot.org/dovecot-1.0/rev/678626efb942
I've tested this by having a perl script generate thousands of SEARCH commands randomly and verifying that Dovecot's output matches UW-IMAP's output.
On Sun, 23 Sep 2007, Timo Sirainen wrote:
On Sat, 2007-09-22 at 22:14 -1000, Julian Cowley wrote:
Thanks. That fixed all of the test cases I had, but now I've found something new when using NOT on overlapping ranges:
Perhaps I should have just dropped the NOT optimizations, but instead I added more..
http://hg.dovecot.org/dovecot-1.0/rev/fa89431f893e http://hg.dovecot.org/dovecot-1.0/rev/92b2bd6b6c2d http://hg.dovecot.org/dovecot-1.0/rev/678626efb942
I've tested this by having a perl script generate thousands of SEARCH commands randomly and verifying that Dovecot's output matches UW-IMAP's output.
Excellent, looks like that got it. Tested it with both pine 4.64 and alpine 0.9999, and I can now narrow searches without it missing messages that should have matched. Thanks very much, Timo!
participants (2)
-
Julian Cowley
-
Timo Sirainen