Reputation: 2195
If I start a transaction in MySQL and update a row like so:
UPDATE table SET SomeValue ...... WHERE Id = 1;
Am I ok to immediately do this:
SELECT SomeValue FROM table WHERE Id = 1;
...during the same connection/session whilst the transaction is still not yet committed, assuming now that I'm getting the updated SomeValue, and safe to assume that nothing can update that SomeValue until I've committed the transaction?
Thanks.
Upvotes: 1
Views: 876
Reputation: 562310
No other session can update that row until you commit.
You can test this for yourself, by opening two terminal windows, run the mysql shell, and try starting a transaction and updating in one window, but do not commit. Then try updating in the second window. It hangs, until the first window commits, or the innodb lock wait timeout is reached.
SELECTing from the table has no effect on locks one way or the other.
Upvotes: 2