Re: proposal: variadic argument support for least, greatest function - Mailing list pgsql-hackers

From Tom Lane
Subject Re: proposal: variadic argument support for least, greatest function
Date
Msg-id 18332.1546992460@sss.pgh.pa.us
Whole thread Raw
In response to proposal: variadic argument support for least, greatest function  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: proposal: variadic argument support for least, greatest function  (Pavel Stehule <pavel.stehule@gmail.com>)
List 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 by date:

Previous
From: Joerg Sonnenberger
Date:
Subject: Re: reducing the footprint of ScanKeyword (was Re: Large writablevariables)
Next
From: David Rowley
Date:
Subject: Re: speeding up planning with partitions