Re: Range Types - typo + NULL string constructor

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: Thom Brown <thom(at)linux(dot)com>, Florian Pflug <fgp(at)phlo(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>, Erik Rijkers <er(at)xs4all(dot)nl>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Range Types - typo + NULL string constructor
Date: 2011-10-10 16:53:54
Message-ID: 651.1318265634@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Jeff Davis <pgsql(at)j-davis(dot)com> writes:
> On Mon, 2011-10-10 at 14:27 +0100, Thom Brown wrote:
>> I don't know if this has already been discussed, but can you explain
>> the following:
>>
>> postgres=# select '[1,8]'::int4range;
>> int4range
>> -----------
>> [1,9)
>> (1 row)
>>
>> It seems unintuitive to represent a discrete range using an exclusive
>> upper bound. While I agree that the value itself is correct, it's
>> representation looks odd. Is it necessary?

> The "canonicalize" function (specified at type creation time) allows you
> to specify the canonical output representation. So, I can change the
> canonical form for discrete ranges to use '[]' notation if we think
> that's more expected.

What if I write '[1,INT_MAX]'::int4range? The open-parenthesis form will
fail with an integer overflow. I suppose you could canonicalize it to
an unbounded range, but that seems unnecessarily surprising.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-10-10 16:58:51 Re: WIP: Join push-down for foreign tables
Previous Message Jeff Davis 2011-10-10 16:44:51 Re: Range Types - typo + NULL string constructor