aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/float.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-04-01 23:52:18 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-04-01 23:52:18 +0000
commiteeaef25ad6824d4bfceeec650be8dbbbd455eb37 (patch)
tree0b08be22b2c5c9678f91927152a4d5d2e3eb2e99 /src/backend/utils/adt/float.c
parent47fe0517fcb7ac2dfd3727eb2c4fb7c9b8f50897 (diff)
downloadpostgresql-eeaef25ad6824d4bfceeec650be8dbbbd455eb37.tar.gz
postgresql-eeaef25ad6824d4bfceeec650be8dbbbd455eb37.zip
Fix some portability issues with new float input code (didn't work on
HPUX 11 ...)
Diffstat (limited to 'src/backend/utils/adt/float.c')
-rw-r--r--src/backend/utils/adt/float.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c
index d56cf04bf36..a9032492155 100644
--- a/src/backend/utils/adt/float.c
+++ b/src/backend/utils/adt/float.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.102 2004/04/01 22:51:31 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.103 2004/04/01 23:52:18 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -282,19 +282,14 @@ float4in(PG_FUNCTION_ARGS)
errno = 0;
val = strtod(num, &endptr);
- if (errno == ERANGE)
- ereport(ERROR,
- (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
- errmsg("\"%s\" is out of range for type real",
- orig_num)));
-
/* did we not see anything that looks like a double? */
- if (num == endptr)
+ if (endptr == num || errno != 0)
{
/*
* C99 requires that strtod() accept NaN and [-]Infinity, but
- * not all platforms support that yet. Therefore, we check for
- * these inputs ourselves.
+ * not all platforms support that yet (and some accept them but
+ * set ERANGE anyway...) Therefore, we check for these inputs
+ * ourselves.
*/
if (strncasecmp(num, "NaN", 3) == 0)
{
@@ -311,6 +306,11 @@ float4in(PG_FUNCTION_ARGS)
val = - get_float4_infinity();
endptr = num + 9;
}
+ else if (errno == ERANGE)
+ ereport(ERROR,
+ (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
+ errmsg("\"%s\" is out of range for type real",
+ orig_num)));
else
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
@@ -447,19 +447,14 @@ float8in(PG_FUNCTION_ARGS)
errno = 0;
val = strtod(num, &endptr);
- if (errno == ERANGE)
- ereport(ERROR,
- (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
- errmsg("\"%s\" is out of range for type double precision",
- orig_num)));
-
/* did we not see anything that looks like a double? */
- if (num == endptr)
+ if (endptr == num || errno != 0)
{
/*
* C99 requires that strtod() accept NaN and [-]Infinity, but
- * not all platforms support that yet. Therefore, we check for
- * these inputs ourselves.
+ * not all platforms support that yet (and some accept them but
+ * set ERANGE anyway...) Therefore, we check for these inputs
+ * ourselves.
*/
if (strncasecmp(num, "NaN", 3) == 0)
{
@@ -476,6 +471,11 @@ float8in(PG_FUNCTION_ARGS)
val = - get_float8_infinity();
endptr = num + 9;
}
+ else if (errno == ERANGE)
+ ereport(ERROR,
+ (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
+ errmsg("\"%s\" is out of range for type double precision",
+ orig_num)));
else
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),