Re: RETURNING and DO INSTEAD ... Intentional or not?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: RETURNING and DO INSTEAD ... Intentional or not?
Дата
Msg-id 25140.1189622446@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: RETURNING and DO INSTEAD ... Intentional or not?  (Richard Huxton <dev@archonet.com>)
Ответы Re: RETURNING and DO INSTEAD ... Intentional or not?  (Josh Berkus <josh@agliodbs.com>)
Список pgsql-hackers
Richard Huxton <dev@archonet.com> writes:
> Tom Lane wrote:
>> What the RETURNING clause in the rule does is let you define the data
>> that should be returned if the rewritten INSERT had a returning clause
>> to start with.

> Sorry - haven't got a CSV download here, or I'd check myself. Does this 
> just allow an INSERT...RETURNING inside the rule, or could it be 
> something like:
> CREATE RULE ... AS ON INSERT ... DO INSTEAD SELECT f(NEW.test1);

Well, that's what you do if you want to deliberately break the normal
behavior of INSERT, ie, have it fire back data unconditionally.
What the rule definition of RETURNING is intended for is to let you
write rules that support an updatable view that does the right things,
ie INSERT and INSERT RETURNING on the view both do what you'd expect
them to do if the view were a plain table.

Josh, this *is* documented; see the CREATE RULE reference page for full
details, and there's at least passing references here:
http://developer.postgresql.org/pgdocs/postgres/rules-update.html#RULES-UPDATE-VIEWS
        regards, tom lane


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Representation of redirected line pointers in HOT
Следующее
От: Josh Berkus
Дата:
Сообщение: Re: RETURNING and DO INSTEAD ... Intentional or not?