Re: [Patch] Log10 and hyperbolic functions for SQL:2016 compliance - Mailing list pgsql-hackers

From Lætitia Avrot
Subject Re: [Patch] Log10 and hyperbolic functions for SQL:2016 compliance
Date
Msg-id CAB_COdg_DVjTn88Wo2iPPaFqtp4WvVKvph26VEG-UCSJfa9vFg@mail.gmail.com
Whole thread Raw
In response to Re: [Patch] Log10 and hyperbolic functions for SQL:2016 compliance  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Responses Re: [Patch] Log10 and hyperbolic functions for SQL:2016 compliance  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
List 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

pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: ATTACH/DETACH PARTITION CONCURRENTLY
Next
From: Noah Misch
Date:
Subject: Synchronize with imath upstream