power() function in Windows: "value out of range: underflow"
Huong Dangminh <huo-dangminh@ys.jp.nec.com>
From: Huong Dangminh <huo-dangminh@ys.jp.nec.com>
To: "pgsql-bugs@lists.postgresql.org" <pgsql-bugs@lists.postgresql.org>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>,
Akio Iwaasa <aki-iwaasa@vt.jp.nec.com>
Date: 2018-04-10T08:30:19Z
Lists: pgsql-bugs, pgsql-hackers
Attachments
- power_NaN.PATCH (application/octet-stream) patch
Hi,
There are some cases that power() function does not work
correctly with 'NaN' arguments in Windows environment.
Something like,
postgres=# select power('NaN',11);
ERROR: value out of range: underflow
postgres=# select power('NaN','NaN');
ERROR: value out of range: underflow
postgres=# select power(11,'NaN');
ERROR: value out of range: underflow
In Linux environment, instead of ERROR it returns 'NaN'.
The reason here is,
When pow() in float.c:dpow() is called with 'NaN' arguments,
pow() returns 'NaN' but in Windows environment errno is set to
EDOM(invalid floating-point exception).
So, PostgreSQL update "result" and cause an ERROR in CHECKFLOATVAL macro.
I think it should be return 'NaN' in all of above cases.
I have tried to create a patch to fix it.
Please confirm the attached file.
---
Thanks and best regards,
Dang Minh Huong
NEC Solution Innovators, Ltd.
http://www.nec-solutioninnovators.co.jp/en/
Commits
-
Revert back-branch changes in power()'s behavior for NaN inputs.
- 99095b632094 9.3.23 landed
- f74d83b3034f 10.4 landed
- eab8d6312f15 9.6.9 landed
- 8fbdd63a52df 9.5.13 landed
- 70211459a507 9.4.18 landed
-
Avoid wrong results for power() with NaN input on more platforms.
- d9c7f56da464 9.3.23 landed
- d6ec3d2375ac 9.6.9 landed
- 9e4caa2748f4 9.5.13 landed
- 6bdf1303b34b 11.0 landed
- 59c2df3ae894 9.4.18 landed
- 217d8f3a19ae 10.4 landed
-
Avoid wrong results for power() with NaN input on some platforms.
- 534267e7f3ea 9.3.23 landed
- 48e0f8cbe0d9 9.6.9 landed
- 44ccd11cbbe6 9.4.18 landed
- 3b7fba935ec0 9.5.13 landed
- 61b200e2f582 11.0 landed
- 4d864de486d6 10.4 landed