From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Frazer McLean <frazer(at)frazermclean(dot)co(dot)uk> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Unexpected interval comparison |
Date: | 2017-03-21 14:52:25 |
Message-ID: | 375c9e5a-960f-942c-913f-55632a1f0a90@aklaver.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 03/21/2017 07:42 AM, Tom Lane wrote:
> Frazer McLean <frazer(at)frazermclean(dot)co(dot)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 :-(
Not sure if it helps but this works:
test=# select extract(epoch from '1 year'::interval) > extract(epoch
from '32618665 years'::interval);
?column?
----------
f
>
> regards, tom lane
>
>
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Klaus P. Pieper | 2017-03-21 15:20:17 | Re: Why is this functional index not used? |
Previous Message | Tom Lane | 2017-03-21 14:42:16 | Re: Unexpected interval comparison |