Re: Range Types, discrete and/or continuous

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Range Types, discrete and/or continuous
Date: 2010-10-25 22:28:48
Message-ID: AANLkTikRyvpex6KFHHUuEFa4G9wYX565LU10-1btZpBn@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Oct 25, 2010 at 2:44 PM, Jeff Davis <pgsql(at)j-davis(dot)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 <pgsql(at)j-davis(dot)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 some cases the granularity might be
>> >> inferred -- if we have a domain defined as numeric(13,2), it would
>> >> be nice if the default granularity was 0.01::numeric.
>> >
>> > I don't think typmod really helps us much. It's more a property of the
>> > column than the type.
>> >
>> > To specify different granularities, I don't think we can avoid
>> > specifying new types with their own entries in pg_type.
>>
>> Why?
>
> Because typmod doesn't survive through a function call. Even if it did,
> I don't think typmod has a real answer for type promotion, implicit
> casting etc.
>
> If we lose the typmod (and therefore the granularity), then a function
> like "adjacent" is difficult to answer if we use a closed-closed
> canonical representation (as you suggested); and if we use a closed-open
> representation then it's difficult to answer a question like whether a
> range contains a specific timestamp.
>
> Can I turn the question around and ask how you intend to make it work
> without new entries in pg_type?

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?

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg 2010-10-25 22:38:23 Re: Composite Types and Function Parameters
Previous Message Robert Haas 2010-10-25 22:03:27 Re: Range Types, discrete and/or continuous