Re: Incomplete idea about views and INSERT...RETURNING - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Incomplete idea about views and INSERT...RETURNING
Date
Msg-id 8848.995842215@sss.pgh.pa.us
Whole thread Raw
In response to Re: Incomplete idea about views and INSERT...RETURNING  (Andrew McMillan <andrew@catalyst.net.nz>)
List pgsql-hackers
Andrew McMillan <andrew@catalyst.net.nz> writes:
> Tom Lane wrote:
>> Could we get away with restricting INSERT RETURNING to work only on
>> inserts directly to tables (no ON INSERT DO INSTEAD allowed)?  Or is
>> that too much of a kluge?

> Isn't it likely that the person writing the RULE would want to
> internally use an INSERT ... RETURNING query and that the RETURNS
> ... should either use values from that, or use a SELECT clause keyed
> on values from that?

Hmm, so we'd allow INSERT RETURNING to be the last statement of an
ON INSERT DO INSTEAD rule, and the RETURNING clause would either be
dropped (if rewriting a plain INSERT) or used to form the outputs
(if rewriting INSERT RETURNING).  Kind of limited maybe, but it would
work for simple cases, which is a lot better than none at all...

The trouble with INSERT RETURNING followed by SELECT is that a rule
has noplace to keep the results: it hasn't got any local variables.
(And I don't think I want to invent such a feature, at least not on
the spur of the moment.)
        regards, tom lane


pgsql-hackers by date:

Previous
From: mlw
Date:
Subject: Re: sub queries and caching.
Next
From: "Christopher Kings-Lynne"
Date:
Subject: RE: More ADD CONSTRAINT behaviour questions