Bad canonicalization for dateranges with 'infinity' bounds
Laurenz Albe <laurenz.albe@cybertec.at>
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: pgsql-hackers@lists.postgresql.org
Date: 2019-05-02T12:40:52Z
Lists: pgsql-hackers
https://www.postgresql.org/docs/current/rangetypes.html#RANGETYPES-INFINITE has:
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.
This does not work as expected for ranges with discrete base types,
notably daterange:
test=> SELECT '[2000-01-01,infinity]'::daterange;
daterange
-----------------------
[2000-01-01,infinity)
(1 row)
test=> SELECT '(-infinity,2000-01-01)'::daterange;
daterange
------------------------
[-infinity,2000-01-01)
(1 row)
This is because "daterange_canonical" makes no difference for 'infinity',
and adding one to infinity does not change the value.
I propose the attached patch which fixes the problem.
Yours,
Laurenz Albe
Commits
-
Fix daterange canonicalization for +/- infinity.
- 613eabcd51c3 12.0 landed
- 2be355498eaf 9.4.24 landed
- 8af1fccba2b1 9.5.19 landed
- 56afeb765177 9.6.15 landed
- 955089d4d74d 10.10 landed
- f5f20deda33b 11.5 landed
- e6feef571a01 13.0 landed