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

Commit157349e

Browse files
committed
Improper addition of NaN/Infinity recognition to float8in()
was causing it not to detect out-of-range float values, as evidenced byfailure of float8 regression test. I corrected that logic and alsomodified expected float8 results to account for new error messagegenerated for out-of-range inputs.
1 parent598a4e1 commit157349e

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

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

Lines changed: 16 additions & 4 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.38 1999/01/21 16:08:51 vadim Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.39 1999/01/24 00:12:59 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -209,8 +209,16 @@ float4in(char *num)
209209

210210
errno=0;
211211
val=strtod(num,&endptr);
212-
if (*endptr!='\0'||errno==ERANGE)
212+
if (*endptr!='\0')
213+
{
214+
/* Should we accept "NaN" or "Infinity" for float4? */
213215
elog(ERROR,"Bad float4 input format '%s'",num);
216+
}
217+
else
218+
{
219+
if (errno==ERANGE)
220+
elog(ERROR,"Input '%s' is out of range for float4",num);
221+
}
214222

215223
/*
216224
* if we get here, we have a legal double, still need to check to see
@@ -262,13 +270,17 @@ float8in(char *num)
262270
val=NAN;
263271
elseif (strcasecmp(num,"Infinity")==0)
264272
val=HUGE_VAL;
265-
elseif (errno==ERANGE)
266-
elog(ERROR,"Input '%s' is out of range for float8",num);
267273
else
268274
elog(ERROR,"Bad float8 input format '%s'",num);
269275
}
276+
else
277+
{
278+
if (errno==ERANGE)
279+
elog(ERROR,"Input '%s' is out of range for float8",num);
280+
}
270281

271282
CheckFloat8Val(val);
283+
272284
*result=val;
273285
returnresult;
274286
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,13 @@ five|f1
209209
(5 rows)
210210

211211
QUERY: INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400');
212-
ERROR:Bad float8 input format'10e400'
212+
ERROR:Input'10e400' is out of range for float8
213213
QUERY: INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e400');
214-
ERROR:Bad float8 input format'-10e400'
214+
ERROR:Input'-10e400' is out of range for float8
215215
QUERY: INSERT INTO FLOAT8_TBL(f1) VALUES ('10e-400');
216-
ERROR:Bad float8 input format'10e-400'
216+
ERROR:Input'10e-400' is out of range for float8
217217
QUERY: INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400');
218-
ERROR:Bad float8 input format'-10e-400'
218+
ERROR:Input'-10e-400' is out of range for float8
219219
QUERY: DELETE FROM FLOAT8_TBL;
220220
QUERY: INSERT INTO FLOAT8_TBL(f1) VALUES ('0.0');
221221
QUERY: INSERT INTO FLOAT8_TBL(f1) VALUES ('-34.84');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp