Re: [HACKERS] Range Types: empty ranges

2011-02-14 Thread Kevin Grittner
Jan Wieck wrote: > Does ['15:15:00','15:15:00') make any more sense? Doesn't this > essentially mean > > >= '15:15:00' && < '15:15:00' > > which again doesn't include a single point on the time line? It defines a position in time with zero duration. Some of the graphics programming I

Re: [HACKERS] Range Types: empty ranges

2011-02-14 Thread Jan Wieck
On 2/11/2011 1:50 PM, Kevin Grittner wrote: Josh Berkus wrote: if I, in one of my applications, accidentally defined something as having the range '('15:15:00','15:15:00')', I would *want* the database to through an error and not accept it. I can agree with that, but I think that range '[

Re: [HACKERS] Range Types: empty ranges

2011-02-11 Thread Martijn van Oosterhout
On Fri, Feb 11, 2011 at 10:11:45AM -0800, Jeff Davis wrote: > The cost, of course, is that not all operations are well-defined for > empty ranges. I think those are mostly operators like those mentioned in > the other thread: ">>" (strictly right of), "<<" (strictly left of), and > "-|-" (adjacent)

Re: [HACKERS] Range Types: empty ranges

2011-02-11 Thread Nathan Boley
FWIW, a very informal survey of probabilists didn't yield any reason for trying to put an order on the empty set ( unless the metric was cardinality or other equivalence relation ). I think the problem here is that the idea of union and intersection forming a ring over sets is being conflated with

Re: [HACKERS] Range Types: empty ranges

2011-02-11 Thread Kevin Grittner
Jeff Davis wrote: >> Perhaps it was a mistake to get so concrete rather than >> conceptual -- basically, it seems like it could be a useful >> concept for any planned or scheduled range with an indeterminate >> end point, which you want to "reserve" up front and record in >> progress until compl

Re: [HACKERS] Range Types: empty ranges

2011-02-11 Thread Jeff Davis
On Fri, 2011-02-11 at 15:14 -0500, Robert Haas wrote: > On Fri, Feb 11, 2011 at 3:03 PM, Jeff Davis wrote: > > Well, there is a certain amount of localized clarity, I will agree with > > that. The complexity comes when you accidentally rely on some > > transformation which seems logically sound, b

Re: [HACKERS] Range Types: empty ranges

2011-02-11 Thread Jeff Davis
On Fri, 2011-02-11 at 14:19 -0600, Kevin Grittner wrote: > Well, in the receipt number example there are multiple ranges in use > for each year, and ranges for multiple years. If we get to the idea > of a multi-ranges, this would be very handy for certain types of > reports -- especially for audit

Re: [HACKERS] Range Types: empty ranges

2011-02-11 Thread Kevin Grittner
Jeff Davis wrote: > Trying to incorporate a "start value" is adding extra information > in there, and it's not really a part of the same algebra. It > sounds more like a contiguous sequence with a "start value" and a > "current value" to me. Well, in the receipt number example there are multip

Re: [HACKERS] Range Types: empty ranges

2011-02-11 Thread Robert Haas
On Fri, Feb 11, 2011 at 3:03 PM, Jeff Davis wrote: > Well, there is a certain amount of localized clarity, I will agree with > that. The complexity comes when you accidentally rely on some > transformation which seems logically sound, but could result in a > transient empty range, which then throw

Re: [HACKERS] Range Types: empty ranges

2011-02-11 Thread Jeff Davis
On Fri, 2011-02-11 at 14:14 -0500, Robert Haas wrote: > > It's really that it has nice mathematical properties coming from set > > theory. Take the distributive law: > > > > A UNION (B INTERSECT C) = (A UNION B) INTERSECT (A UNION C) > > But the basic range type isn't even closed under UNION. An

Re: [HACKERS] Range Types: empty ranges

2011-02-11 Thread Jeff Davis
On Fri, 2011-02-11 at 13:50 -0500, Robert Haas wrote: > On Fri, Feb 11, 2011 at 1:11 PM, Jeff Davis wrote: > > Similarly, "intersection" of ranges is somewhat analogous to > > multiplication of numbers. > > I had a feeling that we might be going in this direction. It strikes > me that this case

Re: [HACKERS] Range Types: empty ranges

2011-02-11 Thread David E. Wheeler
On Feb 11, 2011, at 10:28 AM, Josh Berkus wrote: > So, if we allow empty ranges of this kind, I would want a GUC for > "allow_empty_ranges". GUC you, josh. ;-P D -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.or

Re: [HACKERS] Range Types: empty ranges

2011-02-11 Thread Jeff Davis
On Fri, 2011-02-11 at 13:08 -0600, Kevin Grittner wrote: > It makes more sense in the context of a range of some type with a > clearly defined granularity. Our accounting system, for example, > can assign a new range of receipt IDs for each calendar year. If > you want a variable to represent the

Re: [HACKERS] Range Types: empty ranges

2011-02-11 Thread Kevin Grittner
"Kevin Grittner" wrote: > Basically, with a type having well-defined granularity, a [) range > could usefully represent, "start to last used", and start out > empty. I guess that would actually be "start to next available" -Kevin -- Sent via pgsql-hackers mailing list (pgsql-hackers@po

Re: [HACKERS] Range Types: empty ranges

2011-02-11 Thread Robert Haas
On Fri, Feb 11, 2011 at 2:06 PM, Jeff Davis wrote: > On Fri, 2011-02-11 at 10:28 -0800, Josh Berkus wrote: >> I guess I'm having trouble tying the concept of empty ranges to any >> reality external to the database. > > That's true, but in the same sense as zero has no meaning outside of the > data

Re: [HACKERS] Range Types: empty ranges

2011-02-11 Thread Kevin Grittner
Robert Haas wrote: >> I think that range '[15:15:00,15:15:00)' should be valid as a >> zero-length range between, for example, '[15:00:00,15:15:00)' and >> '[15:15:00,15:30:00)'. > > How would that actually work? I kind of agree with Josh: I'd be > inclined to make the type input function boot

Re: [HACKERS] Range Types: empty ranges

2011-02-11 Thread Jeff Davis
On Fri, 2011-02-11 at 10:28 -0800, Josh Berkus wrote: > I guess I'm having trouble tying the concept of empty ranges to any > reality external to the database. That's true, but in the same sense as zero has no meaning outside of the database. It's really that it has nice mathematical properties c

Re: [HACKERS] Range Types: empty ranges

2011-02-11 Thread Robert Haas
On Fri, Feb 11, 2011 at 1:50 PM, Kevin Grittner wrote: > Josh Berkus wrote: > >> if I, in one of my applications, accidentally defined something >> as having the range '('15:15:00','15:15:00')', I would *want* the >> database to through an error and not accept it. > > I can agree with that, but I

Re: [HACKERS] Range Types: empty ranges

2011-02-11 Thread Robert Haas
On Fri, Feb 11, 2011 at 1:11 PM, Jeff Davis wrote: > Similarly, "intersection" of ranges is somewhat analogous to > multiplication of numbers. I had a feeling that we might be going in this direction. It strikes me that this case is a bit like division by zero. It's kind of a nuisance that divi

Re: [HACKERS] Range Types: empty ranges

2011-02-11 Thread Kevin Grittner
Josh Berkus wrote: > if I, in one of my applications, accidentally defined something > as having the range '('15:15:00','15:15:00')', I would *want* the > database to through an error and not accept it. I can agree with that, but I think that range '[15:15:00,15:15:00)' should be valid as a ze

Re: [HACKERS] Range Types: empty ranges

2011-02-11 Thread Kevin Grittner
Jeff Davis wrote: > The philosophy is that they are essentially the "zero" value of > any range type. Like the number zero, it allows closure over > operations that would otherwise return an error. Well, zero has a pretty well defined and easy to understand meaning. How many ostriches do you h

Re: [HACKERS] Range Types: empty ranges

2011-02-11 Thread Josh Berkus
On 2/11/11 10:11 AM, Jeff Davis wrote: > Thoughts? Do the benefits outweigh the costs? I guess I'm having trouble tying the concept of empty ranges to any reality external to the database. For example, what would the time range: '('15:15:00','15:15:00')' ... represent exactly? "A non-existant

[HACKERS] Range Types: empty ranges

2011-02-11 Thread Jeff Davis
Do we want empty ranges? The philosophy is that they are essentially the "zero" value of any range type. Like the number zero, it allows closure over operations that would otherwise return an error. For instance, the number zero is useful because you can do things like: f(x) = 5x + 3; And even