Re: SELECT FOR UPDATE - release lock?

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Luís Silva <lfs12(at)hotmail(dot)com>
Cc: 'Christian Hofmann' <christian(dot)hofmann(at)gmx(dot)de>, pgsql-novice(at)postgresql(dot)org
Subject: Re: SELECT FOR UPDATE - release lock?
Date: 2006-05-05 14:03:04
Message-ID: 20060505140304.GA4046@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Fri, May 05, 2006 at 14:49:25 +0100,
Luís Silva <lfs12(at)hotmail(dot)com> wrote:
> Locks only affects the lines in the table selected in the sql query, right?

There are both table locks and row locks. You can check the documentation to
be sure, but I think that SELECT FOR UPDATE takes both locks on the rows
and some sort of shared lock on the table.

>
> -----Mensagem original-----
> De: pgsql-novice-owner(at)postgresql(dot)org
> [mailto:pgsql-novice-owner(at)postgresql(dot)org] Em nome de Bruno Wolff III
> Enviada: quinta-feira, 4 de Maio de 2006 20:21
> Para: Christian Hofmann
> Cc: pgsql-novice(at)postgresql(dot)org
> Assunto: Re: [NOVICE] SELECT FOR UPDATE - release lock?
>
> On Thu, May 04, 2006 at 22:08:16 +0200,
> Christian Hofmann <christian(dot)hofmann(at)gmx(dot)de> wrote:
> > Hello,
> >
> > for some tables I am using a "select a,b,c from mytable where x='abc' FOR
> > UPDATE" query to prevent other servers also modify this data while I am
> > reading the data and decide to modify the data.
> >
> > Now sometimes I don't want to make an update. Is there a way to release
> the
> > lock. Or is the lock released by simply call commit?
>
> Locks are released when transactions end.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Robert Landsmeer 2006-05-05 14:41:29 Problem with temporary disbaling foreign keys.
Previous Message Luís Silva 2006-05-05 13:49:25 Re: SELECT FOR UPDATE - release lock?