Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-hackers by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group