Unexpected interval comparison

From: Frazer McLean <frazer(at)frazermclean(dot)co(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Unexpected interval comparison
Date: 2017-03-21 13:57:09
Message-ID: 1490104629.422698.918452336.26FA96B7@webmail.messagingengine.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I came across an unexpected comparison (tested on PostgreSQL 9.4 and
9.6) for intervals with a large difference in magnitude.

I narrowed it down to this example, where comparisons with this range
give the wrong value:

postgres=# SELECT

'1 year'::interval > '3854933 years'::interval,

'1 year'::interval > '3854934 years'::interval,

'1 year'::interval > '32618664 years'::interval,

'1 year'::interval > '32618665 years'::interval;

?column? | ?column? | ?column? | ?column?

----------+----------+----------+----------

f | t | t | f

(1 row)

Is this a bug? Should I not be comparing intervals? It would seem the
interval type has enough information to give the correct answer here.

Regards,

Frazer McLean

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2017-03-21 14:42:16 Re: Unexpected interval comparison
Previous Message Michael Paquier 2017-03-21 03:39:27 Re: how can I use "pg_basebackup" and not include pg_log of master ?