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

Commitc715788

Browse files
author
Thomas G. Lockhart
committed
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.
1 parent0b644ad commitc715788

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.35 1998/11/29 01:57:59 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.36 1999/01/10 17:13:06 thomas Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -249,8 +249,17 @@ float8in(char *num)
249249

250250
errno=0;
251251
val=strtod(num,&endptr);
252-
if (*endptr!='\0'||errno==ERANGE)
253-
elog(ERROR,"Bad float8 input format '%s'",num);
252+
if (*endptr!='\0')
253+
{
254+
if (strcasecmp(num,"NaN")==0)
255+
val=NAN;
256+
elseif (strcasecmp(num,"Infinity")==0)
257+
val=HUGE_VAL;
258+
elseif (errno==ERANGE)
259+
elog(ERROR,"Input '%s' is out of range for float8",num);
260+
else
261+
elog(ERROR,"Bad float8 input format '%s'",num);
262+
}
254263

255264
CheckFloat8Val(val);
256265
*result=val;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp