Re: Unexpected interval comparison
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Frazer McLean <frazer@frazermclean.co.uk>
Cc: pgsql-general@postgresql.org
Date: 2017-03-21T14:42:16Z
Lists: pgsql-general
Frazer McLean <frazer@frazermclean.co.uk> writes: > I came across an unexpected comparison (tested on PostgreSQL 9.4 and > 9.6) for intervals with a large difference in magnitude. > '1 year'::interval > '32618665 years'::interval; > Is this a bug? It looks like the problem is overflow of the result of interval_cmp_value, because it's trying to compute =# select '32618665'::int8 * 30 * 86400 * 1000000; ERROR: bigint out of range It's not immediately obvious how to avoid that while preserving the same comparison semantics :-( regards, tom lane
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