Unexpected interval comparison
Frazer McLean <frazer@frazermclean.co.uk>
From: Frazer McLean <frazer@frazermclean.co.uk>
To: pgsql-general@postgresql.org
Date: 2017-03-21T13:57:09Z
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
Commits
-
Fix integer-overflow problems in interval comparison.
- fd52b8834330 9.6.3 landed
- d68a2b20ae2c 9.5.7 landed
- 8851bcf8813b 9.4.12 landed
- df1a699e5ba3 10.0 landed