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

Commitbb3ca23

Browse files
committed
Improve "out of range" error messages for GUCs.
If the GUC has a unit, label the minimum and maximum valueswith the unit explicitly. Per suggestion from Jian He.Discussion:https://postgr.es/m/CACJufxFJo6FyVg9W8yvNAxbjP+EJ9wieE9d9vw5LpPzyLnLLOQ@mail.gmail.com
1 parentb29cbd3 commitbb3ca23

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

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

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3173,15 +3173,20 @@ parse_and_validate_value(struct config_generic *record,
31733173
if (newval->intval<conf->min||newval->intval>conf->max)
31743174
{
31753175
constchar*unit=get_config_unit_name(conf->gen.flags);
3176+
constchar*unitspace;
3177+
3178+
if (unit)
3179+
unitspace=" ";
3180+
else
3181+
unit=unitspace="";
31763182

31773183
ereport(elevel,
31783184
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3179-
errmsg("%d%s%s is outside the valid range for parameter \"%s\" (%d .. %d)",
3180-
newval->intval,
3181-
unit ?" " :"",
3182-
unit ?unit :"",
3185+
errmsg("%d%s%s is outside the valid range for parameter \"%s\" (%d%s%s .. %d%s%s)",
3186+
newval->intval,unitspace,unit,
31833187
name,
3184-
conf->min,conf->max)));
3188+
conf->min,unitspace,unit,
3189+
conf->max,unitspace,unit)));
31853190
return false;
31863191
}
31873192

@@ -3209,15 +3214,20 @@ parse_and_validate_value(struct config_generic *record,
32093214
if (newval->realval<conf->min||newval->realval>conf->max)
32103215
{
32113216
constchar*unit=get_config_unit_name(conf->gen.flags);
3217+
constchar*unitspace;
3218+
3219+
if (unit)
3220+
unitspace=" ";
3221+
else
3222+
unit=unitspace="";
32123223

32133224
ereport(elevel,
32143225
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
3215-
errmsg("%g%s%s is outside the valid range for parameter \"%s\" (%g .. %g)",
3216-
newval->realval,
3217-
unit ?" " :"",
3218-
unit ?unit :"",
3226+
errmsg("%g%s%s is outside the valid range for parameter \"%s\" (%g%s%s .. %g%s%s)",
3227+
newval->realval,unitspace,unit,
32193228
name,
3220-
conf->min,conf->max)));
3229+
conf->min,unitspace,unit,
3230+
conf->max,unitspace,unit)));
32213231
return false;
32223232
}
32233233

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ SELECT '2006-08-13 12:34:56'::timestamptz;
510510
SET seq_page_cost TO 'NaN';
511511
ERROR: invalid value for parameter "seq_page_cost": "NaN"
512512
SET vacuum_cost_delay TO '10s';
513-
ERROR: 10000 ms is outside the valid range for parameter "vacuum_cost_delay" (0 .. 100)
513+
ERROR: 10000 ms is outside the valid range for parameter "vacuum_cost_delay" (0ms.. 100 ms)
514514
SET no_such_variable TO 42;
515515
ERROR: unrecognized configuration parameter "no_such_variable"
516516
-- Test "custom" GUCs created on the fly (which aren't really an

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp