Pavel Stehule <pavel.steh...@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