Re: Document if width_bucket's low and high are inclusive/exclusive

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Treat <rob(at)xzilla(dot)net>
Cc: Ben Peachey Higdon <bpeacheyhigdon(at)gmail(dot)com>, pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: Document if width_bucket's low and high are inclusive/exclusive
Date: 2025-06-19 15:11:53
Message-ID: 1391433.1750345913@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-docs

Robert Treat <rob(at)xzilla(dot)net> writes:
> Since they are all lower bounds, they all operate the same way, so it
> isn't quite as clear that it needs documenting. Are you thinking
> something like this?

> Returns the number of the bucket in which operand falls given an array
> listing the lower bounds (inclusive) of the buckets

Yeah, though I might write "inclusive lower bounds" rather than use
parens. What's bugging me though is the lack of any mention of the
bucket upper bounds: you have to deduce that the upper bounds must
be exclusive if the lower bounds are inclusive. If that's obvious
here, why is it non-obvious for the other case? Maybe instead of
the parenthetical form you suggested, add a sentence like

Buckets have inclusive lower bounds, and therefore exclusive
upper bounds.

and then we could either rely on the reader remembering that,
or else repeat it, for the second form of width_bucket.

Another thing I just remembered (think I knew it once) is the
behavior of the first form when low > high. It's not an error!
I think we need to document that, perhaps along the lines of

If low > high, the behavior is mirror-reversed, with bucket 1
now being the one just below low, and the inclusive bounds
now being on the upper side.

plus an example.

regards, tom lane

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Fujii Masao 2025-06-20 14:33:22 Fix incorrect UUID index entry in function documentation
Previous Message Fujii Masao 2025-06-19 10:34:41 Minor documentation fixes related to v18