Re: Range Types, discrete and/or continuous

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: Range Types, discrete and/or continuous
Дата
Msg-id AANLkTiks_x93_k82b4f_ga634wCi0oeb9fTrUrF28EGM@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Range Types, discrete and/or continuous  (Jeff Davis <pgsql@j-davis.com>)
Ответы Re: Range Types, discrete and/or continuous  (Jeff Davis <pgsql@j-davis.com>)
Список pgsql-hackers
On Mon, Oct 25, 2010 at 12:51 PM, Jeff Davis <pgsql@j-davis.com> wrote:
> 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.

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 discrete ranges (I think) is a
canonicalization function that converts a range with one or both ends
open to a range with both ends closed.  Then you just apply this
canonicalization functions to every value supplied by the user before
doing anything else with it.  Poof, discrete ranges!  What am I
missing?

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: O_DSYNC broken on MacOS X?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: add label to enum syntax