Re: BUG #18200: Undefined behaviour in interval_div - Mailing list pgsql-bugs

From Laurenz Albe
Subject Re: BUG #18200: Undefined behaviour in interval_div
Date
Msg-id c8374b1627add66a9593de562be16142cd690095.camel@cybertec.at
Whole thread Raw
In response to BUG #18200: Undefined behaviour in interval_div  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #18200: Undefined behaviour in interval_div  (Dean Rasheed <dean.a.rasheed@gmail.com>)
List pgsql-bugs
On Wed, 2023-11-15 at 13:00 +0000, PG Bug reporting form wrote:
> The following query:
> SELECT interval '12000000 months' / 0.001;
>
> triggers an ubsan-detected error:
> timestamp.c:3408:18: runtime error: 1.2e+10 is outside the range of
> representable values of type 'int'
>
> Without ubsan the result is:
>  -178956970 years -8 mons -2562047788:00:54.775808

How about the attached fix?

Yours,
Laurenz Albe

Attachment

pgsql-bugs by date:

Previous
From: "Melzer Kassensysteme"
Date:
Subject: LIMIT clause extremely slow
Next
From: Christophe Pettus
Date:
Subject: Re: LIMIT clause extremely slow