Re: Range Types, constructors, and the type system

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Robert Haas <robertmhaas(at)gmail(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 05:19:45
Message-ID: 1309929585.3012.97.camel@jdavis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

Regards,
Jeff Davis

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kohei KaiGai 2011-07-06 05:25:54 Re: [v9.2] SECURITY LABEL on shared database object
Previous Message Tom Lane 2011-07-06 04:24:09 Re: weird cast behavior in "IN (values)" clause