mirror of
https://github.com/postgres/postgres.git
synced 2025-12-19 17:02:53 +03:00
Allow width_bucket()'s "operand" input to be NaN.
The array-based variant of width_bucket() has always accepted NaN inputs, treating them as equal but larger than any non-NaN, as we do in ordinary comparisons. But up to now, the four-argument variants threw errors for a NaN operand. This is inconsistent and unnecessary, since we can perfectly well regard NaN as falling after the last bucket. We do still throw error for NaN or infinity histogram-bound inputs, since there's no way to compute sensible bucket boundaries. Arguably this is a bug fix, but given the lack of field complaints I'm content to fix it in master. Author: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com> Discussion: https://postgr.es/m/2822872.1750540911@sss.pgh.pa.us
This commit is contained in:
@@ -1464,9 +1464,21 @@ ERROR: count must be greater than zero
|
||||
SELECT width_bucket(3.5::float8, 3.0::float8, 3.0::float8, 888);
|
||||
ERROR: lower bound cannot equal upper bound
|
||||
SELECT width_bucket('NaN', 3.0, 4.0, 888);
|
||||
ERROR: operand, lower bound, and upper bound cannot be NaN
|
||||
width_bucket
|
||||
--------------
|
||||
889
|
||||
(1 row)
|
||||
|
||||
SELECT width_bucket('NaN'::float8, 3.0::float8, 4.0::float8, 888);
|
||||
width_bucket
|
||||
--------------
|
||||
889
|
||||
(1 row)
|
||||
|
||||
SELECT width_bucket(0, 'NaN', 4.0, 888);
|
||||
ERROR: lower and upper bounds cannot be NaN
|
||||
SELECT width_bucket(0::float8, 'NaN', 4.0::float8, 888);
|
||||
ERROR: operand, lower bound, and upper bound cannot be NaN
|
||||
ERROR: lower and upper bounds cannot be NaN
|
||||
SELECT width_bucket(2.0, 3.0, '-inf', 888);
|
||||
ERROR: lower and upper bounds must be finite
|
||||
SELECT width_bucket(0::float8, '-inf', 4.0::float8, 888);
|
||||
|
||||
@@ -869,6 +869,8 @@ SELECT width_bucket(5.0::float8, 3.0::float8, 4.0::float8, 0);
|
||||
SELECT width_bucket(5.0::float8, 3.0::float8, 4.0::float8, -5);
|
||||
SELECT width_bucket(3.5::float8, 3.0::float8, 3.0::float8, 888);
|
||||
SELECT width_bucket('NaN', 3.0, 4.0, 888);
|
||||
SELECT width_bucket('NaN'::float8, 3.0::float8, 4.0::float8, 888);
|
||||
SELECT width_bucket(0, 'NaN', 4.0, 888);
|
||||
SELECT width_bucket(0::float8, 'NaN', 4.0::float8, 888);
|
||||
SELECT width_bucket(2.0, 3.0, '-inf', 888);
|
||||
SELECT width_bucket(0::float8, '-inf', 4.0::float8, 888);
|
||||
|
||||
Reference in New Issue
Block a user