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

From Nathan Bossart
Subject Re: Fix overflow in justify_interval related functions
Date
Msg-id 20220215042306.GA2228390@nathanxps13
Whole thread Raw
In response to Re: Fix overflow in justify_interval related functions  (Joseph Koshakow <koshy44@gmail.com>)
Responses Re: Fix overflow in justify_interval related functions  (Joseph Koshakow <koshy44@gmail.com>)
List pgsql-hackers
On Mon, Feb 14, 2022 at 08:35:43PM -0500, Joseph Koshakow wrote:
> Good catch, I didn't think about that. Though if you are pre-justifying
> the days, then I don't think it's possible for the second addition to
> days to overflow. The maximum amount the days field could be after
> the first justification is 29. I think we can simplify it further to the
> attached patch.

LGTM.  I've marked this one as ready-for-committer.  It's a little weird
that justify_hours() and justify_days() can overflow in cases where there
is still a valid interval representation, but as Tom noted, those functions
have specific charters to follow.

> +        ereport(ERROR,
> +                (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
> +                errmsg("interval out of range")));

nitpick: I think there is ordinarily an extra space before errmsg() so that
it lines up with errcode().

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



pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: do only critical work during single-user vacuum?
Next
From: Michael Paquier
Date:
Subject: Re: pgsql: Add suport for server-side LZ4 base backup compression.