Re: ntile() throws ERROR when hashagg is false

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: ntile() throws ERROR when hashagg is false
Дата
Msg-id 27994.1528988325@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: ntile() throws ERROR when hashagg is false  (David Rowley <david.rowley@2ndquadrant.com>)
Ответы Re: ntile() throws ERROR when hashagg is false  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Список pgsql-hackers
David Rowley <david.rowley@2ndquadrant.com> writes:
> On 14 June 2018 at 18:57, Andrew Gierth <andrew@tao11.riddles.org.uk> wrote:
>> What I think pg is actually doing is taking the value of the ntile()
>> argument from the first row and using that for the whole partition.

Yes, easily verified by looking at window_ntile(): the argument is only
examined on first call.

> I wonder if it would be worth adding a run-time check in
> window_ntile() that causes an ERROR on first call if there are any
> Vars or PARAM_EXEC Params in the function argument. An ERROR might be
> better than doing something that the user does not expect.

-1, that would break cases that are legal and useful, such as where a
PARAM_EXEC Param represents an outer-query-level variable, while still
failing to catch some problematic cases (eg. volatile functions).
I think also that there are cases that are not legal per spec but can
still be useful, as long as the user knows what they're doing.

It might be worth some documentation changes though.

            regards, tom lane


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

Предыдущее
От: Charles Cui
Дата:
Сообщение: Re: [GSoC] current working status
Следующее
От: Aleksander Alekseeev
Дата:
Сообщение: Re: [GSoC] current working status