Re: Incomplete idea about views and INSERT...RETURNING

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew McMillan <andrew(at)catalyst(dot)net(dot)nz>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Incomplete idea about views and INSERT...RETURNING
Date: 2001-07-22 22:50:15
Message-ID: 8848.995842215@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrew McMillan <andrew(at)catalyst(dot)net(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Christopher Kings-Lynne 2001-07-23 02:01:36 RE: More ADD CONSTRAINT behaviour questions
Previous Message mlw 2001-07-22 18:30:15 Re: sub queries and caching.