Thomas Mueller wrote:
Hi Ilja,
Isn't the simplest solution this:
change the query for the special case of 'INBOX' to:
SELECT mailbox_idnr FROM mailboxes WHERE name = 'INBOX' and owner_idnr =
'%llu';
We always store 'INBOX' as 'INBOX' (all caps), so, this will always
work. And we have no problem with indexes this way.
It just too simple probably.. Perhaps I'm overlooking something?
I'm confused at the moment. Your query is right but the 'if' statement
isn't?!
I changed the query and broke dbmail. If I try to change to folder
INBOX/lists/dbmail-dev I get my INBOX:
----------------------------------------------------------------------
if (strncasecmp(name, "INBOX", 5) == 0) {
snprintf(query, DEF_QUERYSIZE,
"SELECT mailbox_idnr FROM mailboxes "
"WHERE name = 'INBOX' "
"AND owner_idnr='%llu'", owner_idnr);
} else {
snprintf(query, DEF_QUERYSIZE,
"SELECT mailbox_idnr FROM mailboxes "
"WHERE name='%s' AND owner_idnr='%llu'", name,
owner_idnr);
}
----------------------------------------------------------------------
strncasecmp() tests if the folder begins with INBOX and thats always
true - right? So we have to use strcasecmp(name, "INBOX") right?
Confused ...
Aha, it wasn't as simple as I thought... The 'if' isn't right, because
strcasecmp only looks at the first 5 characters, and you just gave the
perfect example why this does not work.
What we can do is the following:
keep the 'if' as it is.
Convert the first 5 characters of the name to 'INBOX' (if it starts with
INBOX, in any case (upper, lower, mixed)).
When we do things this way we get the following results:
input query
MyBox -> MyBox
Inbox -> INBOX
Inbox/MyBox -> INBOX/MyBox
etc.
Makes sense?
Ilja