Jasper Bryant-Greene wrote: > On Tue, Jul 24, 2007 at 02:09:23PM -0700, David Jonas wrote: >> < SELECT current FROM quota WHERE ... >>> 513965019 >> < BEGIN >> < INSERT INTO quota (current, ... >> < COMMIT >>> ?? (error_r appears to be (null)) > > Unrelated to the original post, but the above would appear to be a bug to me. > > Because the SELECT is done before the transaction starts, the value in the > INSERT which is based on the SELECT may no longer be consistent with the > actual value in that table.
I don't think it uses the value. The INSERT statement that comes next does an UPDATE if the key exists. The value represented as 0 here is the change in quota value: INSERT INTO quota (current, path, username) VALUES (0, 'quota/storage', '[EMAIL PROTECTED]') ON DUPLICATE KEY UPDATE current = current + 0; So it's only added to or inserted, never changed then replaced. > I had a look through the code as I wanted to include a patch to move the > SELECT > into the transaction with this email, but I'm not familiar enough with the > Dovecot codebase to find the code that performs the above SQL. If anyone can > point me in the right direction I'd be happy to submit a patch. > > Jasper
