power() function in Windows: "value out of range: underflow"

From: Huong Dangminh <huo-dangminh(at)ys(dot)jp(dot)nec(dot)com>
To: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Akio Iwaasa <aki-iwaasa(at)vt(dot)jp(dot)nec(dot)com>
Subject: power() function in Windows: "value out of range: underflow"
Date: 2018-04-10 08:30:19
Message-ID: 75DB81BEEA95B445AE6D576A0A5C9E936A73E741@BPXM05GP.gisp.nec.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

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/

Attachment Content-Type Size
power_NaN.PATCH application/octet-stream 1.6 KB

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Stephen Frost 2018-04-10 11:31:57 Re: LDAP authentication fails with concurrent create extensions
Previous Message Greg k 2018-04-10 07:37:18 LDAP authentication fails with concurrent create extensions

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2018-04-10 08:56:19 Re: [HACKERS] path toward faster partition pruning
Previous Message Amit Langote 2018-04-10 08:18:01 Re: crash with sql language partition support function