mirror of
https://github.com/postgres/postgres.git
synced 2025-07-14 08:21:07 +03:00
Fix a number of places that produced XX000 errors in the regression tests.
It's against project policy to use elog() for user-facing errors, or to omit an errcode() selection for errors that aren't supposed to be "can't happen" cases. Fix all the violations of this policy that result in ERRCODE_INTERNAL_ERROR log entries during the standard regression tests, as errors that can reliably be triggered from SQL surely should be considered user-facing. I also looked through all the files touched by this commit and fixed other nearby problems of the same ilk. I do not claim to have fixed all violations of the policy, just the ones in these files. In a few places I also changed existing ERRCODE choices that didn't seem particularly appropriate; mainly replacing ERRCODE_SYNTAX_ERROR by something more specific. Back-patch to 9.5, but no further; changing ERRCODE assignments in stable branches doesn't seem like a good idea.
This commit is contained in:
@ -484,7 +484,7 @@ allocate_reloption(bits32 kinds, int type, char *name, char *desc)
|
||||
size = sizeof(relopt_string);
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "unsupported option type");
|
||||
elog(ERROR, "unsupported reloption type %d", type);
|
||||
return NULL; /* keep compiler quiet */
|
||||
}
|
||||
|
||||
@ -1016,7 +1016,8 @@ parse_one_reloption(relopt_value *option, char *text_str, int text_len,
|
||||
parsed = parse_bool(value, &option->values.bool_val);
|
||||
if (validate && !parsed)
|
||||
ereport(ERROR,
|
||||
(errmsg("invalid value for boolean option \"%s\": %s",
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("invalid value for boolean option \"%s\": %s",
|
||||
option->gen->name, value)));
|
||||
}
|
||||
break;
|
||||
@ -1027,12 +1028,14 @@ parse_one_reloption(relopt_value *option, char *text_str, int text_len,
|
||||
parsed = parse_int(value, &option->values.int_val, 0, NULL);
|
||||
if (validate && !parsed)
|
||||
ereport(ERROR,
|
||||
(errmsg("invalid value for integer option \"%s\": %s",
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("invalid value for integer option \"%s\": %s",
|
||||
option->gen->name, value)));
|
||||
if (validate && (option->values.int_val < optint->min ||
|
||||
option->values.int_val > optint->max))
|
||||
ereport(ERROR,
|
||||
(errmsg("value %s out of bounds for option \"%s\"",
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("value %s out of bounds for option \"%s\"",
|
||||
value, option->gen->name),
|
||||
errdetail("Valid values are between \"%d\" and \"%d\".",
|
||||
optint->min, optint->max)));
|
||||
@ -1045,12 +1048,14 @@ parse_one_reloption(relopt_value *option, char *text_str, int text_len,
|
||||
parsed = parse_real(value, &option->values.real_val);
|
||||
if (validate && !parsed)
|
||||
ereport(ERROR,
|
||||
(errmsg("invalid value for floating point option \"%s\": %s",
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("invalid value for floating point option \"%s\": %s",
|
||||
option->gen->name, value)));
|
||||
if (validate && (option->values.real_val < optreal->min ||
|
||||
option->values.real_val > optreal->max))
|
||||
ereport(ERROR,
|
||||
(errmsg("value %s out of bounds for option \"%s\"",
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("value %s out of bounds for option \"%s\"",
|
||||
value, option->gen->name),
|
||||
errdetail("Valid values are between \"%f\" and \"%f\".",
|
||||
optreal->min, optreal->max)));
|
||||
@ -1168,7 +1173,7 @@ fillRelOptions(void *rdopts, Size basesize,
|
||||
}
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "unrecognized reloption type %c",
|
||||
elog(ERROR, "unsupported reloption type %d",
|
||||
options[i].gen->type);
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user