Re: [BUGS] Default values, inserts, and rules...

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [BUGS] Default values, inserts, and rules...
Дата
Msg-id 5888.1029994137@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [BUGS] Default values, inserts, and rules...  (Sean Chittenden <sean@chittenden.org>)
Ответы Re: [BUGS] Default values, inserts, and rules...  (Sean Chittenden <sean@chittenden.org>)
Список pgsql-general
Sean Chittenden <sean@chittenden.org> writes:
> What I get from this is that NEW.pk is doing a NEXTVAL() instead of
> reading the value that the tuple was populated with from the sequence.

You are missing the point completely.  Rules do not operate on
individual tuples --- a rule is a textual transformation on the whole
query before it ever gets executed at all.  What gets substituted into
the INSERT command in your rule is not any specific tuple's value,
but the NEXTVAL()-containing expression.

I'm too tired to explain this clearly, but perhaps if you go back and
reread the docs about rules with the above hint in mind, it will make
sense.

My rule of thumb is that if you think you can do it with either a
trigger or a rule, you should be using a trigger.  Triggers are way
easier to understand, even though the notational baggage is heavier.

            regards, tom lane

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

Предыдущее
От: Philip Hallstrom
Дата:
Сообщение: Re: Primary Keys
Следующее
От: Oliver Elphick
Дата:
Сообщение: Re: [ADMIN] How to execute my trigger when update certain columns