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

From: Abhishek Tripathi <postforabhishek(at)gmail(dot)com>
To: haramrae(at)gmail(dot)com
Cc: 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-12 05:03:03
Message-ID: CACun91MoZ3kOcK-9Ckzcn6qe6n72mQhMxcM3ERwjsL1sR9yO0Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-general

Thank you for your response.

I am explaining my situation there is table A on which I have taken a row
lock and the primary key of table A is related with table B as a foreign
key so automatically I can not insert new row with that foreign key now
the primary key of table B is used as foreign key in table C and insertion
can be done on table C. I just want to lock table C also No insertion can
be done on table C related to table B primary key.

On Thu, Oct 11, 2018 at 8:26 PM Alban Hertroys <haramrae(at)gmail(dot)com> wrote:

> 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 Alban Hertroys 2018-10-12 06:37:42 Re: Want to acquire lock on tables where primary of one table is foreign key on othere
Previous Message Andres Freund 2018-10-12 04:51:48 Re: BUG #15427: DROP INDEX did not free up disk space

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2018-10-12 06:37:42 Re: Want to acquire lock on tables where primary of one table is foreign key on othere
Previous Message Laurenz Albe 2018-10-12 03:42:12 Re: how to identify the timeline of specified recovery_target_time when do multiple PITR