aboutsummaryrefslogtreecommitdiff
path: root/src/backend/statistics/attribute_stats.c
diff options
context:
space:
mode:
authorJeff Davis <jdavis@postgresql.org>2024-10-23 16:11:45 -0700
committerJeff Davis <jdavis@postgresql.org>2024-10-23 16:16:39 -0700
commit4b096c67e0eed81e287094b9692fff72b9ea3eef (patch)
tree70d4a30bb8c4269f0db1bd15482d6beba85dee04 /src/backend/statistics/attribute_stats.c
parent7b8b8dddd68aca184ae12e01d2f12d1d338e8f90 (diff)
downloadpostgresql-4b096c67e0eed81e287094b9692fff72b9ea3eef.tar.gz
postgresql-4b096c67e0eed81e287094b9692fff72b9ea3eef.zip
Improve pg_set_attribute_stats() error message.
Previously, an invalid attribute name was caught, but the error message was unhelpful.
Diffstat (limited to 'src/backend/statistics/attribute_stats.c')
-rw-r--r--src/backend/statistics/attribute_stats.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/backend/statistics/attribute_stats.c b/src/backend/statistics/attribute_stats.c
index 086dceaeafe..979fe41a000 100644
--- a/src/backend/statistics/attribute_stats.c
+++ b/src/backend/statistics/attribute_stats.c
@@ -161,6 +161,11 @@ attribute_statistics_update(FunctionCallInfo fcinfo, int elevel)
stats_check_required_arg(fcinfo, attarginfo, ATTNAME_ARG);
attname = PG_GETARG_NAME(ATTNAME_ARG);
attnum = get_attnum(reloid, NameStr(*attname));
+ if (attnum == InvalidAttrNumber)
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_COLUMN),
+ errmsg("column \"%s\" of relation \"%s\" does not exist",
+ NameStr(*attname), get_rel_name(reloid))));
stats_check_required_arg(fcinfo, attarginfo, INHERITED_ARG);
inherited = PG_GETARG_BOOL(INHERITED_ARG);
@@ -860,6 +865,11 @@ pg_clear_attribute_stats(PG_FUNCTION_ARGS)
stats_check_required_arg(fcinfo, attarginfo, ATTNAME_ARG);
attname = PG_GETARG_NAME(ATTNAME_ARG);
attnum = get_attnum(reloid, NameStr(*attname));
+ if (attnum == InvalidAttrNumber)
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_COLUMN),
+ errmsg("column \"%s\" of relation \"%s\" does not exist",
+ NameStr(*attname), get_rel_name(reloid))));
stats_check_required_arg(fcinfo, attarginfo, INHERITED_ARG);
inherited = PG_GETARG_BOOL(INHERITED_ARG);