Re: Question about SELECT FOR UPDATE in transaction, isolation level

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Al <alexm(at)innocent(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Question about SELECT FOR UPDATE in transaction, isolation level
Date: 2001-04-13 16:22:22
Message-ID: 4331.987178942@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Al <alexm%innocent(dot)com(at)news(dot)tht(dot)net> writes:
> begin work;
> select val from ids where cntr='ct1' for update;
> update ids set val=val+(some integer value) where cntr='ct1';
> commit work;

Looks reasonable.

> However, when I run everything except the commit on one terminal and
> then run up to and including the select on another terminal, I receive
> the OLD, non-updated value for val on that second terminal. In other
> words, the select is not blocked and the id is not unique.

Hm, it works for me. You sure you remembered to use select FOR UPDATE
in both transactions?

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-04-13 16:30:46 Re: updates way slower than selects?
Previous Message Tom Lane 2001-04-13 16:17:54 Re: Repairing bad table?