From: Rafa Couto <rafacouto@gmail.com>
To: Andrew Hammond <ahammond@ca.afilias.info>
Cc: pgsql-sql@postgresql.org
Subject: Re: Transaction in plpgslq
Date: Tue, 24 May 2005 12:40:55 +0200
Message-ID: <22df564b050524034045f8c174@mail.gmail.com> (raw)
In-Reply-To: <428E245B.4050204@ca.afilias.info>
References: <22df564b05052003479481da1@mail.gmail.com>
<428E245B.4050204@ca.afilias.info>
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)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: rafacouto@gmail.com, ahammond@ca.afilias.info
Subject: Re: Transaction in plpgslq
In-Reply-To: <22df564b050524034045f8c174@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox