Following up, it looks like dbmail doesn't use the sequences in the schemas as defaults, but rather manually grabs the nextval (thereby updating the sequence) and uses that explicitly in the INSERT.
As such, this should be an easier change, since the trigger is not strictly required. Whether it is better to add a message_uid column to dbmail_messages in addition to a uid_next column to dbmail_mailboxes and keep message_idnr as a primary key, or to instead make (message_idnr, mailbox_idnr) the primary key for dbmail_messages and change all instances of message_idnr in WHERE clauses to < WHERE message_idnr = %s and mailbox_idnr = %s > is still an open question. Either way this will deal with two *very* anoying bugs in gnus' nnimap: wildly incorrect unread message counts in the *Group* buffer and a severy waste of resources calling FETCH of every integer in the gaps between actual UIDs in the folder. (As an example, if the largest UID previously seen by nnimap in a given folder were, say, 10000; and two new messages arrived which were given UIDs 15000 and 20000 (not unlikely on a busy server), then nnimap will, after doing some SEARCHes, will try to FETCH the nov data for every UID in the gaps, ie every int in [10001,14999] and [15001,19999]. And each of those FETCH calls generates sql traffic. As you can imaging it takes a /long/ time to complete.) You see above that I have a strong motivation to have contiguous UIDs w/in mailboxes. So any feedback is appreciated. (The non-contiguous (ie server unique, rather than just user-unique) UIDVALIDITY values do not cause any problems like the non-contiguous (again, server-unique rather than just mailbox-unique) UID values do, so only the message_idnr is at issue. Again, I know that dbmail is IMAP compliant here, but nnimap cannot be the only client which tries to get data on all possibly UIDs in the range of [0, UIDNEXT] for each folder, so this enhancement should be of value to at least /some/ other users. -JimC -- James Cloos <[EMAIL PROTECTED]> OpenPGP: 1024D/ED7DAEA6 _______________________________________________ Dbmail-dev mailing list Dbmail-dev@dbmail.org http://twister.fastxs.net/mailman/listinfo/dbmail-dev