mirror of
https://github.com/postgres/postgres.git
synced 2025-05-21 15:54:08 +03:00
Improve "out of range" error messages for GUCs.
If the GUC has a unit, label the minimum and maximum values with the unit explicitly. Per suggestion from Jian He. Discussion: https://postgr.es/m/CACJufxFJo6FyVg9W8yvNAxbjP+EJ9wieE9d9vw5LpPzyLnLLOQ@mail.gmail.com
This commit is contained in:
parent
b29cbd3da4
commit
bb3ca23239
@ -3173,15 +3173,20 @@ parse_and_validate_value(struct config_generic *record,
|
|||||||
if (newval->intval < conf->min || newval->intval > conf->max)
|
if (newval->intval < conf->min || newval->intval > conf->max)
|
||||||
{
|
{
|
||||||
const char *unit = get_config_unit_name(conf->gen.flags);
|
const char *unit = get_config_unit_name(conf->gen.flags);
|
||||||
|
const char *unitspace;
|
||||||
|
|
||||||
|
if (unit)
|
||||||
|
unitspace = " ";
|
||||||
|
else
|
||||||
|
unit = unitspace = "";
|
||||||
|
|
||||||
ereport(elevel,
|
ereport(elevel,
|
||||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
errmsg("%d%s%s is outside the valid range for parameter \"%s\" (%d .. %d)",
|
errmsg("%d%s%s is outside the valid range for parameter \"%s\" (%d%s%s .. %d%s%s)",
|
||||||
newval->intval,
|
newval->intval, unitspace, unit,
|
||||||
unit ? " " : "",
|
|
||||||
unit ? unit : "",
|
|
||||||
name,
|
name,
|
||||||
conf->min, conf->max)));
|
conf->min, unitspace, unit,
|
||||||
|
conf->max, unitspace, unit)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3209,15 +3214,20 @@ parse_and_validate_value(struct config_generic *record,
|
|||||||
if (newval->realval < conf->min || newval->realval > conf->max)
|
if (newval->realval < conf->min || newval->realval > conf->max)
|
||||||
{
|
{
|
||||||
const char *unit = get_config_unit_name(conf->gen.flags);
|
const char *unit = get_config_unit_name(conf->gen.flags);
|
||||||
|
const char *unitspace;
|
||||||
|
|
||||||
|
if (unit)
|
||||||
|
unitspace = " ";
|
||||||
|
else
|
||||||
|
unit = unitspace = "";
|
||||||
|
|
||||||
ereport(elevel,
|
ereport(elevel,
|
||||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
errmsg("%g%s%s is outside the valid range for parameter \"%s\" (%g .. %g)",
|
errmsg("%g%s%s is outside the valid range for parameter \"%s\" (%g%s%s .. %g%s%s)",
|
||||||
newval->realval,
|
newval->realval, unitspace, unit,
|
||||||
unit ? " " : "",
|
|
||||||
unit ? unit : "",
|
|
||||||
name,
|
name,
|
||||||
conf->min, conf->max)));
|
conf->min, unitspace, unit,
|
||||||
|
conf->max, unitspace, unit)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,7 +510,7 @@ SELECT '2006-08-13 12:34:56'::timestamptz;
|
|||||||
SET seq_page_cost TO 'NaN';
|
SET seq_page_cost TO 'NaN';
|
||||||
ERROR: invalid value for parameter "seq_page_cost": "NaN"
|
ERROR: invalid value for parameter "seq_page_cost": "NaN"
|
||||||
SET vacuum_cost_delay TO '10s';
|
SET vacuum_cost_delay TO '10s';
|
||||||
ERROR: 10000 ms is outside the valid range for parameter "vacuum_cost_delay" (0 .. 100)
|
ERROR: 10000 ms is outside the valid range for parameter "vacuum_cost_delay" (0 ms .. 100 ms)
|
||||||
SET no_such_variable TO 42;
|
SET no_such_variable TO 42;
|
||||||
ERROR: unrecognized configuration parameter "no_such_variable"
|
ERROR: unrecognized configuration parameter "no_such_variable"
|
||||||
-- Test "custom" GUCs created on the fly (which aren't really an
|
-- Test "custom" GUCs created on the fly (which aren't really an
|
||||||
|
Loading…
x
Reference in New Issue
Block a user