Re: Range Types, discrete and/or continuous

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Range Types, discrete and/or continuous
Date: 2010-10-25 16:51:05
Message-ID: 1288025465.8516.829.camel@jdavis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, 2010-10-24 at 18:59 -0400, Tom Lane wrote:
> Jeff Davis <pgsql(at)j-davis(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2010-10-25 16:51:26 Re: O_DSYNC broken on MacOS X?
Previous Message Pavel Stehule 2010-10-25 16:46:47 Re: Composite Types and Function Parameters