[Dovecot] quota dict with mysql 4.0

Andre Hübner andre.huebner at gmx.de
Thu Mar 25 15:04:55 EET 2010


(sorry, i only read the digest version of list and always create i new 
thread by "fake-Re")

Hello,

>> Perhaps you can implement some updating procedure that
>> would only involve a percentage of your users at one time.


no way, i want to fix this! but i need help because i have no idea of 
c-programming.
i can read the code a little bit, but never lerned it.

solution is to edit dovecot-1.2.11/src/lib-dict/dict-sql.c
i can avoid using ON DUPLICATE KEY UPDATE by changing line 91 to:

orig:
dict->has_on_duplicate_key = strcmp(driver->name, "mysql") == 0;
changed:
dict->has_on_duplicate_key = strcmp(driver->name, "mysqlXXX") == 0;

this works only 50%.
if a user has no entry in quotatable, dovecot is updating his quota with 2 
queries:

INSERT INTO quota (bytes,username) VALUES ('2456','myuser')
INSERT INTO quota (messages,username) VALUES ('2','myuser')

The first query works, the second throws an error because username-field is 
uniqe.
Duplicate entry 'myuser' for key 1

So i have to find a way to make this query in one step:
INSERT INTO quota (bytes,messages, username) VALUES ('2456','2','myuser')

or turn the second insert into an update

update quota SET messages='2' where username='myuser'

But iam afraid this is too much for my c-skills. I need help of an C-Crack 
or timo as developer.
if timo could create a switch for mysql 4.0 would surely be the best.

Thanks,
Andre



More information about the dovecot mailing list