From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: proposal: variadic argument support for least, greatest function |
Date: | 2019-01-09 06:11:03 |
Message-ID: | CAFj8pRBn2mKtwj+=WpHCBW7fpy9tpeOq9YHC4qtee6jkbaazGA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
st 9. 1. 2019 v 1:07 odesílatel Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> napsal:
> Pavel Stehule <pavel(dot)stehule(at)gmail(dot)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
>
From | Date | Subject | |
---|---|---|---|
Next Message | Pavan Deolasee | 2019-01-09 06:46:10 | Re: monitoring CREATE INDEX [CONCURRENTLY] |
Previous Message | Dilip Kumar | 2019-01-09 06:10:24 | Re: Undo logs |