Paul, Using Debian version 2.1.3+20060124-1, when doing a search, all of the messages are returned if the search returns no results. I've attached a trace.
Christian
Jan 28 10:15:15 cumin dbmail/imap4d[19162]: imap4.c,IMAPClientHandler: line read for PID 19162 Jan 28 10:15:15 cumin dbmail/imap4d[19162]: COMMAND: [A0003 SELECT "cache"] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: arg[0]: 'cache' Jan 28 10:15:15 cumin dbmail/imap4d[19162]: imap4.c,IMAPClientHandler: Executing command select... Jan 28 10:15:15 cumin dbmail/imap4d[19162]: db.c,db_findmailbox: looking for mailbox with FQN [cache]. Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmysql.c,db_query: executing query [SELECT mailbox_idnr FROM mailboxes WHERE name='cache' AND owner_idnr='583'] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: db.c,db_acl_has_right: checking ACL for user [583] on mailbox [18] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmysql.c,db_query: executing query [SELECT mailbox_idnr FROM mailboxes WHERE mailbox_idnr = '18' AND owner_idnr = '583'] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmysql.c,db_query: executing query [SELECT no_select FROM mailboxes WHERE mailbox_idnr = '18'] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmysql.c,db_query: executing query [SELECT permission,seen_flag,answered_flag,deleted_flag,flagged_flag,recent_flag,draft_flag FROM mailboxes WHERE mailbox_idnr = '18'] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmysql.c,db_query: executing query [SELECT 'a',COUNT(*) FROM messages WHERE mailbox_idnr='18' AND (status='0' OR status='1') UNION SELECT 'b',COUNT(*) FROM messages WHERE mailbox_idnr='18' AND (status='0' OR status='1') AND seen_flag=1 UNION SELECT 'c',COUNT(*) FROM messages WHERE mailbox_idnr='18' AND (status='0' OR status='1') AND recent_flag=1] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmysql.c,db_query: executing query [SELECT message_idnr FROM messages WHERE mailbox_idnr = '18' AND status < '2' ORDER BY message_idnr ASC] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: db.c,db_getmailbox: exists [670] num_rows [670] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmysql.c,db_query: executing query [SELECT message_idnr+1 FROM messages ORDER BY message_idnr DESC LIMIT 1] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmysql.c,db_query: executing query [SELECT permission,seen_flag,answered_flag,deleted_flag,flagged_flag,recent_flag,draft_flag FROM mailboxes WHERE mailbox_idnr = '18'] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmysql.c,db_query: executing query [SELECT 'a',COUNT(*) FROM messages WHERE mailbox_idnr='18' AND (status='0' OR status='1') UNION SELECT 'b',COUNT(*) FROM messages WHERE mailbox_idnr='18' AND (status='0' OR status='1') AND seen_flag=1 UNION SELECT 'c',COUNT(*) FROM messages WHERE mailbox_idnr='18' AND (status='0' OR status='1') AND recent_flag=1] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmysql.c,db_query: executing query [SELECT message_idnr FROM messages WHERE mailbox_idnr = '18' AND status < '2' ORDER BY message_idnr ASC] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: db.c,db_getmailbox: exists [670] num_rows [670] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmysql.c,db_query: executing query [SELECT message_idnr+1 FROM messages ORDER BY message_idnr DESC LIMIT 1] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: RESPONSE: [* 670 EXISTS^M ] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: RESPONSE: [* 0 RECENT^M ] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: RESPONSE: [* FLAGS (\Seen \Answered \Deleted \Flagged \Draft \Recent)^M ] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: RESPONSE: [* OK [PERMANENTFLAGS (\Seen \Answered \Deleted \Flagged \Draft \Recent)]^M ] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: RESPONSE: [* OK [UIDNEXT 61636] Predicted next UID^M ] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: RESPONSE: [* OK [UIDVALIDITY 18] UID value^M ] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmysql.c,db_query: executing query [SELECT MIN(message_idnr) FROM messages WHERE mailbox_idnr = '18' AND status < '2' AND seen_flag = '0'] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: RESPONSE: [* OK [UNSEEN 4] first unseen message^M ] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmysql.c,db_query: executing query [SELECT message_idnr FROM messages WHERE recent_flag = 1 AND mailbox_idnr = '18'] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmail-imapsession.c,dbmail_imap_session_mailbox_select_recent: recent [0] in mailbox [18] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: RESPONSE: [A0003 OK [READ-WRITE] SELECT completed^M ] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: imap4.c,IMAPClientHandler: Finished command select [0] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmysql.c,db_query: executing query [SELECT permission,seen_flag,answered_flag,deleted_flag,flagged_flag,recent_flag,draft_flag FROM mailboxes WHERE mailbox_idnr = '18'] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmysql.c,db_query: executing query [SELECT 'a',COUNT(*) FROM messages WHERE mailbox_idnr='18' AND (status='0' OR status='1') UNION SELECT 'b',COUNT(*) FROM messages WHERE mailbox_idnr='18' AND (status='0' OR status='1') AND seen_flag=1 UNION SELECT 'c',COUNT(*) FROM messages WHERE mailbox_idnr='18' AND (status='0' OR status='1') AND recent_flag=1] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmysql.c,db_query: executing query [SELECT message_idnr FROM messages WHERE mailbox_idnr = '18' AND status < '2' ORDER BY message_idnr ASC] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: db.c,db_getmailbox: exists [670] num_rows [670] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmysql.c,db_query: executing query [SELECT message_idnr+1 FROM messages ORDER BY message_idnr DESC LIMIT 1] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: imap4.c,IMAPClientHandler: line read for PID 19162 Jan 28 10:15:15 cumin dbmail/imap4d[19162]: COMMAND: [A0004 SEARCH HEADER X-Postica-ID 1E8htj-00046T-6o] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: arg[0]: 'HEADER' Jan 28 10:15:15 cumin dbmail/imap4d[19162]: arg[1]: 'X-Postica-ID' Jan 28 10:15:15 cumin dbmail/imap4d[19162]: arg[2]: '1E8htj-00046T-6o' Jan 28 10:15:15 cumin dbmail/imap4d[19162]: imap4.c,IMAPClientHandler: Executing command search... Jan 28 10:15:15 cumin dbmail/imap4d[19162]: db.c,db_acl_has_right: checking ACL for user [583] on mailbox [18] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmysql.c,db_query: executing query [SELECT mailbox_idnr FROM mailboxes WHERE mailbox_idnr = '18' AND owner_idnr = '583'] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmysql.c,db_query: executing query [SELECT message_idnr FROM messages WHERE mailbox_idnr = '18' AND status IN ('0','1') ORDER BY message_idnr] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmail-mailbox.c,append_search: [134767128] [1] type [6] field [X-Postica-ID] search [1E8htj-00046T-6o] at depth [1] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmail-mailbox.c,_do_search: type [6] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmysql.c,db_query: executing query [SELECT message_idnr FROM messages m JOIN physmessage p ON m.physmessage_id=p.id JOIN headervalue v ON v.physmessage_id=p.id JOIN headername n ON v.headername_id=n.id WHERE mailbox_idnr = 18 AND status IN ('0','1') AND headername = 'X-Postica-ID' AND headervalue LIKE '%1E8htj-00046T-6o%' ORDER BY message_idnr] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmail-mailbox.c,_do_search: type [6] rows [0] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmail-mailbox.c,_merge_search: node depth [1] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmail-mailbox.c,dbmail_mailbox_search: found [670] ids Jan 28 10:15:15 cumin dbmail/imap4d[19162]: RESPONSE: [* SEARCH 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 ...] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: RESPONSE: [^M A0004 OK SEARCH completed^M ] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: imap4.c,IMAPClientHandler: Finished command search [0] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: imap4.c,IMAPClientHandler: line read for PID 19162 Jan 28 10:15:15 cumin dbmail/imap4d[19162]: COMMAND: [C64 EXAMINE ""] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: arg[0]: '' Jan 28 10:15:15 cumin dbmail/imap4d[19162]: imap4.c,IMAPClientHandler: Executing command examine... Jan 28 10:15:15 cumin dbmail/imap4d[19162]: db.c,db_findmailbox: looking for mailbox with FQN []. Jan 28 10:15:15 cumin dbmail/imap4d[19162]: dbmysql.c,db_query: executing query [SELECT mailbox_idnr FROM mailboxes WHERE name='' AND owner_idnr='583'] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: db.c,db_findmailbox_owner: no mailbox found Jan 28 10:15:15 cumin dbmail/imap4d[19162]: RESPONSE: [C64 NO specified mailbox does not exist^M ] Jan 28 10:15:15 cumin dbmail/imap4d[19162]: imap4.c,IMAPClientHandler: Finished command examine [1]