Re: INSERT/UPDATE ... RETURNING

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gavin Sherry <swm(at)linuxworld(dot)com(dot)au>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: INSERT/UPDATE ... RETURNING
Date: 2003-04-28 14:18:25
Message-ID: 18137.1051539505@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Gavin Sherry <swm(at)linuxworld(dot)com(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Teodor Sigaev 2003-04-28 15:48:08 Please, apply patch for current CVS
Previous Message Philip Warner 2003-04-28 14:04:42 Re: INSERT/UPDATE ... RETURNING