Re: Rule uses wrong value

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Rule uses wrong value
Дата
Msg-id 3744.1097596135@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Rule uses wrong value  (Jeff Boes <jboes@nexcerpt.com>)
Ответы Re: Rule uses wrong value  (Jeff Boes <jboes@nexcerpt.com>)
Список pgsql-general
Jeff Boes <jboes@nexcerpt.com> writes:
> Tom Lane wrote:
>> No kidding.  A rule is a macro and therefore has the usual risks of
>> multiple evaluations of arguments.

> But shouldn't "new.job_id" use the value that was already recorded in
> the original row?

There is no "value that was already recorded in the original row";
if you want to think in those terms you should use a trigger.  It's
fundamentally wrong to think of a rule in that way.

In the rule, "new.job_id" is effectively a macro parameter that gets
replaced by the INSERT's corresponding expression, ie, nextval(...).

            regards, tom lane

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

Предыдущее
От: Steve Atkins
Дата:
Сообщение: Re: Message-ID as unique key?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Change query priority