Re: Reliability of CURRVAL in a RULE

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: Reliability of CURRVAL in a RULE
Дата
Msg-id 48980194.3060005@archonet.com
обсуждение исходный текст
Ответ на Reliability of CURRVAL in a RULE  (Nick <nboutelier@hotmail.com>)
Список pgsql-hackers
Nick wrote:
> Is the use of CURRVAL in this example reliable in heavy use?

Nick - the hackers list is for people interested in working on the 
code-base of PostgreSQL itself. This would have been better on the 
general or sql lists.

> CREATE RULE add_email AS ON INSERT TO users WHERE (NEW.email IS NULL)
> DO INSERT INTO users_with_email (id) VALUES (CURRVAL('users_id_seq'));

Short answer no. Rules are like macros and you can end up with 
unexpected multiple evaluations and strange order of execution. See the 
mailing list archives for details and try inserting multiple users in 
one go to see an example of a problem.

--   Richard Huxton  Archonet Ltd


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

Предыдущее
От: Nick
Дата:
Сообщение: Reliability of CURRVAL in a RULE
Следующее
От: "Greg Stark"
Дата:
Сообщение: Re: Automatic Client Failover