Re: ntile() throws ERROR when hashagg is false - Mailing list pgsql-hackers

From Tom Lane
Subject Re: ntile() throws ERROR when hashagg is false
Date
Msg-id 27994.1528988325@sss.pgh.pa.us
Whole thread Raw
In response to Re: ntile() throws ERROR when hashagg is false  (David Rowley <david.rowley@2ndquadrant.com>)
Responses Re: ntile() throws ERROR when hashagg is false
List 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 by date:

Previous
From: Charles Cui
Date:
Subject: Re: [GSoC] current working status
Next
From: Aleksander Alekseeev
Date:
Subject: Re: [GSoC] current working status