Re: Document if width_bucket's low and high are inclusive/exclusive
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Treat <rob@xzilla.net>
Cc: Ben Peachey Higdon <bpeacheyhigdon@gmail.com>,
pgsql-docs@lists.postgresql.org
Date: 2025-06-19T15:11:53Z
Lists: pgsql-docs
Robert Treat <rob@xzilla.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
Commits
-
Doc: improve documentation about width_bucket().
- ea06263c4aa5 18.0 landed
- ccfe3dbaa439 15.14 landed
- 9bd588f87de8 14.19 landed
- 9575e540f666 17.6 landed
- 7a93bd5986e4 16.10 landed
- 34a6c679ae35 13.22 landed