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

Поиск
Список
Период
Сортировка
От P. Christeas
Тема Re: Re: [PATCH] Enforce that INSERT...RETURNING preserves the order of multi rows
Дата
Msg-id 201210220035.27862.xrg@linux.gr
обсуждение исходный текст
Ответ на Re: Re: [PATCH] Enforce that INSERT...RETURNING preserves the order of multi rows  (Vik Reykja <vikreykja@gmail.com>)
Ответы Re: Re: [PATCH] Enforce that INSERT...RETURNING preserves the order of multi rows
Список pgsql-hackers
On Sunday 21 October 2012, Vik Reykja wrote:
> On Sun, Oct 21, 2012 at 6:20 PM, Abhijit Menon-Sen
<ams@2ndquadrant.com>wrote:
> > Note: "INSERT … RETURNING" doesn't accept an ORDER BY clause.
>
> Would anyone be opposed to somebody - say, me - writing a patch to allow
> that?  It would take me a lot longer than an experienced hacker to do it,
> but I'm willing to try.


I would oppose, for one.

Please, don't waste your time. Reordering the INSERT .. RETURNING results is
already possible today, with some nested syntax. At the same time, bloating
the INSERT syntax with SELECT semantics would be negative IMO. And I would see
little use in having such a feature.

At a worst case scenario, you could do (in client pseydocode):

ids = query("INSERT INTO tableA (col1, col2) VALUES (...), (...) RETURNING
id")
ordered_ids = query("SELECT id FROM tableA WHERE id IN %s ORDER BY col1", ids)

which would be minimally more roundtrip than a "RETURNING id ORDER BY col1" .



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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Phil Sorber
Дата:
Сообщение: Re: [WIP] pg_ping utility
Следующее
От: Andrew Dunstan
Дата:
Сообщение: to_char timezone