BUG #17876: Function width_bucket() for float8 input returns value out of range

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: mats(at)timescale(dot)com
Subject: BUG #17876: Function width_bucket() for float8 input returns value out of range
Date: 2023-03-29 08:11:54
Message-ID: 17876-61f280d1601f978d@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 17876
Logged by: Mats Kindahl
Email address: mats(at)timescale(dot)com
PostgreSQL version: 15.2
Operating system: All
Description:

On 64-bit platforms, the existing width_bucket() computation can
result in a NaN (0x8000000) if the difference between the `operand`,
`low`, or `high` parameters exceeds DBL_MAX. This is then cast to the
value -2147483648.

mats=# WITH sample(operand, low, high, cnt) AS (
VALUES
(10.5::float8, -1.797e+308::float8, 1.797e+308::float8, 1::int4),
(10.5::float8, -1.797e+308::float8, 1.797e+308::float8, 2),
(10.5::float8, -1.797e+308::float8, 1.797e+308::float8, 3),

(1.797e+308::float8 / 2, -1.797e+308::float8, 1.797e+308::float8, 10),
(-1.797e+308::float8 / 2, -1.797e+308::float8, 1.797e+308::float8, 10),

(1.797e+308::float8 / 2, -1.797e+308::float8, 1.797e+308::float8, 16),
(-1.797e+308::float8 / 2, -1.797e+308::float8, 1.797e+308::float8, 16),

(1.797e+308::float8, -1.797e+308::float8 / 2, 1.797e+308::float8 / 2,
10),
(-1.797e+308::float8, -1.797e+308::float8 / 2, 1.797e+308::float8 / 2,
10)
) SELECT width_bucket(operand, low, high, cnt) FROM sample;
width_bucket
--------------
1
-2147483648
-2147483648
-2147483648
-2147483648
-2147483648
-2147483648
11
0
(9 rows)

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Mats Kindahl 2023-03-29 08:18:42 Re: BUG #17876: Function width_bucket() for float8 input returns value out of range
Previous Message Amit Regmi 2023-03-29 07:16:43 Re: NEED RPM FILE OF LATEST POSTGRE supported for AIX 7.2