Re: [HACKERS] Range Types and length function

2011-06-27 Thread Jeff Davis
On Mon, 2011-06-27 at 12:25 +0200, Florian Pflug wrote: > Does the current definition of length(range), i.e. > upper(range) - lower(range) > deal correctly with open vs. closed ranges and unbounded ranges? I'm thinking > that it probably doesn't - what would be the results of > length('[0,1]'::

Re: [HACKERS] Range Types and length function

2011-06-27 Thread Florian Pflug
On Jun27, 2011, at 03:12 , Jeff Davis wrote: > But I think you're right, it shouldn't be the responsibility of range > types. Perhaps I should leave length() as some inlinable SQL functions > like I mentioned, or perhaps I should remove them completely. Does the current definition of length(range)

Re: [HACKERS] Range Types and length function

2011-06-26 Thread Jeff Davis
On Mon, 2011-06-27 at 00:37 +0200, Florian Pflug wrote: > I actually wouldn't expect there to be one. From what I gathered > during the last discussion, the ideal behind range types is that they > model sets of the form {x in T | a <= x < b} for arbitrary types > T, with the only requirement being

Re: [HACKERS] Range Types and length function

2011-06-26 Thread Florian Pflug
On Jun26, 2011, at 09:18 , Jeff Davis wrote: > Currently, there is no way to define a generic "length" function over > range types, which would give you the distance between the boundary > points. I actually wouldn't expect there to be one. From what I gathered during the last discussion, the idea

Re: [HACKERS] Range Types and length function

2011-06-26 Thread Jeff Davis
On Sun, 2011-06-26 at 13:45 +0100, Greg Stark wrote: > On Sun, Jun 26, 2011 at 8:18 AM, Jeff Davis wrote: > > * it needs to know the result type of that function, which might not be > > the subtype (for instance, for timestamp the difference type would be > > interval) > > What's the use case fo

Re: [HACKERS] Range Types and length function

2011-06-26 Thread Greg Stark
On Sun, Jun 26, 2011 at 8:18 AM, Jeff Davis wrote: >  * it needs to know the result type of that function, which might not be > the subtype (for instance, for timestamp the difference type would be > interval) What's the use case for the length() function? Is it for users to be able to display us

[HACKERS] Range Types and length function

2011-06-26 Thread Jeff Davis
Currently, there is no way to define a generic "length" function over range types, which would give you the distance between the boundary points. It sounds simple, but the system actually needs quite a lot more information to accomplish that: * a function that subtracts two values of the range's