Reputation: 3038
I try to understand, how that SQL command works:
BEGIN;
UPDATE post SET hits = hits + 1;
-- run from another session: DELETE FROM post WHERE hits = 10;
COMMIT;
Let's say, we hahe a rows with hits = 9 and 10. Then we run that query, and then what? What (and why) will our rows look like?
Upvotes: 1
Views: 526
Reputation: 1857
This depends on transaction isolation level in each session but by default
all changes made by UPDATE will be visible to other session only after executing COMMIT.
So your DELETE session will behave like there was no UPDATE at all.
Upvotes: 1