From: | Bruno Wolff III <bruno(at)wolff(dot)to> |
---|---|
To: | Mark <sendmailtomark(at)yahoo(dot)com> |
Cc: | Michael Fuhr <mike(at)fuhr(dot)org>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: update table with row locking |
Date: | 2004-12-29 18:19:24 |
Message-ID: | 20041229181924.GA10760@wolff.to |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, Dec 29, 2004 at 07:02:51 -0800,
Mark <sendmailtomark(at)yahoo(dot)com> wrote:
> In general I need to lock whole table so only one session can
> perform update. I'm looking for solution that will work in both C++
> and Java.
You probably want to use LOCK. You can read the documention for that command
to help decide which lock you should take.
>
> Will 'SELECT FOR UPDATE' lock whole table?
No. It will only lock records visible to the current transaction.
In particular this won't keep other transactions from doing inserts
into the table.
> As per 'LOCK' will lock released if connection get closed abnormally?
I believe the locks get released when the backend process terminates.
Depending on how the client dies, there may be a significant delay before
the backend process terminates.
> ( example: hard crash on the client side, network interruptions,
> etc.) Can LOCK be used in JDBC or it's SQL92 standard?
I don't know, but I would be surprised if you couldn't.
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Fuhr | 2004-12-29 18:20:34 | Re: update table with row locking |
Previous Message | Bruno Wolff III | 2004-12-29 17:38:35 | Re: loading only few rows from huge table |