last_login plugin with MySQL

Sven Hartge sven at svenhartge.de
Sat Oct 18 16:30:44 UTC 2014


Luigi Rosa <lists at luigirosa.com> wrote:
> Sven Hartge wrote on 18/10/2014 18:07:

>> This SQL query looks correct to me. It INSERTs a new row for a
>> username if one does not already exist but UPDATEs it if there is
>> already such a row.

> My fault: I didn't know this SQL syntax.

It is incredibly usefull. Otherwise you would have to do a SELECT first
to decide if you want to INSERT or UPDATE as a second query and this
creates a race condition if another process is able to do its INSERT
after you decided there is no existing key because at the time if your
first SELECT there was in fact none.

Grüße,
Sven.

-- 
Sigmentation fault. Core dumped.



More information about the dovecot mailing list