Re: NEW in Rule makes another nextval call?

Поиск
Список
Период
Сортировка
Искать
От
Richard Huxton
Тема
Re: NEW in Rule makes another nextval call?
Дата
Msg-id
4357A339.5060202@archonet.com
Ответ на
Список
Дерево обсуждения
NEW in Rule makes another nextval call? Sven Willenberger <sven@dmv.com>
Re: NEW in Rule makes another nextval call? Richard Huxton <dev@archonet.com>
Re: NEW in Rule makes another nextval call? Sven Willenberger <sven@dmv.com>
Re: NEW in Rule makes another nextval call? Richard Huxton <dev@archonet.com>
Sven Willenberger wrote:
>  Is this intended behavior? or is the NEW
> acting as a macro that is replace by "nextval()" ?

Well, it's understood behaviour even if not quite "intended".

You are quite right, rules basically act like macros with all the 
limitations they have. What is actually happening behind the scenes is 
that the query is being rewritten to alter the query-plan tree. You 
should be able to get your rule to work by referring to 
currval() rather than NEW.custid.

However, in this particular case I think you want an after insert 
trigger on customer rather than a rule.

-- 
   Richard Huxton
   Archonet Ltd
В списке pgsql-general по дате отправления
От: Tom Lane
Дата:
От: Tom Lane
Дата:
Сообщение: Re: NULL != text ?
FAQ