Re: foreign key locks

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: Noah Misch <noah(at)leadboat(dot)com>, Kevin Grittner <kgrittn(at)mail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: foreign key locks
Date: 2012-10-31 20:22:10
Message-ID: 20121031202209.GF23139@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Simon Riggs wrote:
> On 31 October 2012 19:35, Noah Misch <noah(at)leadboat(dot)com> wrote:
> > On Mon, Oct 29, 2012 at 08:18:33AM -0400, Kevin Grittner wrote:
> >> Andres Freund wrote:

> >> > The point is the introduction of a weaker lock level which can be
> >> > used by the ri triggers. I don't see any imperative that the
> >> > semantics of the old lock level need to be redefined. That just
> >> > seems dangerous to me.
> >>
> >> I agree with Andres here -- the new lock level is needed within RI
> >> triggers, and we might as well expose it for application programmer
> >> use (with proper documentations), but there's no reason to break
> >> existing application code by making the semantics of SELECT FOR
> >> UPDATE less strict than they were before. Let's keep that term
> >> meaning exactly the same thing if we can, and use new names for the
> >> new levels.
> >
> > +1. I had not considered this angle during previous reviews, but I agree with
> > Andres's position. Since this patch does not strengthen the strongest tuple
> > lock relative to its PostgreSQL 9.2 counterpart, that lock type should
> > continue to use the syntax "FOR UPDATE". It will come to mean "the lock type
> > sufficient for all possible UPDATEs of the row".

Yeah, I agree with this too.

> So we have syntax
>
> FOR NON KEY UPDATE
> FOR KEY UPDATE
>
> KEY is the default, so FOR UPDATE is a synonym of FOR KEY UPDATE

Not really sure about the proposed syntax, but yes clearly we need some
other syntax to mean "FOR NON KEY UPDATE". I would rather keep FOR
UPDATE to mean what I currently call FOR KEY UPDATE. More proposals for
the other (weaker) lock level welcome (but if you love FOR NON KEY
UPDATE, please chime in too)

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2012-10-31 21:01:29 Re: foreign key locks
Previous Message Simon Riggs 2012-10-31 20:02:42 Re: foreign key locks