mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +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:
@@ -1069,7 +1069,7 @@ brin_summarize_range(PG_FUNCTION_ARGS)
|
||||
RelationGetRelationName(indexRel))));
|
||||
|
||||
/* User must own the index (comparable to privileges needed for VACUUM) */
|
||||
if (heapRel != NULL && !pg_class_ownercheck(indexoid, save_userid))
|
||||
if (heapRel != NULL && !object_ownercheck(RelationRelationId, indexoid, save_userid))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_INDEX,
|
||||
RelationGetRelationName(indexRel));
|
||||
|
||||
@@ -1152,7 +1152,7 @@ brin_desummarize_range(PG_FUNCTION_ARGS)
|
||||
RelationGetRelationName(indexRel))));
|
||||
|
||||
/* User must own the index (comparable to privileges needed for VACUUM) */
|
||||
if (!pg_class_ownercheck(indexoid, GetUserId()))
|
||||
if (!object_ownercheck(RelationRelationId, indexoid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_INDEX,
|
||||
RelationGetRelationName(indexRel));
|
||||
|
||||
|
||||
@@ -1054,7 +1054,7 @@ gin_clean_pending_list(PG_FUNCTION_ARGS)
|
||||
errmsg("cannot access temporary indexes of other sessions")));
|
||||
|
||||
/* User must own the index (comparable to privileges needed for VACUUM) */
|
||||
if (!pg_class_ownercheck(indexoid, GetUserId()))
|
||||
if (!object_ownercheck(RelationRelationId, indexoid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_INDEX,
|
||||
RelationGetRelationName(indexRel));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user