st 9. 1. 2019 v 1:07 odesÃlatel Tom Lane <t...@sss.pgh.pa.us> napsal:
> 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. > The target of this patch is a consistency LEAST, GREATEST variadic functions (implementet) with generic variadic functions. Sure it is possible to implement array_smallest(anyarray), but it different. This patch try to eliminate unpleasing surprising about different behave LEAST, GREATEST from other variadic functions. > 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. > This is different case - the keyword VARIADIC was not used here. > 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. > I don't think so there is any other possibility - I have not a possibility to unpack a array to elements inside analyze stage. > In short, I'd rather see this done with a couple of array functions, > independently of MinMaxExpr. > It doesn't help to user, when they try to use VARIADIC keyword on LEAST, GREATEST functions. Regards Pavel > > regards, tom lane >