On Nov18, 2011, at 09:25 , Jeff Davis wrote:
> 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
Hm, the problem here is for range_adjacent to recognize that [1,2] is
adjacent to [3,4] when treated as integer ranges, but that they're not
adjacent when treated as float ranges. The reason being, of course, that
there's isn't any integer between 2 and 3, but there are floats between
2 and 3.
That information, however, *is* already contained in the canonical
functions, because those function know that (2,3) are empty as an integer
range, but non-empty as a float range.
For example, [1,2] is adjacent to [3,4] as integer ranges because (2,3)
is empty as an integer range. Conversely, since (2,3) is *not* empty as a
float range, [1,2] and [3,4] are *not* adjacent as float ranges.
More formally, let there be two arbitrary ranges
where the first two parameters are the lower respectively upper bound, and
the last two are booleans saying whether the lower respectively upper bound
is inclusive (true) or exclusive (false).
These ranges are then adjacent exactly if the range
This definition does not depend on any specific canonical form of ranges,
only on the canonicalize function's ability to detect empty ranges.
In response to
pgsql-hackers by date
|Next:||From: Albe Laurenz||Date: 2011-11-18 13:04:15|
|Subject: Review for "Add permission check on SELECT INTO"|
|Previous:||From: Shigeru Hanada||Date: 2011-11-18 12:00:10|
|Subject: Re: WIP: Collecting statistics on CSV file data|