pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Avoid wrong results for power() with NaN input on some platforms
12+ messages / 1 participants
[nested] [flat]

* pgsql: Avoid wrong results for power() with NaN input on some platforms
@ 2018-04-29 19:21  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 12+ messages in thread

From: Tom Lane @ 2018-04-29 19:21 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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

Branch
------
REL9_3_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/534267e7f3ea03f67e22950f689ad71aaa1560ce

Modified Files
--------------
src/backend/utils/adt/float.c                      |  7 ++---
.../expected/float8-exp-three-digits-win32.out     | 30 ++++++++++++++++++++++
src/test/regress/expected/float8-small-is-zero.out | 30 ++++++++++++++++++++++
.../regress/expected/float8-small-is-zero_1.out    | 30 ++++++++++++++++++++++
src/test/regress/expected/float8.out               | 30 ++++++++++++++++++++++
src/test/regress/sql/float8.sql                    |  5 ++++
6 files changed, 129 insertions(+), 3 deletions(-)



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* pgsql: Avoid wrong results for power() with NaN input on some platforms
@ 2018-04-29 19:21  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 12+ messages in thread

From: Tom Lane @ 2018-04-29 19:21 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/61b200e2f582d0886d9de947e182483339d881fd

Modified Files
--------------
src/backend/utils/adt/float.c                      |  7 ++---
.../expected/float8-exp-three-digits-win32.out     | 30 ++++++++++++++++++++++
src/test/regress/expected/float8-small-is-zero.out | 30 ++++++++++++++++++++++
.../regress/expected/float8-small-is-zero_1.out    | 30 ++++++++++++++++++++++
src/test/regress/expected/float8.out               | 30 ++++++++++++++++++++++
src/test/regress/sql/float8.sql                    |  5 ++++
6 files changed, 129 insertions(+), 3 deletions(-)



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* pgsql: Avoid wrong results for power() with NaN input on some platforms
@ 2018-04-29 19:21  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 12+ messages in thread

From: Tom Lane @ 2018-04-29 19:21 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/48e0f8cbe0d9bbc08de6e97ccb6241a670731a97

Modified Files
--------------
src/backend/utils/adt/float.c                      |  7 ++---
.../expected/float8-exp-three-digits-win32.out     | 30 ++++++++++++++++++++++
src/test/regress/expected/float8-small-is-zero.out | 30 ++++++++++++++++++++++
.../regress/expected/float8-small-is-zero_1.out    | 30 ++++++++++++++++++++++
src/test/regress/expected/float8.out               | 30 ++++++++++++++++++++++
src/test/regress/sql/float8.sql                    |  5 ++++
6 files changed, 129 insertions(+), 3 deletions(-)



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* pgsql: Avoid wrong results for power() with NaN input on some platforms
@ 2018-04-29 19:21  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 12+ messages in thread

From: Tom Lane @ 2018-04-29 19:21 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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

Branch
------
REL9_4_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/44ccd11cbbe60940689e35ac83a65ea4e219a983

Modified Files
--------------
src/backend/utils/adt/float.c                      |  7 ++---
.../expected/float8-exp-three-digits-win32.out     | 30 ++++++++++++++++++++++
src/test/regress/expected/float8-small-is-zero.out | 30 ++++++++++++++++++++++
.../regress/expected/float8-small-is-zero_1.out    | 30 ++++++++++++++++++++++
src/test/regress/expected/float8.out               | 30 ++++++++++++++++++++++
src/test/regress/sql/float8.sql                    |  5 ++++
6 files changed, 129 insertions(+), 3 deletions(-)



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* pgsql: Avoid wrong results for power() with NaN input on some platforms
@ 2018-04-29 19:21  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 12+ messages in thread

From: Tom Lane @ 2018-04-29 19:21 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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

Branch
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/3b7fba935ec086c10ac407852ba840e358893e9c

Modified Files
--------------
src/backend/utils/adt/float.c                      |  7 ++---
.../expected/float8-exp-three-digits-win32.out     | 30 ++++++++++++++++++++++
src/test/regress/expected/float8-small-is-zero.out | 30 ++++++++++++++++++++++
.../regress/expected/float8-small-is-zero_1.out    | 30 ++++++++++++++++++++++
src/test/regress/expected/float8.out               | 30 ++++++++++++++++++++++
src/test/regress/sql/float8.sql                    |  5 ++++
6 files changed, 129 insertions(+), 3 deletions(-)



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* pgsql: Avoid wrong results for power() with NaN input on some platforms
@ 2018-04-29 19:21  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 12+ messages in thread

From: Tom Lane @ 2018-04-29 19:21 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/4d864de486d63b50b1ba74330021504d2c674c23

Modified Files
--------------
src/backend/utils/adt/float.c                      |  7 ++---
.../expected/float8-exp-three-digits-win32.out     | 30 ++++++++++++++++++++++
src/test/regress/expected/float8-small-is-zero.out | 30 ++++++++++++++++++++++
.../regress/expected/float8-small-is-zero_1.out    | 30 ++++++++++++++++++++++
src/test/regress/expected/float8.out               | 30 ++++++++++++++++++++++
src/test/regress/sql/float8.sql                    |  5 ++++
6 files changed, 129 insertions(+), 3 deletions(-)



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* pgsql: Avoid wrong results for power() with NaN input on more platforms
@ 2018-04-29 22:15  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 12+ messages in thread

From: Tom Lane @ 2018-04-29 22:15 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid wrong results for power() with NaN input on more platforms.

Buildfarm results show that the modern POSIX rule that 1 ^ NaN = 1 is not
honored on *BSD until relatively recently, and really old platforms don't
believe that NaN ^ 0 = 1 either.  (This is unsurprising, perhaps, since
SUSv2 doesn't require either behavior.)  In hopes of getting to platform
independent behavior, let's deal with all the NaN-input cases explicitly
in dpow().

Note that numeric_power() doesn't know either of these special cases.
But since that behavior is platform-independent, I think it should be
addressed separately, and probably not back-patched.

Discussion: https://postgr.es/m/75DB81BEEA95B445AE6D576A0A5C9E936A73E741@BPXM05GP.gisp.nec.co.jp

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/d6ec3d2375ac3b94d2480c01d7ee7739b236642c

Modified Files
--------------
src/backend/utils/adt/float.c                      | 24 +++++++++++++++++++---
.../expected/float8-exp-three-digits-win32.out     |  6 ++++++
src/test/regress/expected/float8-small-is-zero.out |  6 ++++++
.../regress/expected/float8-small-is-zero_1.out    |  6 ++++++
src/test/regress/expected/float8.out               |  6 ++++++
src/test/regress/sql/float8.sql                    |  1 +
6 files changed, 46 insertions(+), 3 deletions(-)



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* pgsql: Avoid wrong results for power() with NaN input on more platforms
@ 2018-04-29 22:15  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 12+ messages in thread

From: Tom Lane @ 2018-04-29 22:15 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid wrong results for power() with NaN input on more platforms.

Buildfarm results show that the modern POSIX rule that 1 ^ NaN = 1 is not
honored on *BSD until relatively recently, and really old platforms don't
believe that NaN ^ 0 = 1 either.  (This is unsurprising, perhaps, since
SUSv2 doesn't require either behavior.)  In hopes of getting to platform
independent behavior, let's deal with all the NaN-input cases explicitly
in dpow().

Note that numeric_power() doesn't know either of these special cases.
But since that behavior is platform-independent, I think it should be
addressed separately, and probably not back-patched.

Discussion: https://postgr.es/m/75DB81BEEA95B445AE6D576A0A5C9E936A73E741@BPXM05GP.gisp.nec.co.jp

Branch
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9e4caa2748f469d3f37a68f5012a2993dad0db10

Modified Files
--------------
src/backend/utils/adt/float.c                      | 24 +++++++++++++++++++---
.../expected/float8-exp-three-digits-win32.out     |  6 ++++++
src/test/regress/expected/float8-small-is-zero.out |  6 ++++++
.../regress/expected/float8-small-is-zero_1.out    |  6 ++++++
src/test/regress/expected/float8.out               |  6 ++++++
src/test/regress/sql/float8.sql                    |  1 +
6 files changed, 46 insertions(+), 3 deletions(-)



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* pgsql: Avoid wrong results for power() with NaN input on more platforms
@ 2018-04-29 22:15  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 12+ messages in thread

From: Tom Lane @ 2018-04-29 22:15 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid wrong results for power() with NaN input on more platforms.

Buildfarm results show that the modern POSIX rule that 1 ^ NaN = 1 is not
honored on *BSD until relatively recently, and really old platforms don't
believe that NaN ^ 0 = 1 either.  (This is unsurprising, perhaps, since
SUSv2 doesn't require either behavior.)  In hopes of getting to platform
independent behavior, let's deal with all the NaN-input cases explicitly
in dpow().

Note that numeric_power() doesn't know either of these special cases.
But since that behavior is platform-independent, I think it should be
addressed separately, and probably not back-patched.

Discussion: https://postgr.es/m/75DB81BEEA95B445AE6D576A0A5C9E936A73E741@BPXM05GP.gisp.nec.co.jp

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/217d8f3a19aeae6a221c61487f1758a53dda31c8

Modified Files
--------------
src/backend/utils/adt/float.c                      | 24 +++++++++++++++++++---
.../expected/float8-exp-three-digits-win32.out     |  6 ++++++
src/test/regress/expected/float8-small-is-zero.out |  6 ++++++
.../regress/expected/float8-small-is-zero_1.out    |  6 ++++++
src/test/regress/expected/float8.out               |  6 ++++++
src/test/regress/sql/float8.sql                    |  1 +
6 files changed, 46 insertions(+), 3 deletions(-)



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* pgsql: Avoid wrong results for power() with NaN input on more platforms
@ 2018-04-29 22:15  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 12+ messages in thread

From: Tom Lane @ 2018-04-29 22:15 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid wrong results for power() with NaN input on more platforms.

Buildfarm results show that the modern POSIX rule that 1 ^ NaN = 1 is not
honored on *BSD until relatively recently, and really old platforms don't
believe that NaN ^ 0 = 1 either.  (This is unsurprising, perhaps, since
SUSv2 doesn't require either behavior.)  In hopes of getting to platform
independent behavior, let's deal with all the NaN-input cases explicitly
in dpow().

Note that numeric_power() doesn't know either of these special cases.
But since that behavior is platform-independent, I think it should be
addressed separately, and probably not back-patched.

Discussion: https://postgr.es/m/75DB81BEEA95B445AE6D576A0A5C9E936A73E741@BPXM05GP.gisp.nec.co.jp

Branch
------
REL9_4_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/59c2df3ae8947c4c06217d1b330cfa529f480e17

Modified Files
--------------
src/backend/utils/adt/float.c                      | 24 +++++++++++++++++++---
.../expected/float8-exp-three-digits-win32.out     |  6 ++++++
src/test/regress/expected/float8-small-is-zero.out |  6 ++++++
.../regress/expected/float8-small-is-zero_1.out    |  6 ++++++
src/test/regress/expected/float8.out               |  6 ++++++
src/test/regress/sql/float8.sql                    |  1 +
6 files changed, 46 insertions(+), 3 deletions(-)



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* pgsql: Avoid wrong results for power() with NaN input on more platforms
@ 2018-04-29 22:15  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 12+ messages in thread

From: Tom Lane @ 2018-04-29 22:15 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid wrong results for power() with NaN input on more platforms.

Buildfarm results show that the modern POSIX rule that 1 ^ NaN = 1 is not
honored on *BSD until relatively recently, and really old platforms don't
believe that NaN ^ 0 = 1 either.  (This is unsurprising, perhaps, since
SUSv2 doesn't require either behavior.)  In hopes of getting to platform
independent behavior, let's deal with all the NaN-input cases explicitly
in dpow().

Note that numeric_power() doesn't know either of these special cases.
But since that behavior is platform-independent, I think it should be
addressed separately, and probably not back-patched.

Discussion: https://postgr.es/m/75DB81BEEA95B445AE6D576A0A5C9E936A73E741@BPXM05GP.gisp.nec.co.jp

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6bdf1303b34bc630e8945ae3407ec7e8395c8fe5

Modified Files
--------------
src/backend/utils/adt/float.c                      | 24 +++++++++++++++++++---
.../expected/float8-exp-three-digits-win32.out     |  6 ++++++
src/test/regress/expected/float8-small-is-zero.out |  6 ++++++
.../regress/expected/float8-small-is-zero_1.out    |  6 ++++++
src/test/regress/expected/float8.out               |  6 ++++++
src/test/regress/sql/float8.sql                    |  1 +
6 files changed, 46 insertions(+), 3 deletions(-)



^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* pgsql: Avoid wrong results for power() with NaN input on more platforms
@ 2018-04-29 22:15  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 12+ messages in thread

From: Tom Lane @ 2018-04-29 22:15 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid wrong results for power() with NaN input on more platforms.

Buildfarm results show that the modern POSIX rule that 1 ^ NaN = 1 is not
honored on *BSD until relatively recently, and really old platforms don't
believe that NaN ^ 0 = 1 either.  (This is unsurprising, perhaps, since
SUSv2 doesn't require either behavior.)  In hopes of getting to platform
independent behavior, let's deal with all the NaN-input cases explicitly
in dpow().

Note that numeric_power() doesn't know either of these special cases.
But since that behavior is platform-independent, I think it should be
addressed separately, and probably not back-patched.

Discussion: https://postgr.es/m/75DB81BEEA95B445AE6D576A0A5C9E936A73E741@BPXM05GP.gisp.nec.co.jp

Branch
------
REL9_3_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/d9c7f56da464e5d499a2dcd0a601f2ee68fee06b

Modified Files
--------------
src/backend/utils/adt/float.c                      | 24 +++++++++++++++++++---
.../expected/float8-exp-three-digits-win32.out     |  6 ++++++
src/test/regress/expected/float8-small-is-zero.out |  6 ++++++
.../regress/expected/float8-small-is-zero_1.out    |  6 ++++++
src/test/regress/expected/float8.out               |  6 ++++++
src/test/regress/sql/float8.sql                    |  1 +
6 files changed, 46 insertions(+), 3 deletions(-)



^ permalink  raw  reply  [nested|flat] 12+ messages in thread


end of thread, other threads:[~2018-04-29 22:15 UTC | newest]

Thread overview: 12+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-04-29 19:21 pgsql: Avoid wrong results for power() with NaN input on some platforms Tom Lane <tgl@sss.pgh.pa.us>
2018-04-29 19:21 pgsql: Avoid wrong results for power() with NaN input on some platforms Tom Lane <tgl@sss.pgh.pa.us>
2018-04-29 19:21 pgsql: Avoid wrong results for power() with NaN input on some platforms Tom Lane <tgl@sss.pgh.pa.us>
2018-04-29 19:21 pgsql: Avoid wrong results for power() with NaN input on some platforms Tom Lane <tgl@sss.pgh.pa.us>
2018-04-29 19:21 pgsql: Avoid wrong results for power() with NaN input on some platforms Tom Lane <tgl@sss.pgh.pa.us>
2018-04-29 19:21 pgsql: Avoid wrong results for power() with NaN input on some platforms Tom Lane <tgl@sss.pgh.pa.us>
2018-04-29 22:15 pgsql: Avoid wrong results for power() with NaN input on more platforms Tom Lane <tgl@sss.pgh.pa.us>
2018-04-29 22:15 pgsql: Avoid wrong results for power() with NaN input on more platforms Tom Lane <tgl@sss.pgh.pa.us>
2018-04-29 22:15 pgsql: Avoid wrong results for power() with NaN input on more platforms Tom Lane <tgl@sss.pgh.pa.us>
2018-04-29 22:15 pgsql: Avoid wrong results for power() with NaN input on more platforms Tom Lane <tgl@sss.pgh.pa.us>
2018-04-29 22:15 pgsql: Avoid wrong results for power() with NaN input on more platforms Tom Lane <tgl@sss.pgh.pa.us>
2018-04-29 22:15 pgsql: Avoid wrong results for power() with NaN input on more platforms Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox