Re: [PATCH] Enforce that INSERT...RETURNING preserves the order of multi rows
| От | P. Christeas |
|---|---|
| Тема | Re: [PATCH] Enforce that INSERT...RETURNING preserves the order of multi rows |
| Дата | |
| Msg-id | 201210212127.41830.xrg@linux.gr обсуждение исходный текст |
| Ответ на | Re: [PATCH] Enforce that INSERT...RETURNING preserves the order of multi rows (Andres Freund <andres@2ndquadrant.com>) |
| Список | 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 по дате отправления: