### Re: [HACKERS] range_adjacent and discrete ranges

I wrote: Attached is a draft patch for this. It passes regression tests but I've not tried to exercise it with a canonical function that actually does something different. I hacked up int4range_canonical to produce []-style ranges, and confirmed that this version of range_adjacent seems to

### Re: [HACKERS] range_adjacent and discrete ranges

I wrote: I did a little bit of performance testing on an x86_64 machine (Fedora 14), and found that the time to execute a clause like WHERE int4range(1,2) -|- int4range(x, 1000) (x being an integer Var) grows from 0.37 us to 0.56 us if we adopt the patched version of range_adjacent.

### Re: [HACKERS] range_adjacent and discrete ranges

Florian Pflug f...@phlo.org writes: More formally, let there be two arbitrary ranges a,b,i_a,i_b c,d,i_c,i_d 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

### Re: [HACKERS] range_adjacent and discrete ranges

On Fri, 2011-11-18 at 14:47 -0500, Tom Lane wrote: Yeah, probably not. However, I don't like the idea of '(3,4)'::int4range throwing an error, as it currently does, because it seems to require the application to have quite a lot of knowledge of the range semantics to avoid having errors

### Re: [HACKERS] range_adjacent and discrete ranges

Jeff Davis pg...@j-davis.com writes: On Fri, 2011-11-18 at 14:47 -0500, Tom Lane wrote: Yeah, probably not. However, I don't like the idea of '(3,4)'::int4range throwing an error, as it currently does, because it seems to require the application to have quite a lot of knowledge of the range

### Re: [HACKERS] range_adjacent and discrete ranges

On Nov19, 2011, at 22:03 , Tom Lane wrote: Jeff Davis pg...@j-davis.com writes: On Fri, 2011-11-18 at 14:47 -0500, Tom Lane wrote: Yeah, probably not. However, I don't like the idea of '(3,4)'::int4range throwing an error, as it currently does, because it seems to require the application to

### [HACKERS] range_adjacent and discrete ranges

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

### Re: [HACKERS] range_adjacent and discrete ranges

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

### Re: [HACKERS] range_adjacent and discrete ranges

Florian Pflug f...@phlo.org writes: ...This definition does not depend on any specific canonical form of ranges, only on the canonicalize function's ability to detect empty ranges. Hmm, well, now that you mention it, I don't think the current canonical functions handle empty ranges very nicely

### Re: [HACKERS] range_adjacent and discrete ranges

On Fri, 2011-11-18 at 10:33 -0500, Tom Lane wrote: regression=# select int4range(4,4,'(]'); ERROR: range lower bound must be less than or equal to range upper bound regression=# select int4range(4,4,'()'); ERROR: range lower bound must be less than or equal to range upper bound Would it

### Re: [HACKERS] range_adjacent and discrete ranges

On Fri, 2011-11-18 at 13:32 +0100, Florian Pflug wrote: 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. Very good point. Thank you. Regards, Jeff Davis

### Re: [HACKERS] range_adjacent and discrete ranges

Jeff Davis pg...@j-davis.com writes: On Fri, 2011-11-18 at 10:33 -0500, Tom Lane wrote: Would it be better for them to silently transform such cases to empty? I wouldn't like to extend that to int4range(4,3), however. When the upper bound is less than the lower bound, it's almost certainly a