Re: Re: [PATCH] Enforce that INSERT...RETURNING preserves the order of multi rows

From: "P(dot) Christeas" <xrg(at)linux(dot)gr>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Re: [PATCH] Enforce that INSERT...RETURNING preserves the order of multi rows
Date: 2012-10-21 16:40:33
Message-ID: 201210211940.33857.xrg@linux.gr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sunday 21 October 2012, Abhijit Menon-Sen wrote:
> At 2012-10-21 11:49:26 -0400, cbbrowne(at)gmail(dot)com wrote:
> > If there is a natural sequence (e.g. - a value assigned by nextval()),
> > that offers a natural place to apply the usual order-imposing ORDER BY
> > that we are expected to use elsewhere.
>
> Note: "INSERT … RETURNING" doesn't accept an ORDER BY clause.

Exactly. And IMHO it should never have.

The real trouble is when you insert some arbitrary values, which have no
implicit order or primary key /before/ the insert will assign them one. Then,
you need to map them to the SERIAL they got.

Or else, you can't use the multi-row INSERT and must just do many INSERTs.

--
Say NO to spam and viruses. Stop using Microsoft Windows!

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-10-21 16:49:03 Re: Successor of MD5 authentication, let's use SCRAM
Previous Message Andres Freund 2012-10-21 16:36:29 Re: [PATCH] Enforce that INSERT...RETURNING preserves the order of multi rows