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
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>
Subject: Re: [PATCH] Enforce that INSERT...RETURNING preserves the order of multi rows
Date: 2012-10-21 18:27:41
Message-ID: 201210212127.41830.xrg@linux.gr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sunday 21 October 2012, Andres Freund wrote:
> On Sunday, October 21, 2012 07:24:52 PM Andrew Dunstan wrote:
> > why does the client have to be involved, exactly?
> Suppose you have something like
>
> CREATE TABLE positionlog(
> ...
> And you want to insert multiple values in one roundtrip *and* know their
> ids in your application.
>
> INSERT INTO positionlog(position)
> VALUES
> ('POINT(..., ...)'),
> ('POINT(..., ...)')
> RETURNING id, timestamp, position
> ;
>
> If you want to correlate re returned ids with data in your application
> without relying on the ordering of INSERT ... VALUES... RETURNING you
> would need to sort a postgis type in the same way the server does it.
> Am I missing something here?
>

That's close enough to my case: you would have to guess from (timestamp,
position) the order they have with respect to your [(timestamp, pos),...]
input array. That's not always trivial to do client-side (what about duplicate
pairs? ), let alone the CPU needed to sort and match again.

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Abhijit Menon-Sen 2012-10-21 18:43:28 Re: [PATCH] Enforce that INSERT...RETURNING preserves the order of multi rows
Previous Message Tom Lane 2012-10-21 18:27:39 Re: Re: [PATCH] Enforce that INSERT...RETURNING preserves the order of multi rows