Re: range_adjacent and discrete ranges

Jeff Davis <pgsql@j-davis.com>

From: Jeff Davis <pgsql@j-davis.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Florian Pflug <fgp@phlo.org>, pgsql-hackers@postgresql.org
Date: 2011-11-18T16:56:06Z
Lists: pgsql-hackers
On Fri, 2011-11-18 at 10:33 -0500, Tom Lane wrote:
> regression=# select int4range(4,4,'(]');
> ERROR:  range lower bound must be less than or equal to range upper bound
> regression=# select int4range(4,4,'()');
> ERROR:  range lower bound must be less than or equal to range upper bound
> 
> Would it be better for them to silently transform such cases to "empty"?

That had crossed my mind, but I read the first as saying that it
includes 4 and doesn't include 4, which is a little confusing.

But I wouldn't object to making them return empty ranges. Seeing that we
removed some other errors in favor of returning something, it might be a
little more consistent to return empty when possible.

I wouldn't like to extend that to int4range(4,3), however. When the
upper bound is less than the lower bound, it's almost certainly a
mistake, and the user should be informed.

By the way, what does this have to do with canonical functions? This
seems more like a constructor issue, and there is already a
zero-argument constructor to make empty ranges.

Regards,
	Jeff Davis