Re: Using results from INSERT ... RETURNING

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Using results from INSERT ... RETURNING
Дата
Msg-id 19617.1247970633@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Using results from INSERT ... RETURNING  (Jaime Casanova <jcasanov@systemguards.com.ec>)
Список pgsql-hackers
Jaime Casanova <jcasanov@systemguards.com.ec> writes:
> On Sat, Jul 18, 2009 at 6:25 PM, Merlin Moncure<mmoncure@gmail.com> wrote:
>> Being able to use 'returning' in a subquery is probably the #1 most
>> requested feature for postgresql (it's also a todo). Solving it for
>> 'with' queries is a nice step in the right direction, and sidesteps
>> some of the traps that result from the general case.

> ah! that's why i asked: 'if we will support this, shouldn't we
> supporting INSERT RETURNING inside subqueries too?'

We've been over that: when will you fire triggers?  What happens if the
outer query doesn't want to read the whole output of the DML command,
or wants to read it more than once?

If the DML command is in a single-evaluation WITH clause at the top
level of the command, then it's reasonable to identify the outer
command's own begin and end as the times to fire triggers; and there is
no issue about partial or repeated evaluation.  If it's in a subquery
then things get much messier and more poorly defined.

Note that it can't just be "a WITH clause".  It has to be one at the top
query level, or the problem comes right back.
        regards, tom lane


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

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: machine-readable explain output v2
Следующее
От: Robert Haas
Дата:
Сообщение: Re: GEQO vs join order restrictions