Windowing Function Patch Review -> NTILE function - Mailing list pgsql-hackers

From David Rowley
Subject Windowing Function Patch Review -> NTILE function
Date
Msg-id F8B51ABADE2343029236663D0E64EAEB@amd64
Whole thread Raw
In response to Re: Windowing Function Patch Review -> Standard Conformance  ("Hitoshi Harada" <umi.tanuki@gmail.com>)
Responses Re: Windowing Function Patch Review -> NTILE function  ("Hitoshi Harada" <umi.tanuki@gmail.com>)
List pgsql-hackers
I've done a little testing with NTILE(). I think a check should be added to
the ntile() function in wfunc.c.

david=# select name,salary,ntile(0) over (order by salary) as n from
employees;
ERROR:  floating-point exception
DETAIL:  An invalid floating-point operation was signaled. This probably
means an out-of-range result or an invalid operation, such as division by
zero.

I tracked that message back to the signal handler in postgres.c :-( simple
fix though. Any value less than 1 does not really make sense to me.

Maybe we should add something like:

if (PG_WINDOW_ARG(0) < 1) elog(ERROR, "negative or zero ntile argument not allowed");

What do you think?

Oracle errors out on less than 1, Sybase seems not to have ntile.
MSSQL 2008 also errors out on less than 1

David.



pgsql-hackers by date:

Previous
From: "David Rowley"
Date:
Subject: Re: Windowing Function Patch Review -> Standard Conformance
Next
From: "David Rowley"
Date:
Subject: Windowing Function Patch Review -> NTH_VALUE