Re: A simple question about Read committed isolation level

From: weiping he <laser(at)qmail(dot)zhengmai(dot)net(dot)cn>
To:
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: A simple question about Read committed isolation level
Date: 2004-04-16 10:49:07
Message-ID: 407FBA23.9090905@qmail.zhengmai.net.cn
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane 写道:

>weiping he <laser(at)qmail(dot)zhengmai(dot)net(dot)cn> writes:
>
>
>>txn1: txn2:
>>begin; begin;
>>update table_a set col= col + 1; update table_a set col = col + 1;
>>end; end;
>>
>>
>
>
>
>>if two transaction begin at exact the same time,
>>what's the result of 'col' after both transactions committed
>>in Read committed level? it's 3 or 2?
>>My understanding is the result is 3,
>>
>>
>
>If the second xact to lock the row is READ COMMITTED, you get 3.
>If it's SERIALIZABLE you get an error. In no case will you silently
>lose an update.
>
>
dose is mean that I must use some kind of lock ( ... FOR UPDATE for example)
to lock that row to get the result 3 in READ COMMITTED level? My
understanding
is even in MVCC environment, the update action would still be executed
sequencly
(by means of some kind of lock).

What confused me is: in MVCC environment, what's the procedure of
postgresql to
use lock when two transaction update to the same row at the same time?

thanks you.

Laser

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Sullivan 2004-04-16 12:17:11 Re: Mirroring tables from Oracle to Postgresql
Previous Message Bruno BAGUETTE 2004-04-16 09:34:11 Parse error a in short stored procedure : What's wrong ?