Transaction Isolation on select, insert, delete
Posted
by Bradford
on Stack Overflow
See other posts from Stack Overflow
or by Bradford
Published on 2010-04-05T21:09:04Z
Indexed on
2010/04/05
21:13 UTC
Read the original article
Hit count: 296
What could possibly go wrong with the following transaction if executed by concurrent users in the default isolation level of READ COMMITTED?
BEGIN TRANSACTION
SELECT * FROM t WHERE pid = 10 and r between 40 and 60
-- ... this returns tid = 1, 3, 5
-- ... process returned data ...
DELETE FROM t WHERE tid in (1, 3, 5)
INSERT INTO t (tid, pid, r) VALUES (77, 10, 35)
INSERT INTO t (tid, pid, r) VALUES (78, 10, 37)
INSERT INTO t (tid, pid, r) VALUES (79, 11, 39)
COMMIT
© Stack Overflow or respective owner