Fix formatting of Interval output

From: Joseph Koshakow <koshy44(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Fix formatting of Interval output
Date: 2022-02-18 03:04:05
Message-ID: CAAvxfHfjBGpsXccdbWyMMDXg8bn48ptfnEag9qwk8m5sziVs2A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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:
postgres=# SELECT INTERVAL '-2147483648 hrs';
interval
--------------------
--2147483648:00:00
(1 row)

Cheers,
Joe Koshakow

Attachment Content-Type Size
v1-0001-Fix-Interval-formatting-with-INT_MIN-hours.patch text/x-patch 2.5 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2022-02-18 03:07:21 Re: Assert in pageinspect with NULL pages
Previous Message Michael Paquier 2022-02-18 03:02:22 Re: Assert in pageinspect with NULL pages