Re: Range Types, discrete and/or continuous - Mailing list pgsql-hackers

From Jeff Davis
Subject Re: Range Types, discrete and/or continuous
Date
Msg-id 1288025465.8516.829.camel@jdavis
Whole thread Raw
In response to Re: Range Types, discrete and/or continuous  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Range Types, discrete and/or continuous
List pgsql-hackers
On Sun, 2010-10-24 at 18:59 -0400, Tom Lane wrote:
> Jeff Davis <pgsql@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 representing [1, 2) as [1, 2-epsilon], mainly because there
> is often no portable value for epsilon.  Dump-and-restore would be quite
> hazardous.
> 

OK. I tried to present a couple approaches for achieving that. To
summarize:

The most obvious way would be different code paths and DDL options that
let postgresql know whether it's continuous or discrete. That may make
it easier to create new range types with just DDL and without defining
any low-level functions, and postgresql may be able to take care of
representational issues.

Another way, suggested by Nathan Boley, is to require the type
definition to do a lot of work and define its own representation that's
opaque to postgres. Then, postgres would ask for information through
accessors like min (null if open at beginning), max (null if open at
end), upper bound, lower bound, and flags (to indicate null or infinite
boundaries). This requires more work to define a new range type, and it
certainly couldn't be done with DDL only. However, it seems to allow
discrete and continuous ranges to work together more seamlessly and
share more code. I am leaning toward this approach.

Regards,Jeff Davis



pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: Composite Types and Function Parameters
Next
From: Peter Eisentraut
Date:
Subject: Re: O_DSYNC broken on MacOS X?