Re: Fix overflow in justify_interval related functions - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Fix overflow in justify_interval related functions
Date
Msg-id 2914902.1644864956@sss.pgh.pa.us
Whole thread Raw
In response to Re: Fix overflow in justify_interval related functions  (Nathan Bossart <nathandbossart@gmail.com>)
Responses Re: Fix overflow in justify_interval related functions  (Nathan Bossart <nathandbossart@gmail.com>)
List pgsql-hackers
Nathan Bossart <nathandbossart@gmail.com> writes:
> On Sun, Feb 13, 2022 at 01:28:38PM -0500, Joseph Koshakow wrote:
>> +SELECT justify_hours(interval '2147483647 days 24 hrs');
>> +ERROR:  interval out of range

> The docs [0] claim that the maximum value for interval is 178 million
> years, but this test case is only ~6 million.  Should we instead rework the
> logic to avoid overflow for this case?

I think the docs are misleading you on this point.  The maximum
value of the months part of an interval is 2^31 months or
about 178Myr, but what we're dealing with here is days, which
likewise caps at 2^31 days.  justify_hours is not chartered
to transpose up to months, so it can't avoid that limit.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Christoph Berg
Date:
Subject: Re: Non-decimal integer literals
Next
From: Bruce Momjian
Date:
Subject: Re: [Proposal] Fully WAL logged CREATE DATABASE - No Checkpoints