diff options
author | Jeff Davis <jdavis@postgresql.org> | 2024-11-22 12:07:46 -0800 |
---|---|---|
committer | Jeff Davis <jdavis@postgresql.org> | 2024-11-22 12:40:24 -0800 |
commit | 869ee4f10eca2acda3d2210198a46d5029a569fc (patch) | |
tree | ae7dd2d7f779d93f76f1a3bd9deff12f7ddc62cd /src/backend/statistics/attribute_stats.c | |
parent | efdc7d747539fccc7c9a946bfcb4ded716f679f1 (diff) | |
download | postgresql-869ee4f10eca2acda3d2210198a46d5029a569fc.tar.gz postgresql-869ee4f10eca2acda3d2210198a46d5029a569fc.zip |
Disallow modifying statistics on system columns.
Reported-by: Heikki Linnakangas
Discussion: https://postgr.es/m/df3e1c41-4e6c-40ad-9636-98deefe488cd@iki.fi
Diffstat (limited to 'src/backend/statistics/attribute_stats.c')
-rw-r--r-- | src/backend/statistics/attribute_stats.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/backend/statistics/attribute_stats.c b/src/backend/statistics/attribute_stats.c index 686f2e639c6..b97ba7b0c0c 100644 --- a/src/backend/statistics/attribute_stats.c +++ b/src/backend/statistics/attribute_stats.c @@ -167,6 +167,13 @@ 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 < 0) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("cannot modify statistics on system column \"%s\"", + NameStr(*attname)))); + if (attnum == InvalidAttrNumber) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), @@ -882,6 +889,13 @@ 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 < 0) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("cannot clear statistics on system column \"%s\"", + NameStr(*attname)))); + if (attnum == InvalidAttrNumber) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), |