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

Commitac75959

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 parent203749a commitac75959

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

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

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

6152+
/* reject NaN (infinities will fail range checks later) */
6153+
if (isnan(val))
6154+
return false;
6155+
61526156
/* allow whitespace after number */
61536157
while (isspace((unsignedchar)*endptr))
61546158
endptr++;

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,13 @@ 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)
514+
SET geqo_selection_bias TO '-infinity';
515+
ERROR: -Infinity is outside the valid range for parameter "geqo_selection_bias" (1.5 .. 2)
509516
--
510517
-- Test DISCARD TEMP
511518
--

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ 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+
SET geqo_selection_bias TO'-infinity';
151+
147152
--
148153
-- Test DISCARD TEMP
149154
--

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp