Re: Transaction in plpgslq - Mailing list pgsql-sql

From Rafa Couto
Subject Re: Transaction in plpgslq
Date
Msg-id 22df564b050524034045f8c174@mail.gmail.com
Whole thread Raw
In response to Re: Transaction in plpgslq  (Andrew Hammond <ahammond@ca.afilias.info>)
Responses Re: Transaction in plpgslq  ("Jan B." <jan@monso.de>)
Re: Transaction in plpgslq  (Andrew Hammond <ahammond@ca.afilias.info>)
List pgsql-sql
2005/5/20, Andrew Hammond <ahammond@ca.afilias.info>:

> The solution to your problem is locking (or concurrency control if you
> prefer). While we're at it, we might as well optimize your statement a
> little too using ORDER BY with LIMIT instead of min().
>
> SELECT id INTO _contacto_id
> FROM contactos
> WHERE contactos.operadora_id IS NULL
>   AND contactos.actividad_id > = _actividad_id
> ORDER BY id LIMIT 1
> FOR UPDATE;
>
> Take a look at the "FOR UPDATE" section of the SELECT description for an
> explanation of how this works.


I understand "FOR UPDATE" clause is locking while is selecting rows
only. It does not secure atomic execution from 'SELECT' to 'UPDATE' in
next statement. Is not it?


--
Rafa Couto (caligari)


pgsql-sql by date:

Previous
From: Szűcs Gábor
Date:
Subject: Re: could not devise a query plan
Next
From: "Jan B."
Date:
Subject: Re: Transaction in plpgslq