Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteab8d63

Browse files
committed
Revert back-branch changes in power()'s behavior for NaN inputs.
Per discussion, the value of fixing these bugs in the back branchesdoesn't outweigh the downsides of changing corner-case behavior ina minor release. Hence, revert commits217d8f3 and4d864de inthe v10 branch and the corresponding commits in 9.3-9.6.Discussion:https://postgr.es/m/75DB81BEEA95B445AE6D576A0A5C9E936A73E741@BPXM05GP.gisp.nec.co.jp
1 parent938c6f4 commiteab8d63

File tree

6 files changed

+1
-170
lines changed

6 files changed

+1
-170
lines changed

‎src/backend/utils/adt/float.c

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,25 +1461,6 @@ dpow(PG_FUNCTION_ARGS)
14611461
float8arg2=PG_GETARG_FLOAT8(1);
14621462
float8result;
14631463

1464-
/*
1465-
* The POSIX spec says that NaN ^ 0 = 1, and 1 ^ NaN = 1, while all other
1466-
* cases with NaN inputs yield NaN (with no error). Many older platforms
1467-
* get one or more of these cases wrong, so deal with them via explicit
1468-
* logic rather than trusting pow(3).
1469-
*/
1470-
if (isnan(arg1))
1471-
{
1472-
if (isnan(arg2)||arg2!=0.0)
1473-
PG_RETURN_FLOAT8(get_float8_nan());
1474-
PG_RETURN_FLOAT8(1.0);
1475-
}
1476-
if (isnan(arg2))
1477-
{
1478-
if (arg1!=1.0)
1479-
PG_RETURN_FLOAT8(get_float8_nan());
1480-
PG_RETURN_FLOAT8(1.0);
1481-
}
1482-
14831464
/*
14841465
* The SQL spec requires that we emit a particular SQLSTATE error code for
14851466
* certain error conditions. Specifically, we don't return a
@@ -1498,7 +1479,7 @@ dpow(PG_FUNCTION_ARGS)
14981479
* pow() sets errno only on some platforms, depending on whether it
14991480
* follows _IEEE_, _POSIX_, _XOPEN_, or _SVID_, so we try to avoid using
15001481
* errno. However, some platform/CPU combinations return errno == EDOM
1501-
* and result ==NaN for negative arg1 and very large arg2 (they must be
1482+
* and result ==Nan for negative arg1 and very large arg2 (they must be
15021483
* using something different from our floor() test to decide it's
15031484
* invalid). Other platforms (HPPA) return errno == ERANGE and a large
15041485
* (HUGE_VAL) but finite result to signal overflow.

‎src/test/regress/expected/float8-exp-three-digits-win32.out

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -340,42 +340,6 @@ SELECT power(float8 '144', float8 '0.5');
340340
12
341341
(1 row)
342342

343-
SELECT power(float8 'NaN', float8 '0.5');
344-
power
345-
-------
346-
NaN
347-
(1 row)
348-
349-
SELECT power(float8 '144', float8 'NaN');
350-
power
351-
-------
352-
NaN
353-
(1 row)
354-
355-
SELECT power(float8 'NaN', float8 'NaN');
356-
power
357-
-------
358-
NaN
359-
(1 row)
360-
361-
SELECT power(float8 '-1', float8 'NaN');
362-
power
363-
-------
364-
NaN
365-
(1 row)
366-
367-
SELECT power(float8 '1', float8 'NaN');
368-
power
369-
-------
370-
1
371-
(1 row)
372-
373-
SELECT power(float8 'NaN', float8 '0');
374-
power
375-
-------
376-
1
377-
(1 row)
378-
379343
-- take exp of ln(f.f1)
380344
SELECT '' AS three, f.f1, exp(ln(f.f1)) AS exp_ln_f1
381345
FROM FLOAT8_TBL f

‎src/test/regress/expected/float8-small-is-zero.out

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -344,42 +344,6 @@ SELECT power(float8 '144', float8 '0.5');
344344
12
345345
(1 row)
346346

347-
SELECT power(float8 'NaN', float8 '0.5');
348-
power
349-
-------
350-
NaN
351-
(1 row)
352-
353-
SELECT power(float8 '144', float8 'NaN');
354-
power
355-
-------
356-
NaN
357-
(1 row)
358-
359-
SELECT power(float8 'NaN', float8 'NaN');
360-
power
361-
-------
362-
NaN
363-
(1 row)
364-
365-
SELECT power(float8 '-1', float8 'NaN');
366-
power
367-
-------
368-
NaN
369-
(1 row)
370-
371-
SELECT power(float8 '1', float8 'NaN');
372-
power
373-
-------
374-
1
375-
(1 row)
376-
377-
SELECT power(float8 'NaN', float8 '0');
378-
power
379-
-------
380-
1
381-
(1 row)
382-
383347
-- take exp of ln(f.f1)
384348
SELECT '' AS three, f.f1, exp(ln(f.f1)) AS exp_ln_f1
385349
FROM FLOAT8_TBL f

‎src/test/regress/expected/float8-small-is-zero_1.out

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -344,42 +344,6 @@ SELECT power(float8 '144', float8 '0.5');
344344
12
345345
(1 row)
346346

347-
SELECT power(float8 'NaN', float8 '0.5');
348-
power
349-
-------
350-
NaN
351-
(1 row)
352-
353-
SELECT power(float8 '144', float8 'NaN');
354-
power
355-
-------
356-
NaN
357-
(1 row)
358-
359-
SELECT power(float8 'NaN', float8 'NaN');
360-
power
361-
-------
362-
NaN
363-
(1 row)
364-
365-
SELECT power(float8 '-1', float8 'NaN');
366-
power
367-
-------
368-
NaN
369-
(1 row)
370-
371-
SELECT power(float8 '1', float8 'NaN');
372-
power
373-
-------
374-
1
375-
(1 row)
376-
377-
SELECT power(float8 'NaN', float8 '0');
378-
power
379-
-------
380-
1
381-
(1 row)
382-
383347
-- take exp of ln(f.f1)
384348
SELECT '' AS three, f.f1, exp(ln(f.f1)) AS exp_ln_f1
385349
FROM FLOAT8_TBL f

‎src/test/regress/expected/float8.out

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -340,42 +340,6 @@ SELECT power(float8 '144', float8 '0.5');
340340
12
341341
(1 row)
342342

343-
SELECT power(float8 'NaN', float8 '0.5');
344-
power
345-
-------
346-
NaN
347-
(1 row)
348-
349-
SELECT power(float8 '144', float8 'NaN');
350-
power
351-
-------
352-
NaN
353-
(1 row)
354-
355-
SELECT power(float8 'NaN', float8 'NaN');
356-
power
357-
-------
358-
NaN
359-
(1 row)
360-
361-
SELECT power(float8 '-1', float8 'NaN');
362-
power
363-
-------
364-
NaN
365-
(1 row)
366-
367-
SELECT power(float8 '1', float8 'NaN');
368-
power
369-
-------
370-
1
371-
(1 row)
372-
373-
SELECT power(float8 'NaN', float8 '0');
374-
power
375-
-------
376-
1
377-
(1 row)
378-
379343
-- take exp of ln(f.f1)
380344
SELECT '' AS three, f.f1, exp(ln(f.f1)) AS exp_ln_f1
381345
FROM FLOAT8_TBL f

‎src/test/regress/sql/float8.sql

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,6 @@ SELECT '' AS three, f.f1, |/f.f1 AS sqrt_f1
108108

109109
-- power
110110
SELECT power(float8'144', float8'0.5');
111-
SELECT power(float8'NaN', float8'0.5');
112-
SELECT power(float8'144', float8'NaN');
113-
SELECT power(float8'NaN', float8'NaN');
114-
SELECT power(float8'-1', float8'NaN');
115-
SELECT power(float8'1', float8'NaN');
116-
SELECT power(float8'NaN', float8'0');
117111

118112
-- take exp of ln(f.f1)
119113
SELECT''AS three,f.f1, exp(ln(f.f1))AS exp_ln_f1

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp