]> granicus.if.org Git - postgresql/commit
Avoid wrong results for power() with NaN input on some platforms.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 29 Apr 2018 19:21:45 +0000 (15:21 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 29 Apr 2018 19:21:45 +0000 (15:21 -0400)
commit534267e7f3ea03f67e22950f689ad71aaa1560ce
tree9d4db30cc0b6eb86ee40119e1d3843658e8fae71
parent1c66ee81febec2f0aa7fd0c3f2d5f70995542d30
Avoid wrong results for power() with NaN input on some platforms.

Per spec, the result of power() should be NaN if either input is NaN.
It appears that on some versions of Windows, the libc function does
return NaN, but it also sets errno = EDOM, confusing our code that
attempts to work around shortcomings of other platforms.  Hence, add
guard tests to avoid substituting a wrong result for the right one.

It's been like this for a long time (and the odd behavior only appears
in older MSVC releases, too) so back-patch to all supported branches.

Dang Minh Huong, reviewed by David Rowley

Discussion: https://postgr.es/m/75DB81BEEA95B445AE6D576A0A5C9E936A73E741@BPXM05GP.gisp.nec.co.jp
src/backend/utils/adt/float.c
src/test/regress/expected/float8-exp-three-digits-win32.out
src/test/regress/expected/float8-small-is-zero.out
src/test/regress/expected/float8-small-is-zero_1.out
src/test/regress/expected/float8.out
src/test/regress/sql/float8.sql