Re: Want to acquire lock on tables where primary of one table is foreign key on othere

From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: postforabhishek(at)gmail(dot)com
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Want to acquire lock on tables where primary of one table is foreign key on othere
Date: 2018-10-11 14:56:38
Message-ID: CAF-3MvNXowd7rrRNqF3oaHdz+J1W5zrm8yR+3LGx5Fa14s+oQw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-general

On Thu, 11 Oct 2018 at 16:38, Abhishek Tripathi
<postforabhishek(at)gmail(dot)com> wrote:
> Actually I have acquired a "Select for Update" on a table whose id is refrence as a foreign key on another table So I want those table won't update until there is lock. Is it possible? Becuase postgres is acquiring lock but AccessShare Lock which allow to write on those table How I restrict this.

For what purpose do you want that? What is inadequate about the lock
that Postgres acquires?

Table locks are very rarely what you want, as it blocks all concurrent
access to the entire table, while that is only necessary for a few
rarely used corner cases; a foreign key update is not among those.

--
If you can't see the forest for the trees,
Cut the trees and you'll see there is no forest.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2018-10-11 22:09:02 Re: BUG #15425: DETACH/ATTACH PARTITION bug
Previous Message Abhishek Tripathi 2018-10-11 09:49:13 Fwd: Want to acquire lock on tables where primary of one table is foreign key on othere

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Janes 2018-10-11 15:36:06 Re: Advice on logging strategy
Previous Message Bryce Pepper 2018-10-11 14:53:58 RE: RHEL 7 (systemd) reboot