The documentation says:
Also, some element types have a notion of “infinity”, but that is just another value so far as the range type mechanisms are concerned. For example, in timestamp ranges, [today,]
means the same thing as [today,)
. But [today,infinity]
means something different from [today,infinity)
— the latter excludes the special timestamp value infinity
.
That seems to flatly contradict your observations, because
SELECT 'infinity'::date;
date
----------
infinity
(1 row)
The explanation for this behavior is that PostgreSQL converts ranges of “discrete” types (date
and the integer
types) into their “canonical” representation:
SELECT '[2010-01-01,2010-02-28]'::daterange;
daterange
-------------------------
[2010-01-01,2010-03-01)
(1 row)
This is what happened in your example: PostgreSQL adds 1 to infinity
(which doesn't change the value) and converts the inclusive upper bound to an exclusive upper bound.
Now this is arguably not the correct behavior, because now infinity
is not part of the interval any more. I have sent in a patch for that, and it got fixed with commit e6feef571a.