]> granicus.if.org Git - postgresql/commit
Make numeric power() handle NaNs according to the modern POSIX spec.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 17 May 2018 15:10:50 +0000 (11:10 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 17 May 2018 15:10:50 +0000 (11:10 -0400)
commitd1fc750b5199837a330c10d542191c8ab03a7dc8
tree932630a21fc6853ef448e4beee344fdd4e274638
parentb2b82228ee5dc08f0341b5480546479c19e84baf
Make numeric power() handle NaNs according to the modern POSIX spec.

In commit 6bdf1303b, we ensured that power()/^ for float8 would honor
the NaN behaviors specified by POSIX standards released in this century,
ie NaN ^ 0 = 1 and 1 ^ NaN = 1.  However, numeric_power() was not
touched and continued to follow the once-common behavior that every
case involving NaN input produces NaN.  For consistency, let's switch
the numeric behavior to the modern spec in the same release that ensures
that behavior for float8.

(Note that while 6bdf1303b was initially back-patched, we later undid
that, concluding that any behavioral change should appear only in v11.)

Discussion: https://postgr.es/m/10898.1526421338@sss.pgh.pa.us
src/backend/utils/adt/numeric.c
src/test/regress/expected/numeric.out
src/test/regress/sql/numeric.sql