mirror of
https://github.com/postgres/postgres.git
synced 2025-12-21 05:21:08 +03:00
Refactor ownercheck functions
Instead of dozens of mostly-duplicate pg_foo_ownercheck() functions, write one common function object_ownercheck() that can handle almost all of them. We already have all the information we need, such as which system catalog corresponds to which catalog table and which column is the owner column. Reviewed-by: Corey Huinker <corey.huinker@gmail.com> Reviewed-by: Antonin Houska <ah@cybertec.at> Discussion: https://www.postgresql.org/message-id/flat/95c30f96-4060-2f48-98b5-a4392d3b6066@enterprisedb.com
This commit is contained in:
@@ -138,7 +138,7 @@ CreateStatistics(CreateStatsStmt *stmt)
|
||||
errdetail_relkind_not_supported(rel->rd_rel->relkind)));
|
||||
|
||||
/* You must own the relation to create stats on it */
|
||||
if (!pg_class_ownercheck(RelationGetRelid(rel), stxowner))
|
||||
if (!object_ownercheck(RelationRelationId, RelationGetRelid(rel), stxowner))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, get_relkind_objtype(rel->rd_rel->relkind),
|
||||
RelationGetRelationName(rel));
|
||||
|
||||
@@ -665,7 +665,7 @@ AlterStatistics(AlterStatsStmt *stmt)
|
||||
elog(ERROR, "cache lookup failed for extended statistics object %u", stxoid);
|
||||
|
||||
/* Must be owner of the existing statistics object */
|
||||
if (!pg_statistics_object_ownercheck(stxoid, GetUserId()))
|
||||
if (!object_ownercheck(StatisticExtRelationId, stxoid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_STATISTIC_EXT,
|
||||
NameListToString(stmt->defnames));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user