Re: [HACKERS] Range Types, discrete and/or continuous

2010-10-26 Thread Hitoshi Harada
2010/10/26 Robert Haas robertmh...@gmail.com: On Mon, Oct 25, 2010 at 8:13 PM, Jeff Davis pg...@j-davis.com wrote: On Mon, 2010-10-25 at 18:03 -0400, Robert Haas wrote: Hmm.  Do you have some concrete examples of cases where a range type might want to do some representational optimization?

Re: [HACKERS] Range Types, discrete and/or continuous

2010-10-26 Thread Jeff Davis
On Mon, 2010-10-25 at 21:07 -0400, Robert Haas wrote: See, that gets complicated, because now you're restricting the range of values that can be expressed by the range type to something less than the natural range of the data type. I am not sure the value of supporting that is sufficient to

Re: [HACKERS] Range Types, discrete and/or continuous

2010-10-26 Thread Robert Haas
On Tue, Oct 26, 2010 at 1:26 PM, Jeff Davis pg...@j-davis.com wrote: On Mon, 2010-10-25 at 21:07 -0400, Robert Haas wrote: See, that gets complicated, because now you're restricting the range of values that can be expressed by the range type to something less than the natural range of the data

Re: [HACKERS] Range Types, discrete and/or continuous

2010-10-26 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: On Tue, Oct 26, 2010 at 1:26 PM, Jeff Davis pg...@j-davis.com wrote: However, this is orthogonal, I think. I can always ask the user to specify everything when creating a Range Type, and then we can make them default to use the interface functions

Re: [HACKERS] Range Types, discrete and/or continuous

2010-10-26 Thread Robert Haas
On Tue, Oct 26, 2010 at 1:42 PM, Tom Lane t...@sss.pgh.pa.us wrote: Robert Haas robertmh...@gmail.com writes: On Tue, Oct 26, 2010 at 1:26 PM, Jeff Davis pg...@j-davis.com wrote: However, this is orthogonal, I think. I can always ask the user to specify everything when creating a Range Type,

Re: [HACKERS] Range Types, discrete and/or continuous

2010-10-25 Thread David Fetter
On Sun, Oct 24, 2010 at 06:59:34PM -0400, Tom Lane wrote: Jeff Davis pg...@j-davis.com writes: Last development cycle, one of the questions that was unresolved was whether to handle ranges like a discrete set (that is, [1,5) = [1,4] ) or continuous or both. Put me in the camp that says

Re: [HACKERS] Range Types, discrete and/or continuous

2010-10-25 Thread Heikki Linnakangas
On 25.10.2010 01:59, Tom Lane wrote: Jeff Davispg...@j-davis.com writes: If we treat those as discrete, then R1 = R2, R1 contains R2, R2 contains R1, and R2 - R1 = R1 - R2 = empty. However, if we treat those as continuous, then we get a contradiction: R2 contains R1 R1 does not contain R2

Re: [HACKERS] Range Types, discrete and/or continuous

2010-10-25 Thread Tom Lane
David Fetter da...@fetter.org writes: On Sun, Oct 24, 2010 at 06:59:34PM -0400, Tom Lane wrote: Put me in the camp that says you need both. I really seriously dislike the idea of representing [1, 2) as [1, 2-epsilon], mainly because there is often no portable value for epsilon.

Re: [HACKERS] Range Types, discrete and/or continuous

2010-10-25 Thread David Fetter
On Mon, Oct 25, 2010 at 10:21:49AM -0400, Tom Lane wrote: David Fetter da...@fetter.org writes: On Sun, Oct 24, 2010 at 06:59:34PM -0400, Tom Lane wrote: Put me in the camp that says you need both. I really seriously dislike the idea of representing [1, 2) as [1, 2-epsilon], mainly

Re: [HACKERS] Range Types, discrete and/or continuous

2010-10-25 Thread Jeff Davis
On Sun, 2010-10-24 at 18:59 -0400, Tom Lane wrote: Jeff Davis pg...@j-davis.com writes: Last development cycle, one of the questions that was unresolved was whether to handle ranges like a discrete set (that is, [1,5) = [1,4] ) or continuous or both. Put me in the camp that says you need

Re: [HACKERS] Range Types, discrete and/or continuous

2010-10-25 Thread Robert Haas
On Mon, Oct 25, 2010 at 12:51 PM, Jeff Davis pg...@j-davis.com wrote: On Sun, 2010-10-24 at 18:59 -0400, Tom Lane wrote: Jeff Davis pg...@j-davis.com writes: Last development cycle, one of the questions that was unresolved was whether to handle ranges like a discrete set (that is, [1,5) =

Re: [HACKERS] Range Types, discrete and/or continuous

2010-10-25 Thread Kevin Grittner
Jeff Davis pg...@j-davis.com wrote: Last development cycle, one of the questions that was unresolved was whether to handle ranges like a discrete set (that is, [1,5) = [1,4] ) or continuous or both. I think that discrete ranges are required. For instance, day range and IP address ranges

Re: [HACKERS] Range Types, discrete and/or continuous

2010-10-25 Thread Jeff Davis
On Mon, 2010-10-25 at 12:20 -0500, Kevin Grittner wrote: It would be very useful to be able to specify a granularity -- for example timestamps with a five minute granularity would be useful for scheduling appointments. In some cases the granularity might be inferred -- if we have a domain

Re: [HACKERS] Range Types, discrete and/or continuous

2010-10-25 Thread Robert Haas
On Mon, Oct 25, 2010 at 2:01 PM, Jeff Davis pg...@j-davis.com wrote: On Mon, 2010-10-25 at 12:20 -0500, Kevin Grittner wrote: It would be very useful to be able to specify a granularity -- for example timestamps with a five minute granularity would be useful for scheduling appointments. In

Re: [HACKERS] Range Types, discrete and/or continuous

2010-10-25 Thread Jeff Davis
On Mon, 2010-10-25 at 13:00 -0400, Robert Haas wrote: I'm still confused. It seems to me (and maybe I'm full of it) that the distinction between continuous ranges and discrete ranges is pretty minor. Suppose you have continuous ranges done, and working. The only thing you need to add for

Re: [HACKERS] Range Types, discrete and/or continuous

2010-10-25 Thread Jeff Davis
On Mon, 2010-10-25 at 14:11 -0400, Robert Haas wrote: On Mon, Oct 25, 2010 at 2:01 PM, Jeff Davis pg...@j-davis.com wrote: On Mon, 2010-10-25 at 12:20 -0500, Kevin Grittner wrote: It would be very useful to be able to specify a granularity -- for example timestamps with a five minute

Re: [HACKERS] Range Types, discrete and/or continuous

2010-10-25 Thread Robert Haas
On Mon, Oct 25, 2010 at 2:27 PM, Jeff Davis pg...@j-davis.com wrote: On Mon, 2010-10-25 at 13:00 -0400, Robert Haas wrote: I'm still confused.  It seems to me (and maybe I'm full of it) that the distinction between continuous ranges and discrete ranges is pretty minor.  Suppose you have

Re: [HACKERS] Range Types, discrete and/or continuous

2010-10-25 Thread Robert Haas
On Mon, Oct 25, 2010 at 2:44 PM, Jeff Davis pg...@j-davis.com wrote: On Mon, 2010-10-25 at 14:11 -0400, Robert Haas wrote: On Mon, Oct 25, 2010 at 2:01 PM, Jeff Davis pg...@j-davis.com wrote: On Mon, 2010-10-25 at 12:20 -0500, Kevin Grittner wrote: It would be very useful to be able to

Re: [HACKERS] Range Types, discrete and/or continuous

2010-10-25 Thread Jeff Davis
On Mon, 2010-10-25 at 18:28 -0400, Robert Haas wrote: Oh, maybe I'm confused. Are you saying you'd need multiple copies of the base type, or multiple range types based on a single base type? The latter. That is, if you want a timestamp range with granularity 1 second, and a timestamp range

Re: [HACKERS] Range Types, discrete and/or continuous

2010-10-25 Thread Jeff Davis
On Mon, 2010-10-25 at 18:03 -0400, Robert Haas wrote: Hmm. Do you have some concrete examples of cases where a range type might want to do some representational optimization? Let's say for instance you want to keep an timestamp range in 16 bytes. You could have an 8-byte timestamp, a 7-byte

Re: [HACKERS] Range Types, discrete and/or continuous

2010-10-25 Thread Robert Haas
On Mon, Oct 25, 2010 at 8:01 PM, Jeff Davis pg...@j-davis.com wrote: On Mon, 2010-10-25 at 18:28 -0400, Robert Haas wrote: Oh, maybe I'm confused.  Are you saying you'd need multiple copies of the base type, or multiple range types based on a single base type? The latter. That is, if you want

Re: [HACKERS] Range Types, discrete and/or continuous

2010-10-25 Thread Robert Haas
On Mon, Oct 25, 2010 at 8:13 PM, Jeff Davis pg...@j-davis.com wrote: On Mon, 2010-10-25 at 18:03 -0400, Robert Haas wrote: Hmm.  Do you have some concrete examples of cases where a range type might want to do some representational optimization? Let's say for instance you want to keep an

Re: [HACKERS] Range Types, discrete and/or continuous

2010-10-24 Thread Tom Lane
Jeff Davis pg...@j-davis.com writes: Last development cycle, one of the questions that was unresolved was whether to handle ranges like a discrete set (that is, [1,5) = [1,4] ) or continuous or both. Put me in the camp that says you need both. I really seriously dislike the idea of

Re: [HACKERS] Range Types, discrete and/or continuous

2010-10-24 Thread Robert Haas
On Sun, Oct 24, 2010 at 6:59 PM, Tom Lane t...@sss.pgh.pa.us wrote: Jeff Davis pg...@j-davis.com writes: Last development cycle, one of the questions that was unresolved was whether to handle ranges like a discrete set (that is, [1,5) = [1,4] ) or continuous or both. Put me in the camp that

Re: [HACKERS] Range types

2009-12-23 Thread decibel
On Dec 15, 2009, at 6:29 PM, Jeff Davis wrote: On Tue, 2009-12-15 at 18:06 -0600, decibel wrote: Now that varlena's don't have an enormous fixed overhead, perhaps it's worth looking at using them. Obviously some operations would be slower, but for your stated examples of auditing and history,

Re: [HACKERS] Range types

2009-12-17 Thread Dimitri Fontaine
Tom Lane t...@sss.pgh.pa.us writes: Dimitri Fontaine dfonta...@hi-media.com writes: Tom Lane t...@sss.pgh.pa.us writes: foreach p2_member in unnest(p2) loop p1 := array(select period_except(p1_member, p2_member) from unnest(p1) p1_member); end

Re: [HACKERS] Range types

2009-12-17 Thread Tom Lane
Dimitri Fontaine dfonta...@hi-media.com writes: Tom Lane t...@sss.pgh.pa.us writes: Hm, how would you do it with LATERAL? The problem is not so much composition as the need for a variable number of rounds of composition. Let's have a try at it: select p2_member, array_accum(p1) from

Re: [HACKERS] Range types

2009-12-17 Thread Andrew Gierth
Tom == Tom Lane t...@sss.pgh.pa.us writes: Someone mentioned LATERAL? Tom Lane t...@sss.pgh.pa.us writes: Hm, how would you do it with LATERAL? The problem is not so much composition as the need for a variable number of rounds of composition. Let's have a try at it: select

Re: [HACKERS] Range types

2009-12-17 Thread Scott Bailey
Tom Lane wrote: Dimitri Fontaine dfonta...@hi-media.com writes: Tom Lane t...@sss.pgh.pa.us writes: Hm, how would you do it with LATERAL? The problem is not so much composition as the need for a variable number of rounds of composition. Let's have a try at it: select p2_member,

Re: [HACKERS] Range types

2009-12-16 Thread Dimitri Fontaine
Tom Lane t...@sss.pgh.pa.us writes: foreach p2_member in unnest(p2) loop p1 := array(select period_except(p1_member, p2_member) from unnest(p1) p1_member); end loop; But maybe it can be done in a single SQL command. Yeah, as soon as you have LATERAL,

Re: [HACKERS] Range types

2009-12-16 Thread tomas
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Tue, Dec 15, 2009 at 04:16:28PM +0100, Nicolas Barbier wrote: [...] whatever and same whatever as before + the character with the lowest value in lexicographical ordering. I don't think it is possible to get anything in between those

Re: [HACKERS] Range types

2009-12-16 Thread tomas
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Tue, Dec 15, 2009 at 11:49:19AM -0800, David Fetter wrote: On Tue, Dec 15, 2009 at 11:31:05AM -0800, Scott Bailey wrote: Jeff Davis wrote: On Tue, 2009-12-15 at 10:19 -0500, Tom Lane wrote: Would it be OK if we handled float timestamp

Re: [HACKERS] Range types

2009-12-16 Thread Tom Lane
Dimitri Fontaine dfonta...@hi-media.com writes: Tom Lane t...@sss.pgh.pa.us writes: foreach p2_member in unnest(p2) loop p1 := array(select period_except(p1_member, p2_member) from unnest(p1) p1_member); end loop; But maybe it can be done in

Re: [HACKERS] Range types

2009-12-16 Thread Jeff Davis
On Sun, 2009-12-13 at 23:49 -0800, Scott Bailey wrote: So basically I have an anyrange pseudo type with the functions prev, next, last, etc defined. So instead of hard coding range types, we would allow the user to define their own range types. Basically if we are able to determine the

Re: [HACKERS] Range types

2009-12-16 Thread Robert Haas
On Wed, Dec 16, 2009 at 12:31 PM, Jeff Davis pg...@j-davis.com wrote: There's one problem, and that's for timestamptz ranges with intervals that include days and months. Timezone adjustments are just not well-defined for that kind of granule (nor would it be particularly useful even if it

Re: [HACKERS] Range types

2009-12-16 Thread Tom Lane
Jeff Davis pg...@j-davis.com writes: [ hacky special-case representation for discrete timestamp ranges ] I'm still not exactly clear on what the use-case is for discrete timestamp ranges, and I wonder how many people are going to be happy with a representation that can't handle a range that's

Re: [HACKERS] Range types

2009-12-16 Thread Scott Bailey
Jeff Davis wrote: On Sun, 2009-12-13 at 23:49 -0800, Scott Bailey wrote: So basically I have an anyrange pseudo type with the functions prev, next, last, etc defined. So instead of hard coding range types, we would allow the user to define their own range types. Basically if we are able to

Re: [HACKERS] Range types

2009-12-16 Thread Scott Bailey
Tom Lane wrote: Jeff Davis pg...@j-davis.com writes: [ hacky special-case representation for discrete timestamp ranges ] I'm still not exactly clear on what the use-case is for discrete timestamp ranges, and I wonder how many people are going to be happy with a representation that can't

Re: [HACKERS] Range types

2009-12-16 Thread Scott Bailey
Ok, silly question here. But how do you determine the length of a continuous range? By definition length of [a, b) and (a, b] = b-a. But what about (a,b) and [a,b]? Are we saying that because they are continuous, the difference between values included in the range and those excluded are so

Re: [HACKERS] Range types

2009-12-16 Thread Tom Lane
Scott Bailey arta...@comcast.net writes: As I pointed out off-list, I think the granularity for timestamp range should be limited to hours and smaller. Anything larger is asking for trouble. And quite honestly if they wanted day granularity, they should use date range. I'm still not real

Re: [HACKERS] Range types

2009-12-16 Thread Jeff Davis
On Wed, 2009-12-16 at 12:42 -0500, Robert Haas wrote: On Wed, Dec 16, 2009 at 12:31 PM, Jeff Davis pg...@j-davis.com wrote: There's one problem, and that's for timestamptz ranges with intervals that include days and months. Timezone adjustments are just not well-defined for that kind of

Re: [HACKERS] Range types

2009-12-16 Thread Jeff Davis
On Wed, 2009-12-16 at 12:50 -0500, Tom Lane wrote: I'm still not exactly clear on what the use-case is for discrete timestamp ranges, and I wonder how many people are going to be happy with a representation that can't handle a range that's open-ended on the left. Huh? We're miscommunicating

Re: [HACKERS] Range types

2009-12-16 Thread Alvaro Herrera
to...@tuxteam.de wrote: (and as Andrew Dunstan pointed out off-list: I was wrong with my bold assertion that one can squeeze infinitely many (arbitrary length) strings between two given. This is not always the case). Of course you can do that if you assume lexicographical order, or any other

Re: [HACKERS] Range types

2009-12-16 Thread Martijn van Oosterhout
On Tue, Dec 15, 2009 at 04:29:26PM -0800, Jeff Davis wrote: On Tue, 2009-12-15 at 18:06 -0600, decibel wrote: Now that varlena's don't have an enormous fixed overhead, perhaps it's worth looking at using them. Obviously some operations would be slower, but for your stated examples of

Re: [HACKERS] Range types

2009-12-16 Thread Martijn van Oosterhout
On Wed, Dec 16, 2009 at 10:57:19AM -0800, Scott Bailey wrote: Ok, silly question here. But how do you determine the length of a continuous range? By definition length of [a, b) and (a, b] = b-a. But what about (a,b) and [a,b]? Are we saying that because they are continuous, the

Re: [HACKERS] Range types

2009-12-16 Thread Tom Lane
Alvaro Herrera alvhe...@commandprompt.com writes: In short, I think that while it is possible to define ranges of strings, it is not as useful as one would like. Note it is not the *range* that is the problem, it is the assumption that there's a unique next string. There's no unique next in

Re: [HACKERS] Range types

2009-12-16 Thread Jeff Davis
On Wed, 2009-12-16 at 13:59 -0500, Tom Lane wrote: The argument for having granularity wired into the datatype seems to boil down to just space savings. I don't find that compelling enough to justify code contortions and user-visible restrictions on functionality. The argument (at least from

Re: [HACKERS] Range types

2009-12-16 Thread Alvaro Herrera
Tom Lane wrote: Alvaro Herrera alvhe...@commandprompt.com writes: In short, I think that while it is possible to define ranges of strings, it is not as useful as one would like. Note it is not the *range* that is the problem, it is the assumption that there's a unique next string.

Re: [HACKERS] Range types

2009-12-16 Thread Tom Lane
Martijn van Oosterhout klep...@svana.org writes: But a period type will take just one or two more bytes if you don't require alignment. Alignment on a varlena type seems silly anyway, since you'll be aligning the header byte rather than the content. You might still end up paying the alignment

Re: [HACKERS] Range types

2009-12-16 Thread Tom Lane
Jeff Davis pg...@j-davis.com writes: On Wed, 2009-12-16 at 12:50 -0500, Tom Lane wrote: I'm still not exactly clear on what the use-case is for discrete timestamp ranges, and I wonder how many people are going to be happy with a representation that can't handle a range that's open-ended on

Re: [HACKERS] Range types

2009-12-16 Thread Tom Lane
Jeff Davis pg...@j-davis.com writes: On Wed, 2009-12-16 at 13:59 -0500, Tom Lane wrote: The argument for having granularity wired into the datatype seems to boil down to just space savings. I don't find that compelling enough to justify code contortions and user-visible restrictions on

Re: [HACKERS] Range types

2009-12-16 Thread Martijn van Oosterhout
On Wed, Dec 16, 2009 at 03:57:44PM -0500, Tom Lane wrote: Jeff Davis pg...@j-davis.com writes: I still have not seen an answer to the problem of changing the representation of a continuous range. If you have the continuous range [5, 10], you're pretty much stuck with that representation,

Re: [HACKERS] Range types

2009-12-16 Thread Jeff Davis
On Wed, 2009-12-16 at 15:46 -0500, Tom Lane wrote: Huh? We're miscommunicating somewhere. Yeah, apparently. By open-ended I meant -infinity left bound, or null left bound if you prefer. Not sure if there's a better term. But my proposal allowed both of those things with various flag

Re: [HACKERS] Range types

2009-12-16 Thread Tom Lane
Martijn van Oosterhout klep...@svana.org writes: However, it does seem reasonable to allow people to restrict, either by typmod or a check constraint the kinds of values that can be stored in a particular column. Then an application can decide which way they want their intervals to work and

Re: [HACKERS] Range types

2009-12-16 Thread Jeff Davis
On Wed, 2009-12-16 at 15:57 -0500, Tom Lane wrote: Making it explicit doesn't fix the fact that you can't rely on the arithmetic to be exact. Can't rely on what arithmetic to be exact? Int64 timestamps should clearly work for granules of 1 second. If the administrator can choose a timestamp

Re: [HACKERS] Range types

2009-12-16 Thread Scott Bailey
Tom Lane wrote: Martijn van Oosterhout klep...@svana.org writes: However, it does seem reasonable to allow people to restrict, either by typmod or a check constraint the kinds of values that can be stored in a particular column. Then an application can decide which way they want their intervals

Re: [HACKERS] Range types

2009-12-16 Thread Jeff Davis
On Wed, 2009-12-16 at 13:59 -0500, Tom Lane wrote: For example, if you're trying to do classroom scheduling, it might be useful to constrain the periods to start and end on hour boundaries --- but the next thing you'll want is to have it know that the next slot after 5pm Friday is 8am Monday.

Re: [HACKERS] Range types

2009-12-16 Thread Jeff Davis
On Wed, 2009-12-16 at 14:29 +0100, to...@tuxteam.de wrote: This alone would practically preclude discrete -- int and float would behave quite differently (float's granules growing towards the edges or having to choose a bigger granule for float than for int in the first place). It may be an

Re: [HACKERS] Range types

2009-12-16 Thread tomas
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Wed, Dec 16, 2009 at 04:45:54PM -0300, Alvaro Herrera wrote: to...@tuxteam.de wrote: (and as Andrew Dunstan pointed out off-list: I was wrong with my bold assertion that one can squeeze infinitely many (arbitrary length) strings between

Re: [HACKERS] Range types

2009-12-15 Thread Greg Stark
On Tue, Dec 15, 2009 at 7:28 AM, to...@tuxteam.de wrote: The situation is even more restricted with floats (they are much smaller; thus one could say that they're more discrete than strings, even). Problem with floats is -- the granule is not the same size over the whole range (nasty), and

Re: [HACKERS] Range types

2009-12-15 Thread tomas
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Tue, Dec 15, 2009 at 01:09:02PM +, Greg Stark wrote: [...] In fact, as I only recently found out, one of the design goals of IEEE floats was specifically that they sort lexicographically and use every bit pattern. So you can alwys get the

Re: [HACKERS] Range types

2009-12-15 Thread Tom Lane
to...@tuxteam.de writes: (and as Andrew Dunstan pointed out off-list: I was wrong with my bold assertion that one can squeeze infinitely many (arbitrary length) strings between two given. This is not always the case). Really? If the string length is unbounded I think you were right.

Re: [HACKERS] Range types

2009-12-15 Thread Tom Lane
Greg Stark gsst...@mit.edu writes: In fact, as I only recently found out, one of the design goals of IEEE floats was specifically that they sort lexicographically and use every bit pattern. So you can alwys get the next float by just incrementing your float as an 64-bit integer. Yes that

Re: [HACKERS] Range types

2009-12-15 Thread Robert Haas
On Tue, Dec 15, 2009 at 9:58 AM, Tom Lane t...@sss.pgh.pa.us wrote: Greg Stark gsst...@mit.edu writes: In fact, as I only recently found out, one of the design goals of IEEE floats was specifically that they sort lexicographically and use every bit pattern. So you can alwys get the next float

Re: [HACKERS] Range types

2009-12-15 Thread Nicolas Barbier
2009/12/15 Tom Lane t...@sss.pgh.pa.us: to...@tuxteam.de writes: (and as Andrew Dunstan pointed out off-list: I was wrong with my bold assertion that one can squeeze infinitely many (arbitrary length) strings between two given. This is not always the case). Really?  If the string length is

Re: [HACKERS] Range types

2009-12-15 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: I also have to say that I'm very skeptical of the argument that there is only a small list of types people will want this for. I'm not sure that anyone has argued that. I did suggest that there might be a small list of types for which we should provide

Re: [HACKERS] Range types

2009-12-15 Thread Robert Haas
On Tue, Dec 15, 2009 at 10:19 AM, Tom Lane t...@sss.pgh.pa.us wrote: Robert Haas robertmh...@gmail.com writes: I also have to say that I'm very skeptical of the argument that there is only a small list of types people will want this for. I'm not sure that anyone has argued that.  I did

Re: [HACKERS] Range types

2009-12-15 Thread Tom Lane
Nicolas Barbier nicolas.barb...@gmail.com writes: Assuming lexicographical ordering (first different character determines order; end-of-string is sorted before anything else), consider the following two strings: whatever and same whatever as before + the character with the lowest value in

Re: [HACKERS] Range types

2009-12-15 Thread Florian G. Pflug
On 15.12.09 15:52 , Tom Lane wrote: to...@tuxteam.de writes: (and as Andrew Dunstan pointed out off-list: I was wrong with my bold assertion that one can squeeze infinitely many (arbitrary length) strings between two given. This is not always the case). Really? If the string length is

Re: [HACKERS] Range types

2009-12-15 Thread Andrew Dunstan
Tom Lane wrote: So the long and the short of it is that next/previous are not going to work for string types, maxlength or no maxlength. Even more importantly, I strongly doubt they would be of the slightest practical value. cheers andrew -- Sent via

Re: [HACKERS] Range types

2009-12-15 Thread Jeff Davis
On Tue, 2009-12-15 at 10:19 -0500, Tom Lane wrote: I'm not sure that anyone has argued that. I did suggest that there might be a small list of types for which we should provide discrete behavior (ie, with next/previous functions) and the rest could have continuous behavior (without that

Re: [HACKERS] Range types

2009-12-15 Thread Tom Lane
Jeff Davis pg...@j-davis.com writes: If I'm correct, continuous ranges always need two extra bits of storage for the exclusivity. But for timestamps, that means 16 bytes (2 x 8-byte timestamp) turns into 17 bytes, which is really more like 20 or 24 bytes with alignment. You probably need some

Re: [HACKERS] Range types

2009-12-15 Thread Scott Bailey
Jeff Davis wrote: On Tue, 2009-12-15 at 10:19 -0500, Tom Lane wrote: I'm not sure that anyone has argued that. I did suggest that there might be a small list of types for which we should provide discrete behavior (ie, with next/previous functions) and the rest could have continuous behavior

Re: [HACKERS] Range types

2009-12-15 Thread David Fetter
On Tue, Dec 15, 2009 at 11:31:05AM -0800, Scott Bailey wrote: Jeff Davis wrote: On Tue, 2009-12-15 at 10:19 -0500, Tom Lane wrote: Would it be OK if we handled float timestamp ranges as continuous and int64 timestamps discrete? That sounds like a recipe for disaster. Whatever timestamp

Re: [HACKERS] Range types

2009-12-15 Thread Tom Lane
David Fetter da...@fetter.org writes: On Tue, Dec 15, 2009 at 11:31:05AM -0800, Scott Bailey wrote: As for the extra bits, would it be better to just require continuous ranges to be either [] or [)? But I don't know which would be preferred. My inclination would be toward [), but Tom seemed to

Re: [HACKERS] Range types

2009-12-15 Thread Jeff Davis
On Tue, 2009-12-15 at 13:15 -0500, Tom Lane wrote: You probably need some flag bits anyway, so flailing frantically to avoid that doesn't seem like a profitable use of time. I think need and flailing are both a little too strong here. The biggest use case will almost certainly be ranges of

Re: [HACKERS] Range types

2009-12-15 Thread Tom Lane
Jeff Davis pg...@j-davis.com writes: I think need and flailing are both a little too strong here. The biggest use case will almost certainly be ranges of timestamps, and most of those people will have no use for flag bits (or if they do, it might not be worth an 8-byte-per-value overhead).

Re: [HACKERS] Range types

2009-12-15 Thread Scott Bailey
David Fetter wrote: On Tue, Dec 15, 2009 at 11:31:05AM -0800, Scott Bailey wrote: Jeff Davis wrote: On Tue, 2009-12-15 at 10:19 -0500, Tom Lane wrote: Would it be OK if we handled float timestamp ranges as continuous and int64 timestamps discrete? That sounds like a recipe for disaster.

Re: [HACKERS] Range types

2009-12-15 Thread Jeff Davis
On Tue, 2009-12-15 at 11:49 -0800, David Fetter wrote: That sounds like a recipe for disaster. Whatever timestamp ranges are, float and int64 should be treated the same way so as not to get surprises due to implementation details. It's a compile-time option that will change the semantics of

Re: [HACKERS] Range types

2009-12-15 Thread Tom Lane
Jeff Davis pg...@j-davis.com writes: On Tue, 2009-12-15 at 11:49 -0800, David Fetter wrote: FWIW, I think it would be a good idea to treat timestamps as continuous in all cases. I disagree. There is a lot of value in treating timestamp ranges as discrete. One big reason is that the ranges

Re: [HACKERS] Range types

2009-12-15 Thread Tom Lane
Scott Bailey arta...@comcast.net writes: Ok, let me give an example of what we can do with the current implementations that would not be possible with timestamps if we implement as suggested. ... The function below takes two period arrays that can have overlapping and adjacent elements. It

Re: [HACKERS] Range types

2009-12-15 Thread Scott Bailey
Tom Lane wrote: Jeff Davis pg...@j-davis.com writes: On Tue, 2009-12-15 at 11:49 -0800, David Fetter wrote: FWIW, I think it would be a good idea to treat timestamps as continuous in all cases. I disagree. There is a lot of value in treating timestamp ranges as discrete. One big reason

Re: [HACKERS] Range types

2009-12-15 Thread Scott Bailey
If this were an amazingly short and beautiful piece of code, it might support your argument, but it's neither. Well we can't all be arrogant brainiacs. -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription:

Re: [HACKERS] Range types

2009-12-15 Thread Tom Lane
I wrote: The proposed problem is certainly soluble without any assumptions of discreteness. To be concrete, I think it could be approached like this: Assume the datatype provides a built-in function period_except(p1 period, p2 period) returns setof period which can return zero, one,

Re: [HACKERS] Range types

2009-12-15 Thread Jeff Davis
On Tue, 2009-12-15 at 17:17 -0500, Tom Lane wrote: Actually, that is exactly one of the reasons why what you propose is a *bad* idea. You want to institutionalize application dependence on a non-portable implementation detail, namely the granularity of machine representation of what's in

Re: [HACKERS] Range types

2009-12-15 Thread Josh Berkus
On 12/15/09 2:40 PM, Scott Bailey wrote: If this were an amazingly short and beautiful piece of code, it might support your argument, but it's neither. Well we can't all be arrogant brainiacs. Tom, Scott, Let's keep it constructive here. Thanks! --Josh -- Sent via pgsql-hackers

Re: [HACKERS] Range types

2009-12-15 Thread decibel
On Dec 15, 2009, at 5:40 PM, Jeff Davis wrote: If you think I'm proposing that we drop inclusivity/exclusivity before telling the application, that's not what I'm proposing at all. I'm proposing that, at least in some circumstances, it's important to be able to display the same value in

Re: [HACKERS] Range types

2009-12-15 Thread decibel
On Dec 15, 2009, at 11:34 AM, Jeff Davis wrote: On Tue, 2009-12-15 at 10:19 -0500, Tom Lane wrote: I'm not sure that anyone has argued that. I did suggest that there might be a small list of types for which we should provide discrete behavior (ie, with next/previous functions) and the rest

Re: [HACKERS] Range types

2009-12-15 Thread Christophe Pettus
On Dec 15, 2009, at 3:40 PM, Jeff Davis wrote: Based on the premise that timestamps are a continuous value and the granularity/precision is entirely an implementation detail, you're right. But I disagree with the premise, at least in some cases that I think are worthwhile. The argument is,

Re: [HACKERS] Range types

2009-12-15 Thread Scott Bailey
Tom Lane wrote: I wrote: The proposed problem is certainly soluble without any assumptions of discreteness. To be concrete, I think it could be approached like this: Assume the datatype provides a built-in function period_except(p1 period, p2 period) returns setof period which can

Re: [HACKERS] Range types

2009-12-15 Thread Jeff Davis
On Tue, 2009-12-15 at 18:06 -0600, decibel wrote: Now that varlena's don't have an enormous fixed overhead, perhaps it's worth looking at using them. Obviously some operations would be slower, but for your stated examples of auditing and history, I suspect that you're not going to notice the

Re: [HACKERS] Range types

2009-12-15 Thread Jeff Davis
On Tue, 2009-12-15 at 18:03 -0600, decibel wrote: I think it would help the discussion if you could provide some real examples. I suspect you're thinking of things like scheduling apps, where it's important to be able to do things like what's the next available time slot?. There are probably

Re: [HACKERS] Range types

2009-12-15 Thread Jeff Davis
On Tue, 2009-12-15 at 16:08 -0800, Christophe Pettus wrote: The argument is, in essence: DECIMAL is continuous. DECIMAL(10,3) is discrete. timestamptz in general is a continuous value (unless we're talking Planck times :) ). There is no way for us to guarantee that

Re: [HACKERS] Range types

2009-12-14 Thread Takahiro Itagaki
Scott Bailey arta...@comcast.net wrote: CREATE TYPE periodtz AS RANGE (timestamptz, '1 microsecond'::interval); What does the second argument mean? Is it a default interval? So basically I have a pg_range table to store the base typeid, a text field for the granule value and the granule

Re: [HACKERS] Range types

2009-12-14 Thread tomas
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Sun, Dec 13, 2009 at 11:49:53PM -0800, Scott Bailey wrote: I had proposed a temporal contrib module earlier and you wanted to see support for many range types not just timestamptz [...] So basically I have an anyrange pseudo type with the

Re: [HACKERS] Range types

2009-12-14 Thread Robert Haas
On Mon, Dec 14, 2009 at 4:06 AM, to...@tuxteam.de wrote: As another approach, what about storing typeid in typmod? (Oid can be assumed to be stored in int32.) For example,     CREATE TABLE tbl ( r range(timestamp) );     SELECT '[ 2.0, 3.0 )'::range(float); There might be some overhead to

Re: [HACKERS] Range types

2009-12-14 Thread tomas
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Mon, Dec 14, 2009 at 06:02:04AM -0500, Robert Haas wrote: On Mon, Dec 14, 2009 at 4:06 AM, to...@tuxteam.de wrote: [...] This looks more natural to me too. It 's very different than the way we've traditionally used typmod, though, which

Re: [HACKERS] Range types

2009-12-14 Thread Dimitri Fontaine
Scott Bailey arta...@comcast.net writes: So basically I have an anyrange pseudo type with the functions prev, next, last, etc defined. So instead of hard coding range types, we would allow the user to define their own range types. Basically if we are able to determine the previous and next

Re: [HACKERS] Range types

2009-12-14 Thread Martijn van Oosterhout
On Sun, Dec 13, 2009 at 11:49:53PM -0800, Scott Bailey wrote: So basically I have an anyrange pseudo type with the functions prev, next, last, etc defined. So instead of hard coding range types, we would allow the user to define their own range types. Basically if we are able to

Re: [HACKERS] Range types

2009-12-14 Thread Tom Lane
Scott Bailey arta...@comcast.net writes: So basically I have an anyrange pseudo type with the functions prev, next, last, etc defined. So instead of hard coding range types, we would allow the user to define their own range types. Basically if we are able to determine the previous and next

<    1   2   3   4   5   >