Re: BUG #18200: Undefined behaviour in interval_div

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: exclusion(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18200: Undefined behaviour in interval_div
Date: 2023-11-15 17:23:08
Message-ID: c8374b1627add66a9593de562be16142cd690095.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
0001-Check-for-overflow-in-interval-division.patch text/x-patch 1.2 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Christophe Pettus 2023-11-15 17:48:37 Re: LIMIT clause extremely slow
Previous Message Melzer Kassensysteme 2023-11-15 16:46:21 LIMIT clause extremely slow