MySQL: Does SET influence FOR UPDATE? I have the following set of MySQL queries:

SET @domain := (
    SELECT server_domain
    FROM engine.storage
    WHERE (size_bytes - bytes_inuse) &gt;= 40000
    FOR UPDATE
);

UPDATE engine.storage
SET bytes_inuse = bytes_inuse + 40000
WHERE server_domain = (SELECT @domain);


The question is if the SET statement influences the functionality of FOR UPDATE? Will the SELECT statement be executed everytime I call SELECT @domain or once on assignment and before the UPDATE statement? Or is there even a better solution to manage this?

Thanks in advance!
Unless the MySQL lords know better than me, it's equivalent to the query:

UPDATE engine.storage
SET bytes_inuse = bytes_inuse + 40000
WHERE (size_bytes - bytes_inuse) &gt;= 40000;


I imagine in your real query you have a more restrictive WHERE clause etc.