Re: Undocumented array_val[generate_series(...)] functionality?

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Undocumented array_val[generate_series(...)] functionality?
Дата
Msg-id CAKFQuwY=4BBQ9iMarAk4MFQdZ0u-xXvW=P25aHChX4b7MdXmwA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Undocumented array_val[generate_series(...)] functionality?  (David Rowley <dgrowleyml@gmail.com>)
Ответы Re: Undocumented array_val[generate_series(...)] functionality?  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Список pgsql-general
On Sun, Jul 11, 2021 at 6:06 PM David Rowley <dgrowleyml@gmail.com> wrote:
select abs(generate_series(-3,-1));

abs() is simply called once per output value of the generate_series
SRF.  That seems fairly equivalent to me to what's going on in your
example case.


Fair point.  Both of these are premised on two related facts:

One, the select generate_series(1,3) function call causes multiple rows to be generated where there would usually be only one.  In short, SRF function calls and non-SRF function calls exhibit different behaviors on the output.

Two, composition results in an inside-to-outside execution order: the SRF is evaluated first, the additional rows added, then the outer function (abs or the subscript function respectively in these examples) is evaluated for whatever rows are now present in the result.

Is the above something one can learn from our documentation?

Is this syntax we are discouraging users from using and thus intentionally not documenting it?  I do get this impression but, frankly, given the utility of " [ generate_series(...) ] " I find it hard to recommend something different to get the same result yet don't have a place to point and say "here is how and why it works".

David J.


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

Предыдущее
От: Kyotaro Horiguchi
Дата:
Сообщение: Re: Removing a subscription that does not exist
Следующее
От: Laurenz Albe
Дата:
Сообщение: Re: What to look for when excessively long commits