Re: Transaction in plpgslq

From: Rafa Couto <rafacouto(at)gmail(dot)com>
To: Andrew Hammond <ahammond(at)ca(dot)afilias(dot)info>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Transaction in plpgslq
Date: 2005-05-24 10:40:55
Message-ID: 22df564b050524034045f8c174@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

2005/5/20, Andrew Hammond <ahammond(at)ca(dot)afilias(dot)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)

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Jan B. 2005-05-24 11:00:36 Re: Transaction in plpgslq
Previous Message Szűcs Gábor 2005-05-24 10:39:04 Re: could not devise a query plan