As I test my theory on a duplicate db, I have to install sqlite3 ... but on test DB it seems to work properly !
here is the trigger :
Code:
CREATE TRIGGER UpdateIncommingBit
AFTER INSERT ON mailmessages
FOR EACH ROW
WHEN 1|new.status <> new.status
AND
128|new.status <> new.status
AND
2048|new.status = new.status
BEGIN
UPDATE mailmessages
SET status = 1|status
WHERE id = new.id;
END;
So I use bitwise opérator | to check if mail is read 128|new.status
"read" status is bitstatus 8 in mailstatusfalg table, bin 1000 0000 = dec 128
"new" status is bitstatus 12, bin 1000 0000 0000 = dec 2048
and so on (use windows calc in developper mode, option Dword, Déc) ...
so
1|new.status <> new.status = not "incoming" status
AND
128|new.status <> new.status = not "read" status
AND
2048|new.status = new.status = "new" status
As I test my theory on a duplicate db, I have to install sqlite3 ... but on test DB it seems to work properly !
here is the trigger :
cf : http://www.tutorialspoint.com/sqlite..._operators.htm
So I use bitwise opérator | to check if mail is read 128|new.status
"read" status is bitstatus 8 in mailstatusfalg table, bin 1000 0000 = dec 128
"new" status is bitstatus 12, bin 1000 0000 0000 = dec 2048
and so on (use windows calc in developper mode, option Dword, Déc) ...
so
1|new.status <> new.status = not "incoming" status
AND
128|new.status <> new.status = not "read" status
AND
2048|new.status = new.status = "new" status
if it's ok :
SET status = 1|status
my test process :
So now i just have to install sqlite3 and this trigger on y N9 and restart my own mail server (down since I change house) that produced this bug.
Let me know if it works for you ... I'll let you know as soon as possible
...