Bad canonicalization for dateranges with 'infinity' bounds

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Bad canonicalization for dateranges with 'infinity' bounds
Date: 2019-05-02 12:40:52
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers 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;
(1 row)

test=> SELECT '(-infinity,2000-01-01)'::daterange;
(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.

Laurenz Albe


Browse pgsql-hackers by date

  From Date Subject
Next Message Laurenz Albe 2019-05-02 12:49:23 Re: Bad canonicalization for dateranges with 'infinity' bounds
Previous Message Tomas Vondra 2019-05-02 12:35:45 Re: walsender vs. XLogBackgroundFlush during shutdown