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

Commitbc2232f

Browse files
committed
Disallow NaN as a value for floating-point GUCs.
None of the code that uses GUC values is really prepared for them tohold NaN, but parse_real() didn't have any defense against acceptingsuch a value. Treat it the same as a syntax error.I haven't attempted to analyze the exact consequences of setting anyof the float GUCs to NaN, but since they're quite unlikely to be good,this seems like a back-patchable bug fix.Note: we don't need an explicit test for +-Infinity because those willbe rejected by existing range checks. I added a regression test forthat in HEAD, but not older branches because the spelling of the valuein the error message will be platform-dependent in branches where wedon't always use port/snprintf.c.Discussion:https://postgr.es/m/1798.1552165479@sss.pgh.pa.us
1 parent7d7de6d commitbc2232f

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

‎src/backend/utils/misc/guc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5847,6 +5847,10 @@ parse_real(const char *value, double *result)
58475847
if (endptr==value||errno==ERANGE)
58485848
return false;
58495849

5850+
/* reject NaN (infinities will fail range checks later) */
5851+
if (isnan(val))
5852+
return false;
5853+
58505854
/* allow whitespace after number */
58515855
while (isspace((unsignedchar)*endptr))
58525856
endptr++;

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,11 @@ SELECT '2006-08-13 12:34:56'::timestamptz;
506506
Sun Aug 13 12:34:56 2006 PDT
507507
(1 row)
508508

509+
-- Test some simple error cases
510+
SET seq_page_cost TO 'NaN';
511+
ERROR: parameter "seq_page_cost" requires a numeric value
512+
SET vacuum_cost_delay TO '10s';
513+
ERROR: 10000 is outside the valid range for parameter "vacuum_cost_delay" (0 .. 100)
509514
--
510515
-- Test DISCARD TEMP
511516
--

‎src/test/regress/sql/guc.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ RESET datestyle;
144144
SHOW datestyle;
145145
SELECT'2006-08-13 12:34:56'::timestamptz;
146146

147+
-- Test some simple error cases
148+
SET seq_page_cost TO'NaN';
149+
SET vacuum_cost_delay TO'10s';
150+
147151
--
148152
-- Test DISCARD TEMP
149153
--

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp