Re: casting between range types

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: casting between range types
Date: 2011-08-31 15:36:17
Message-ID: 4E5E54F1.3090908@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 31.08.2011 18:09, Jeff Davis wrote:
> On Wed, 2011-08-31 at 09:20 +0300, Heikki Linnakangas wrote:
>> On 31.08.2011 09:14, Jeff Davis wrote:
>>> First, a range is really a set. So if we take '[1,10)'::int4range and
>>> cast that to numrange, we end up moving from a set of exactly 9 elements
>>> to a set of an infinite number of elements. Going the other way is
>>> probably worse.
>
> ...
>
>> Can you only provide casts that make sense, like between int4 and
>> numeric range types, and leave out the ones that don't?
>
> There are certainly some casts that make sense, like
> int4range->int8range. Do you think int4range->numrange also makes sense?

Not sure. It depends on whether you think of '[1,8]'::int4range as a
finite set of the integers between 1 and 8, or as a continuous range
from 1 to 8. I don't see harm in providing explicit casts like that, but
I would be very conservative with implicit and assignment casts.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2011-08-31 15:36:26 Re: rename index fields bug
Previous Message Heikki Linnakangas 2011-08-31 15:24:24 Re: rename index fields bug