Re: Range Types, constructors, and the type system

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: Florian Pflug <fgp(at)phlo(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Range Types, constructors, and the type system
Date: 2011-07-06 13:10:02
Message-ID: CA+TgmoZ=fGup0MSdJmc-oNT=RUjbzuFYHV-EFGmh0jDOx7O+cQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jul 6, 2011 at 1:19 AM, Jeff Davis <pgsql(at)j-davis(dot)com> wrote:
> On Tue, 2011-07-05 at 13:06 -0400, Robert Haas wrote:
>> On Tue, Jul 5, 2011 at 12:54 PM, Jeff Davis <pgsql(at)j-davis(dot)com> wrote:
>> > It would be something like: range_co(1,8)::int8range
>> >
>> > (just so we're comparing apples to apples)
>> >
>> > The intermediate type proposal doesn't require that we move the "c" and
>> > "o" into the parameter list.
>>
>> Well, you have to specify the bounds somewhere...
>
> That's true. In my example it's in the function name.
>
>> OK, so let's pass the information on the bounds as a separate
>> argument.  Like this:
>>
>> int8range(1,8,'co')
>
> That has a lot going for it, in the sense that it avoids dealing with
> the type problems.
>
>> Then you can instead pass 'o' for open or 'i' for infinity (passing
>> NULL for the corresponding argument position in that case).  The third
>> argument can be optional and default to 'cc'.
>
> The fact that there can be a default for the third argument makes this
> quite a lot more appealing than I had originally thought (although I
> think 'co' is the generally-accepted default).
>
> There's some slight ugliness around the NULL/infinity business, but I
> think that I could be convinced. I'd like to avoid confusion between
> NULL and infinity if possible.

I was thinking that if you passed 'i' for one of the bounds, it would
ignore the supplied argument and substitute its special infinity
value. But you'd still need to supply some argument in that position,
which could be NULL or anything else. It doesn't really seem worth
having additional constructor functions to handle the case where one
or both arguments are infinite.

--
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 Robert Haas 2011-07-06 13:55:01 Re: Avoid index rebuilds for no-rewrite ALTER TABLE ALTER TYPE
Previous Message Craig Ringer 2011-07-06 12:56:20 Re: Review of VS 2010 support patches