Re: INSERT/UPDATE ... RETURNING - Mailing list pgsql-hackers

From Tom Lane
Subject Re: INSERT/UPDATE ... RETURNING
Date
Msg-id 18137.1051539505@sss.pgh.pa.us
Whole thread Raw
In response to INSERT/UPDATE ... RETURNING  (Gavin Sherry <swm@linuxworld.com.au>)
List pgsql-hackers
Gavin Sherry <swm@linuxworld.com.au> writes:
> I am working on a project which requires INSERT/UPDATE ... RETURNING
> functionality.

This would be good to have.

> Oracle returns data into binded variables, which we do not support. It
> returns multiple rows into bind arrays, ie, an array of instances of 
> binded variables.

Right.  I think it would be better to return the result just like a
SELECT result.

> 2) Same row affected multiple times

> UPDATEs can affect rows multiple times.

No they can't.  Study the MVCC rules.

> 3) Inherited updates affecting multiple tables

> Seems that it would be the right thing to do to allow returning of
> inherited rows, but it might be a bit painful to implement. Ideas?

Why does this matter?  The RETURNING clause can only name columns of the
topmost table, and so these expressions can surely be computed for every
row of every child table too.

> 4) Handling rule cases

> Seems reasonable to allow RETURNING when the query is re-written to a
> single query and that the operation is not transformed.

In principle I think you could rewrite the RETURNING clause too, but
certainly it'd be okay to punt on this for a first implementation.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Philip Warner
Date:
Subject: Re: INSERT/UPDATE ... RETURNING
Next
From: Teodor Sigaev
Date:
Subject: Please, apply patch for current CVS