Re: Fix overflow in justify_interval related functions

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Joseph Koshakow <koshy44(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Fix overflow in justify_interval related functions
Date: 2022-02-14 19:15:09
Message-ID: 20220214191509.GA2040852@nathanxps13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Feb 14, 2022 at 01:55:56PM -0500, Tom Lane wrote:
> Nathan Bossart <nathandbossart(at)gmail(dot)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.

Makes sense. So we could likely avoid it for justify_interval, but the
others are at the mercy of the interval implementation.

--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2022-02-14 19:18:58 Re: Time to drop plpython2?
Previous Message Bruce Momjian 2022-02-14 18:58:39 Re: [Proposal] Fully WAL logged CREATE DATABASE - No Checkpoints