1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-18 02:02:55 +03:00

Message style improvements

An improvement pass over the new stats import functionality.
This commit is contained in:
Peter Eisentraut
2025-08-27 21:17:58 +02:00
parent 5865150b6d
commit 80f1106132
4 changed files with 52 additions and 49 deletions

View File

@@ -199,7 +199,7 @@ attribute_statistics_update(FunctionCallInfo fcinfo)
if (!PG_ARGISNULL(ATTNUM_ARG))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("cannot specify both attname and attnum")));
errmsg("cannot specify both \"%s\" and \"%s\"", "attname", "attnum")));
attname = TextDatumGetCString(PG_GETARG_DATUM(ATTNAME_ARG));
attnum = get_attnum(reloid, attname);
/* note that this test covers attisdropped cases too: */
@@ -225,7 +225,7 @@ attribute_statistics_update(FunctionCallInfo fcinfo)
{
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("must specify either attname or attnum")));
errmsg("must specify either \"%s\" or \"%s\"", "attname", "attnum")));
attname = NULL; /* keep compiler quiet */
attnum = 0;
}
@@ -297,8 +297,9 @@ attribute_statistics_update(FunctionCallInfo fcinfo)
&elemtypid, &elem_eq_opr))
{
ereport(WARNING,
(errmsg("unable to determine element type of attribute \"%s\"", attname),
errdetail("Cannot set STATISTIC_KIND_MCELEM or STATISTIC_KIND_DECHIST.")));
(errmsg("could not determine element type of column \"%s\"", attname),
errdetail("Cannot set %s or %s.",
"STATISTIC_KIND_MCELEM", "STATISTIC_KIND_DECHIST")));
elemtypid = InvalidOid;
elem_eq_opr = InvalidOid;
@@ -313,8 +314,9 @@ attribute_statistics_update(FunctionCallInfo fcinfo)
{
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("could not determine less-than operator for attribute \"%s\"", attname),
errdetail("Cannot set STATISTIC_KIND_HISTOGRAM or STATISTIC_KIND_CORRELATION.")));
errmsg("could not determine less-than operator for column \"%s\"", attname),
errdetail("Cannot set %s or %s.",
"STATISTIC_KIND_HISTOGRAM", "STATISTIC_KIND_CORRELATION")));
do_histogram = false;
do_correlation = false;
@@ -327,8 +329,9 @@ attribute_statistics_update(FunctionCallInfo fcinfo)
{
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("attribute \"%s\" is not a range type", attname),
errdetail("Cannot set STATISTIC_KIND_RANGE_LENGTH_HISTOGRAM or STATISTIC_KIND_BOUNDS_HISTOGRAM.")));
errmsg("column \"%s\" is not a range type", attname),
errdetail("Cannot set %s or %s.",
"STATISTIC_KIND_RANGE_LENGTH_HISTOGRAM", "STATISTIC_KIND_BOUNDS_HISTOGRAM")));
do_bounds_histogram = false;
do_range_length_histogram = false;
@@ -587,7 +590,7 @@ get_attr_stat_type(Oid reloid, AttrNumber attnum,
if (!HeapTupleIsValid(atup))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("attribute %d of relation \"%s\" does not exist",
errmsg("column %d of relation \"%s\" does not exist",
attnum, RelationGetRelationName(rel))));
attr = (Form_pg_attribute) GETSTRUCT(atup);
@@ -595,7 +598,7 @@ get_attr_stat_type(Oid reloid, AttrNumber attnum,
if (attr->attisdropped)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("attribute %d of relation \"%s\" does not exist",
errmsg("column %d of relation \"%s\" does not exist",
attnum, RelationGetRelationName(rel))));
expr = get_attr_expr(rel, attr->attnum);
@@ -729,7 +732,7 @@ text_to_stavalues(const char *staname, FmgrInfo *array_in, Datum d, Oid typid,
{
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("\"%s\" array cannot contain NULL values", staname)));
errmsg("\"%s\" array must not contain null values", staname)));
*ok = false;
return (Datum) 0;
}

View File

@@ -112,7 +112,7 @@ relation_statistics_update(FunctionCallInfo fcinfo)
{
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("reltuples cannot be < -1.0")));
errmsg("argument \"%s\" must not be less than -1.0", "reltuples")));
result = false;
}
else

View File

@@ -41,7 +41,7 @@ stats_check_required_arg(FunctionCallInfo fcinfo,
if (PG_ARGISNULL(argnum))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("\"%s\" cannot be NULL",
errmsg("argument \"%s\" must not be null",
arginfo[argnum].argname)));
}
@@ -68,7 +68,7 @@ stats_check_arg_array(FunctionCallInfo fcinfo,
{
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("\"%s\" cannot be a multidimensional array",
errmsg("argument \"%s\" must not be a multidimensional array",
arginfo[argnum].argname)));
return false;
}
@@ -77,7 +77,7 @@ stats_check_arg_array(FunctionCallInfo fcinfo,
{
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("\"%s\" array cannot contain NULL values",
errmsg("argument \"%s\" array must not contain null values",
arginfo[argnum].argname)));
return false;
}
@@ -108,7 +108,7 @@ stats_check_arg_pair(FunctionCallInfo fcinfo,
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("\"%s\" must be specified when \"%s\" is specified",
errmsg("argument \"%s\" must be specified when argument \"%s\" is specified",
arginfo[nullarg].argname,
arginfo[otherarg].argname)));
@@ -263,7 +263,7 @@ stats_check_arg_type(const char *argname, Oid argtype, Oid expectedtype)
if (argtype != expectedtype)
{
ereport(WARNING,
(errmsg("argument \"%s\" has type \"%s\", expected type \"%s\"",
(errmsg("argument \"%s\" has type %s, expected type %s",
argname, format_type_be(argtype),
format_type_be(expectedtype))));
return false;
@@ -319,11 +319,11 @@ stats_fill_fcinfo_from_arg_pairs(FunctionCallInfo pairs_fcinfo,
if (argnulls[i])
ereport(ERROR,
(errmsg("name at variadic position %d is NULL", i + 1)));
(errmsg("name at variadic position %d is null", i + 1)));
if (types[i] != TEXTOID)
ereport(ERROR,
(errmsg("name at variadic position %d has type \"%s\", expected type \"%s\"",
(errmsg("name at variadic position %d has type %s, expected type %s",
i + 1, format_type_be(types[i]),
format_type_be(TEXTOID))));