Re: [Patch] Log10 and hyperbolic functions for SQL:2016 compliance

From: Lætitia Avrot <laetitia(dot)avrot(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [Patch] Log10 and hyperbolic functions for SQL:2016 compliance
Date: 2019-02-03 01:55:06
Message-ID: CAB_COdg_DVjTn88Wo2iPPaFqtp4WvVKvph26VEG-UCSJfa9vFg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Alvaro,

Thank you so much for taking the time to review the patch and for taking
the time again to sort things
out with me this evening.

> I see that in dtanh() you set errno to 0 before calling tanh(), but 1)
> you don't check for it afterwards (seems like you should be checking for
> ERANGE, as well as checking the return value for isinf()), and 2) you
> don't do that in dsinh() and dcosh() and I'm not quite sure I see why.
> What's up with that?
>
>
At the time I wrote that patch, I tried to include errno testing.Then, I
think again and
came back with the wrong idea everything would be fine.

By re-reading math.h documentation, it is now clear that the three
functions can raise a
ERANGE error.

There are two cases :
- range error due to overflow occurs.
- range error occurs due to underflow. In that case, the correct result
(after rounding) is returned. So I assume we can ignore that case.

For sinh and cosh, we can have both cases and we added support for overflow.

For tanh, the only possible case is underflow and then, the result is
correct.

We included comments to explain errno handling in those functions.

Cheers,

Lætitia

Attachment Content-Type Size
adding_log10_and_hyperbolic_functions_v4.patch text/x-patch 7.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2019-02-03 03:57:04 Synchronize with imath upstream
Previous Message David Rowley 2019-02-03 00:18:47 Re: ATTACH/DETACH PARTITION CONCURRENTLY