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

Commitf9ec64d

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 parent22816ce commitf9ec64d

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
@@ -5613,6 +5613,10 @@ parse_real(const char *value, double *result)
56135613
if (endptr==value||errno==ERANGE)
56145614
return false;
56155615

5616+
/* reject NaN (infinities will fail range checks later) */
5617+
if (isnan(val))
5618+
return false;
5619+
56165620
/* allow whitespace after number */
56175621
while (isspace((unsignedchar)*endptr))
56185622
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