Re: multiple statements.. and locking - Mailing list pgsql-novice

From Tom Lane
Subject Re: multiple statements.. and locking
Date
Msg-id 19076.1081225911@sss.pgh.pa.us
Whole thread Raw
In response to multiple statements.. and locking  (Benjamin <benjamin@netyantra.com>)
List pgsql-novice
Benjamin <benjamin@netyantra.com> writes:
> I have a C application. I have to modify a row in a table, n then
> immediately access a field in that row.
> These operation of modifying and accessing has to be atomic.So, i have
> to lock the row.

The UPDATE in your example does that already; I think you should just
drop the LOCK ...

> BEGIN; LOCK TABLE tablename in ROW EXCLUSIVE MODE; UPDATE tablename set
> colname=value WHERE rowprimary='a' ; SELECT b from tablename WHERE
> rowprimary='a'; COMMIT;

            regards, tom lane

pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: Help for MSSQL "Compute" equivalent in Postgres
Next
From: Nabil Sayegh
Date:
Subject: Re: 7.4 dramatically slower than 7.3? (was: snowflaking)