8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.135 2007/01/02 22:19:42 momjian Exp $
11
+ * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.136 2007/01/03 04:21:47 momjian Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -1439,15 +1439,11 @@ dpow(PG_FUNCTION_ARGS)
1439
1439
errmsg ("invalid argument for power function" )));
1440
1440
1441
1441
/*
1442
- * We must check both for errno getting set and for a NaN result, in order
1443
- * to deal with the vagaries of different platforms...
1442
+ * pow() sets errno only on some platforms, depending on whether it
1443
+ * follows _IEEE_, _POSIX_, _XOPEN_, or _SVID_, so, for consistency,
1444
+ * we don't consult it and just do our check below.
1444
1445
*/
1445
- errno = 0 ;
1446
1446
result = pow (arg1 , arg2 );
1447
- if (errno != 0 && !isinf (result ))
1448
- ereport (ERROR ,
1449
- (errcode (ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE ),
1450
- errmsg ("result is out of range" )));
1451
1447
1452
1448
CHECKFLOATVAL (result , isinf (arg1 ) || isinf (arg2 ), arg1 == 0 );
1453
1449
PG_RETURN_FLOAT8 (result );
@@ -1464,15 +1460,11 @@ dexp(PG_FUNCTION_ARGS)
1464
1460
float8 result ;
1465
1461
1466
1462
/*
1467
- * We must check both for errno getting set and for a NaN result, in order
1468
- * to deal with the vagaries of different platforms.
1463
+ * exp() sets errno only on some platforms, depending on whether it
1464
+ * follows _IEEE_, _POSIX_, _XOPEN_, or _SVID_, so, for consistency,
1465
+ * we don't consult it and just do our check below.
1469
1466
*/
1470
- errno = 0 ;
1471
1467
result = exp (arg1 );
1472
- if (errno != 0 && !isinf (result ))
1473
- ereport (ERROR ,
1474
- (errcode (ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE ),
1475
- errmsg ("result is out of range" )));
1476
1468
1477
1469
CHECKFLOATVAL (result , isinf (arg1 ), false);
1478
1470
PG_RETURN_FLOAT8 (result );
@@ -1547,6 +1539,10 @@ dacos(PG_FUNCTION_ARGS)
1547
1539
float8 arg1 = PG_GETARG_FLOAT8 (0 );
1548
1540
float8 result ;
1549
1541
1542
+ /*
1543
+ * We use errno here because the trigonometric functions are cyclic
1544
+ * and hard to check for underflow.
1545
+ */
1550
1546
errno = 0 ;
1551
1547
result = acos (arg1 );
1552
1548
if (errno != 0 )
0 commit comments