pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Bruce Momjian <bruce@momjian.us>
Cc: Fujii Masao <masao.fujii@oss.nttdata.com>
Cc: jani.rahkola@iki.fi
Cc: pgsql-docs@lists.postgresql.org
Subject: Re: Documentation of return values of range functions lower and upper
Date: Wed, 01 Nov 2023 21:40:43 +0100
Message-ID: <a0f9f8fa5de833acd7cf9e74352ef347ade6572d.camel@cybertec.at> (raw)
In-Reply-To: <ZUK0-gzxmfHdDila@momjian.us>
References: <160508672127.25505.8356390205508789564@wrigleys.postgresql.org>
	<53ec9f116bea9252d7fa9341e024530553656c42.camel@cybertec.at>
	<16601466752e40543051369fac722c0a200bb4e6.camel@cybertec.at>
	<27d690d8-0987-5f2b-a2da-fc2ec7c19e3c@oss.nttdata.com>
	<02f3fa3a592fa6c1f8ec1a9f539ae376f744eb42.camel@cybertec.at>
	<ZUK0-gzxmfHdDila@momjian.us>

On Wed, 2023-11-01 at 16:28 -0400, Bruce Momjian wrote:
> On Wed, Nov 18, 2020 at 05:28:44PM +0100, Laurenz Albe wrote:
> > On Wed, 2020-11-18 at 22:49 +0900, Fujii Masao wrote:
> > > On 2020/11/12 17:14, Laurenz Albe wrote:
> > > > On Wed, 2020-11-11 at 18:19 +0100, Laurenz Albe wrote:
> > > > > > Table 9.54 in page
> > > > > > https://www.postgresql.org/docs/current/functions-range.html states that the
> > > > > > functions lower and upper return NULL if the requested bound is infinite. If
> > > > > > the element type of the range contains the special values infinity and
> > > > > > -infinity, this is not correct, as those values are returned if explicitly
> > > > > > used as either bound.
> > > > > +1
> > > > > Perhaps it would be better to say
> > > > >     NULL if the range is empty or has no lower/upper bound
> > > 
> > > I agree this description looks a bit confusing. But according to the section
> > > "Infinite (Unbounded) Ranges" (*1), we already call "lower/upper bound
> > > omitted" just infinite. So I don't think the current description is incorrect.
> > > 
> > > (*1)
> > > https://www.postgresql.org/docs/devel/rangetypes.html#RANGETYPES-INFINITE
> > 
> > That is correct, but I'd argue that it would be better to clarify the paragraph too,
> > in particular:
> > 
> >   The functions lower_inf and upper_inf test for infinite lower and upper bounds of a range, respectively.
> > 
> > should better read
> > 
> >   The functions lower_inf and upper_inf test for omitted lower and upper bounds of a range, respectively.
> > 
> > The rest of the paragraph is pretty unambiguous.
> > 
> > 
> > Independent of this, I think that my patch for "upper" and "lower" would make the
> > documentation clearer.
> 
> Yes, I agree this documentation needs help.
> 
> For upper/lower(), it is clear that the documentation is better saying
> "unspecified" rather than infinite.  The fact that upper/lower_inf()
> returns false for +/-Infinity is quite odd, but should at least be
> documented.
> 
> Patch attached.  It is odd that +Infinity (vs. Infinity) wasn't
> supported for datetime input until PG 16, but I think we have to say
> +/-infinity vs (blank)/-Infinity.
> 
> Patch attached.

I am unhappy with "unspecified".  A NULL value as upper or lower bound has a very
specific meaning, namely that the range is unbounded in that direction.  This is
a bit confusing, since NULL is typically used for unknown or undefined values.

I think it would be better to say "returns NULL if the range is empty or unbounded"
and "is the range unbounded on the upper end?".

Yours,
Laurenz Albe





view thread (14+ messages)  latest in thread

Message-ID: <a0f9f8fa5de833acd7cf9e74352ef347ade6572d.camel@cybertec.at>
Permalink:  ../a0f9f8fa5de833acd7cf9e74352ef347ade6572d.camel@cybertec.at/
Also on:    postgresql.org/message-id/a0f9f8fa5de833acd7cf9e74352ef347ade6572d.camel@cybertec.at

 · 

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-docs@postgresql.org
  Cc: laurenz.albe@cybertec.at, bruce@momjian.us, masao.fujii@oss.nttdata.com, jani.rahkola@iki.fi, pgsql-docs@lists.postgresql.org
  Subject: Re: Documentation of return values of range functions lower and upper
  In-Reply-To: <a0f9f8fa5de833acd7cf9e74352ef347ade6572d.camel@cybertec.at>

* 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