Re: [PATCH] Enforce that INSERT...RETURNING preserves the order of multi rows - Mailing list pgsql-hackers

From P. Christeas
Subject Re: [PATCH] Enforce that INSERT...RETURNING preserves the order of multi rows
Date
Msg-id 201210212127.41830.xrg@linux.gr
Whole thread Raw
In response to Re: [PATCH] Enforce that INSERT...RETURNING preserves the order of multi rows  (Andres Freund <andres@2ndquadrant.com>)
List 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!



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Re: [PATCH] Enforce that INSERT...RETURNING preserves the order of multi rows
Next
From: Abhijit Menon-Sen
Date:
Subject: Re: [PATCH] Enforce that INSERT...RETURNING preserves the order of multi rows