Re: do foreign key checks lock parent table ?

From: Jan Wieck <janwieck(at)yahoo(dot)com>
To: swalker(at)iglou(dot)com
Cc: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: do foreign key checks lock parent table ?
Date: 2002-04-03 16:29:38
Message-ID: 200204031629.g33GTcm32174@saturn.janwieck.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

swalker(at)iglou(dot)com wrote:
>
> So turning intially deferred on is a suitable solution? It seems
> to work OK in this simple test case.

It might change the behaviour of your application. If you set
the constraints deferred, they aren't checked at insert time
and the PK's aren't locked then either. So after doing the
INSERT or UPDATE successfully, someone else can still remove
the primary key referenced in your rows without any problems.
When you commit your transaction then, the deferred
constraints will fail and the COMMIT results in a ROLLBACK.

Jan

>
> On Tue, 2 Apr 2002, Stephan Szabo wrote:
> > The locks being grabbed are a bit stronger than they need to be
> > (if you want more info, there was a bit of discussion on -hackers
> > recently). The updates should block updates on parent of the
> > referenced row but don't need to block other child updates but there's
> > no current lock level that is quite right.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #

In response to

Browse pgsql-general by date

  From Date Subject
Next Message mlw 2002-04-03 16:32:57 Re: [GENERAL] Re : Solaris Performance - Profiling (Solved)
Previous Message Jan Wieck 2002-04-03 16:25:59 Re: do foreign key checks lock parent table ?