Re: [Patch] Log10 and hyperbolic functions for SQL:2016 compliance
Lætitia Avrot <laetitia.avrot@gmail.com>
From: Lætitia Avrot <laetitia.avrot@gmail.com>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2019-02-03T01:55:06Z
Lists: pgsql-hackers
Attachments
- adding_log10_and_hyperbolic_functions_v4.patch (text/x-patch) patch v4
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
Commits
-
Add support for hyperbolic functions, as well as log10().
- f1d85aa98ee7 12.0 landed