Re: Atomicity?

Поиск
Список
Период
Сортировка
От Michael Glaesemann
Тема Re: Atomicity?
Дата
Msg-id A13B2A81-F9D4-4D8C-A155-B59F27716F93@seespotcode.net
обсуждение исходный текст
Ответ на Re: Atomicity?  (Peter Eisentraut <peter_e@gmx.net>)
Ответы Re: Atomicity?  (Naz Gassiep <naz@mira.net>)
Список pgsql-general
On Aug 29, 2006, at 4:46 , Peter Eisentraut wrote:

> Naz Gassiep wrote:
>> conwatch=# UPDATE replies SET rgt = rgt + 2 WHERE postid = 18 AND rgt
>>> = 11;
>> ERROR:  duplicate key violates unique constraint "replies_rgt_postid"
>
> This is a well-known deficiency in PostgreSQL.  You will have to work
> around it somehow (by changing the query, the schema, or the index).

One such workaround is:

BEGIN;

UPDATE replies
SET rgt = -1 * (rgt + 2)
WHERE postid = 18
    AND rgt >= 11;

UPDATE replies
SET rgt = -1 * rgt
WHERE rgt < 0;

COMMIT;

Michael Glaesemann
grzm seespotcode net




В списке pgsql-general по дате отправления:

Предыдущее
От: Naz Gassiep
Дата:
Сообщение: Re: Atomicity?
Следующее
От: Naz Gassiep
Дата:
Сообщение: Re: Atomicity?