power() function in Windows: "value out of range: underflow" - Mailing list pgsql-bugs

From Huong Dangminh
Subject power() function in Windows: "value out of range: underflow"
Date
Msg-id 75DB81BEEA95B445AE6D576A0A5C9E936A73E741@BPXM05GP.gisp.nec.co.jp
Whole thread Raw
Responses Re: power() function in Windows: "value out of range: underflow"  (Euler Taveira <euler@timbira.com.br>)
Re: power() function in Windows: "value out of range: underflow"  (Euler Taveira <euler@timbira.com.br>)
Re: power() function in Windows: "value out of range: underflow"  (David Rowley <david.rowley@2ndquadrant.com>)
Re: power() function in Windows: "value out of range: underflow"  (David Rowley <david.rowley@2ndquadrant.com>)
List pgsql-bugs
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

pgsql-bugs by date:

Previous
From: Greg k
Date:
Subject: LDAP authentication fails with concurrent create extensions
Next
From: Stephen Frost
Date:
Subject: Re: LDAP authentication fails with concurrent create extensions