diff options
author | Thomas G. Lockhart <lockhart@fourpalms.org> | 1999-01-10 17:13:06 +0000 |
---|---|---|
committer | Thomas G. Lockhart <lockhart@fourpalms.org> | 1999-01-10 17:13:06 +0000 |
commit | c715788681121b78af3046d5c039c751625c8ad9 (patch) | |
tree | f7688d82b274cf03ede226007dd9526ffd32148a /src/backend/utils/adt/float.c | |
parent | 0b644ad332f5c9cfb074c41462e6274b72c39d5d (diff) | |
download | postgresql-c715788681121b78af3046d5c039c751625c8ad9.tar.gz postgresql-c715788681121b78af3046d5c039c751625c8ad9.zip |
Handle "NaN" and "Infinity" for input values.
I think NAN is already guaranteed to be there from Jan's work on NUMERIC,
but perhaps HUGE_VAL needs some #ifndef's in the same place.
Should also include "-Infinity" as -HUGE_VAL sometime; not there yet.
Diffstat (limited to 'src/backend/utils/adt/float.c')
-rw-r--r-- | src/backend/utils/adt/float.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c index a00cef1bf19..ba6abbb247c 100644 --- a/src/backend/utils/adt/float.c +++ b/src/backend/utils/adt/float.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.35 1998/11/29 01:57:59 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.36 1999/01/10 17:13:06 thomas Exp $ * *------------------------------------------------------------------------- */ @@ -249,8 +249,17 @@ float8in(char *num) errno = 0; val = strtod(num, &endptr); - if (*endptr != '\0' || errno == ERANGE) - elog(ERROR, "Bad float8 input format '%s'", num); + if (*endptr != '\0') + { + if (strcasecmp(num, "NaN") == 0) + val = NAN; + else if (strcasecmp(num, "Infinity") == 0) + val = HUGE_VAL; + else if (errno == ERANGE) + elog(ERROR, "Input '%s' is out of range for float8", num); + else + elog(ERROR, "Bad float8 input format '%s'", num); + } CheckFloat8Val(val); *result = val; |