Re: proposal: variadic argument support for least, greatest function

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: proposal: variadic argument support for least, greatest function
Дата
Msg-id 18332.1546992460@sss.pgh.pa.us
обсуждение исходный текст
Ответ на proposal: variadic argument support for least, greatest function  (Pavel Stehule <pavel.stehule@gmail.com>)
Ответы Re: proposal: variadic argument support for least, greatest function  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-hackers
Pavel Stehule <pavel.stehule@gmail.com> writes:
> We cannot to write
> SELECT least(VARIADIC ARRAY[1,2,3]);
> Attached patch add this possibility to least, greatest functions.

TBH, I don't find that natural at all.  If I were looking for the
functionality "smallest element of an array", I think I'd expect to find
that exposed as "array_smallest(anyarray) returns anyelement", not as
some weird syntax option for LEAST.

It also seems rather inconsistent that this behaves so differently
from, eg,

=# select least(array[1,2], array[3,4]);
 least 
-------
 {1,2}
(1 row)

Normally, if you have a variadic function, it doesn't also take arrays,
so that there's less possibility for confusion.

The implementation seems mighty ugly too, in that it has to treat this
as entirely disjoint from MinMaxExpr's normal argument interpretation.
But that seems like a symptom of the fact that the definition is
disjointed itself.

In short, I'd rather see this done with a couple of array functions,
independently of MinMaxExpr.

            regards, tom lane


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

Предыдущее
От: Joerg Sonnenberger
Дата:
Сообщение: Re: reducing the footprint of ScanKeyword (was Re: Large writablevariables)
Следующее
От: David Rowley
Дата:
Сообщение: Re: speeding up planning with partitions