Subject | Is UPDATE in read-committed transaction atomic? |
---|---|
Author | jaratulpas |
Post date | 2007-11-02T11:31:22Z |
I have an application which uses read-committed transactions for
performance reasons. It can be easily verified that in
select cnt ... into :cnt;
update ... set cnt = :cnt + 1 ...;
a data race can happen if another transaction commits changed cnt.
Is the statement
update object set cnt = cnt + 1 where id = 'a';
safe, i.e. is the row locked for the duration of the update statement?
Thanks, Jara
PS: I do know about "select with lock".
performance reasons. It can be easily verified that in
select cnt ... into :cnt;
update ... set cnt = :cnt + 1 ...;
a data race can happen if another transaction commits changed cnt.
Is the statement
update object set cnt = cnt + 1 where id = 'a';
safe, i.e. is the row locked for the duration of the update statement?
Thanks, Jara
PS: I do know about "select with lock".