Why no "array_sort" function?

Поиск
Список
Период
Сортировка
От Fabien COELHO
Тема Why no "array_sort" function?
Дата
Msg-id alpine.DEB.2.22.394.2005080947190.914063@pseudo
обсуждение исходный текст
Ответы Re: Why no "array_sort" function?  (Sergei Kornilov <sk@zsrv.org>)
Список pgsql-hackers
Hello devs,

although having arrays is an anathema in a relational world, pg has them, 
and I find it useful for some queries, mostly in an aggregation to show 
in a compact way what items were grouped together.

There are a few functions available to deal with arrays. Among these 
functions, there is no "array_sort". It is easy enough to provide one that 
seems to work, such as:

   CREATE OR REPLACE FUNCTION array_sort(a ANYARRAY) RETURNS ANYARRAY
   IMMUTABLE  STRICT AS $$
     SELECT ARRAY_AGG(i) FROM (SELECT i FROM UNNEST(a) AS i ORDER BY 1) AS i;
   $$ LANGUAGE sql;

but I'm afraid that is is not particularly efficient, and I'm not even 
sure that it is deterministic (ok, the subquery is sorted, but the outside
query could still decide to scan it out of order for some reason?).

Is there a reason *not* to provide an "array_sort" function?

-- 
Fabien.



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

Предыдущее
От: Justin Pryzby
Дата:
Сообщение: should INSERT SELECT use a BulkInsertState?
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: ALTER TABLE ... SET STORAGE does not propagate to indexes