pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: pgsql-hackers@lists.postgresql.org
Subject: Bad canonicalization for dateranges with 'infinity' bounds
Date: Thu, 02 May 2019 14:40:52 +0200
Message-ID: <77f24ea19ab802bc9bc60ddbb8977ee2d646aec1.camel@cybertec.at> (raw)

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






view thread (10+ messages)  latest in thread

Message-ID: <77f24ea19ab802bc9bc60ddbb8977ee2d646aec1.camel@cybertec.at>
Permalink:  ../77f24ea19ab802bc9bc60ddbb8977ee2d646aec1.camel@cybertec.at/
Also on:    postgresql.org/message-id/77f24ea19ab802bc9bc60ddbb8977ee2d646aec1.camel@cybertec.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: laurenz.albe@cybertec.at, pgsql-hackers@lists.postgresql.org
  Subject: Re: Bad canonicalization for dateranges with 'infinity' bounds
  In-Reply-To: <77f24ea19ab802bc9bc60ddbb8977ee2d646aec1.camel@cybertec.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox