Re: Fix formatting of Interval output

2022-02-19 Thread Tom Lane
Joseph Koshakow writes: > On Sat, Feb 19, 2022 at 12:00 PM Tom Lane wrote: >> I think that messing with struct pg_tm might have too many side-effects. >> However, pg_tm isn't all that well adapted to intervals in the first >> place, so it'd make sense to make a new struct specifically for interva

Re: Fix formatting of Interval output

2022-02-19 Thread Joseph Koshakow
On Sat, Feb 19, 2022 at 12:00 PM Tom Lane wrote: > I think that messing with struct pg_tm might have too many side-effects. > However, pg_tm isn't all that well adapted to intervals in the first > place, so it'd make sense to make a new struct specifically for interval > decoding. Yeah that's a g

Re: Fix formatting of Interval output

2022-02-19 Thread Tom Lane
Joseph Koshakow writes: > On Fri, Feb 18, 2022 at 11:44 PM Tom Lane wrote: >> I wonder if the most reasonable fix would be to start using int64 >> instead of int arithmetic for the values that are potentially large. >> I doubt that we'd be taking much of a performance hit on modern >> hardware.

Re: Fix formatting of Interval output

2022-02-19 Thread Joseph Koshakow
On Fri, Feb 18, 2022 at 11:44 PM Tom Lane wrote: > > Joseph Koshakow writes: > > When formatting the output of an Interval, we call abs() on the hours > > field of the Interval. Calling abs(INT_MIN) returns back INT_MIN > > causing the output to contain two '-' characters. The attached patch > >

Re: Fix formatting of Interval output

2022-02-18 Thread Tom Lane
Joseph Koshakow writes: > When formatting the output of an Interval, we call abs() on the hours > field of the Interval. Calling abs(INT_MIN) returns back INT_MIN > causing the output to contain two '-' characters. The attached patch > fixes that issue by special casing INT_MIN hours. Good catch,

Fix formatting of Interval output

2022-02-17 Thread Joseph Koshakow
When formatting the output of an Interval, we call abs() on the hours field of the Interval. Calling abs(INT_MIN) returns back INT_MIN causing the output to contain two '-' characters. The attached patch fixes that issue by special casing INT_MIN hours. Here is an example of the issue: postgre