Reputation: 116
I read that SELECT ... FOR UPDATE inside a transaction disallows other transactions from SELECTing the affected records.
So far so good, but what is with SELECT statements from other connections that are not inside a transaction. Can these statements read my affected records?
I read something that all MySQL statements are transactions implicitly. That would mean, that a normal SELECT that is not wrapped inside START TRANSACTION ... COMMIT cannot read my affected records. However, I don't found much on this topic. So my Question is if this is correct?
Upvotes: 0
Views: 235
Reputation: 14761
Statements outside your transaction won't read your modified data. The exclusive lock prevents it as does an isolation level of not read-uncommmitted. A transaction started before yours may quite legitimately read the old value.
Yes normal SELECT statements without a START TRANSACTION
/ BEGIN
are implicitly their own transaction. As such a SELECT .. FOR UPDATE
as a single statement is rather pointless.
Upvotes: 1