How does "SELECT ... FOR UPDATE" work? - Mailing list pgsql-novice

From Joshua Daniel Franklin
Subject How does "SELECT ... FOR UPDATE" work?
Date
Msg-id Pine.LNX.4.44.0211220853480.21521-100000@iocc.com
Whole thread Raw
Responses Re: How does "SELECT ... FOR UPDATE" work?
List pgsql-novice
I am trying to build a small multiuser application.
The single-user mode works fine, but I want to be able
to lock some rows that are going to be updated.

I am trying to understand how to use "SELECT ... FOR UPDATE;"
to do this. With the psql client, I opened two sessions and did

"select * from iocc where id='100' for update;"

which returned the appropriate row. Then, in the *other* session,

"update iocc set zip = '71998' where id = '100';"

which returned "UPDATE 1" (I was expecting some error). I then
looked back in the first session and the row was indeed updated.
Obviously I'm missing something here.

I'm using RedHat 7.3 with postgresql-server-7.2.1-5 rpm.
Thanks.

Joshua Daniel Franklin
IOCC.COM



pgsql-novice by date:

Previous
From: HK
Date:
Subject: how to know backend crashed ??
Next
From: Tom Lane
Date:
Subject: Re: Viewing Foreign key constraints in psql