While thinking about range_cmp_bounds, I started to think that the way
range_adjacent works is wrong.
range_adjacent() depends on the bounds of two ranges to match up, such
that the boundary values are equal, but one is exclusive and the other
inclusive, and one is a lower bound and the other an upper bound.
That makes perfect sense for continuous ranges because that is the only
way they can possibly be adjacent. It also works for the discrete ranges
as defined so far, because they use a canonical function that translates
the values to [) form. But if someone were to write a canonical function
that translates the ranges to  or () form, range_adjacent would be
There are a few approaches to solving it:
1. Make the canonical function accept a "format" argument much like the
constructor, and have an output format stored in the catalog that would
be passed in under most circumstances. However, range_adjacent could
pass in its own form that would be useful for its purposes.
2. Replace the canonical function with "inc" and "dec" functions, or
some variation thereof. We'd still need some kind of output format to
match the current behavior, otherwise every range would always be output
in [) form (I don't necessarily object to that, but it would be a
behavior difference for user-defined range types).
3. Remove range_adjacent.
4. Do nothing, and document that the canonical function should translate
to either [) or (] if you want range_adjacent to work.
pgsql-hackers by date
|Next:||From: Simon Riggs||Date: 2011-11-18 08:53:09|
|Subject: Re: Inlining comparators as a performance optimisation|
|Previous:||From: Jeff Davis||Date: 2011-11-18 08:14:16|
|Subject: Re: Are range_before and range_after commutator operators?|