pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Allow width_bucket()'s "operand" input to be NaN.
Date: Wed, 02 Jul 2025 15:34:47 +0000
Message-ID: <E1uWzTz-004NAC-1d@gemulon.postgresql.org> (raw)

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7374b3a53635cb031b4d1bedfd80531409f54693

Modified Files
--------------
src/backend/utils/adt/float.c         | 18 +++++++++---------
src/backend/utils/adt/numeric.c       | 17 +++++++----------
src/test/regress/expected/numeric.out | 16 ++++++++++++++--
src/test/regress/sql/numeric.sql      |  2 ++
4 files changed, 32 insertions(+), 21 deletions(-)



Message-ID: <E1uWzTz-004NAC-1d@gemulon.postgresql.org>
Permalink:  ../E1uWzTz-004NAC-1d@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1uWzTz-004NAC-1d@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Allow width_bucket()'s "operand" input to be NaN.
  In-Reply-To: <E1uWzTz-004NAC-1d@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox