Re: Why does the range type's upper function behave inconsistently?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dane Foster <studdugie(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Why does the range type's upper function behave inconsistently?
Date: 2015-07-05 17:28:07
Message-ID: 10004.1436117287@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dane Foster <studdugie(at)gmail(dot)com> writes:
> I don't understand the inconsistent behavior of the range types' upper
> function in regard to inclusive ranges.

The behavior is different for discrete vs. continuous ranges. For
example,

regression=# select int4range(1, 4, '[]');
int4range
-----------
[1,5)
(1 row)

regression=# select numrange(1, 4, '[]');
numrange
----------
[1,4]
(1 row)

In the discrete case we normalize the bounds to '[)' style so that ranges
that contain the same sets of values will compare as equal even when they
were written differently. But there's no practical way to do that for
continuous types. See
http://www.postgresql.org/docs/9.4/static/rangetypes.html#RANGETYPES-DISCRETE

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2015-07-05 17:33:03 Re: Why does the range type's upper function behave inconsistently?
Previous Message Julien Rouhaud 2015-07-05 17:25:03 Re: Why does the range type's upper function behave inconsistently?