mirror of
https://github.com/postgres/postgres.git
synced 2025-07-11 10:01:57 +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:
@ -254,7 +254,7 @@ RenameSchema(const char *oldname, const char *newname)
|
||||
errmsg("schema \"%s\" already exists", newname)));
|
||||
|
||||
/* must be owner */
|
||||
if (!pg_namespace_ownercheck(nspOid, GetUserId()))
|
||||
if (!object_ownercheck(NamespaceRelationId, nspOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_SCHEMA,
|
||||
oldname);
|
||||
|
||||
@ -364,7 +364,7 @@ AlterSchemaOwner_internal(HeapTuple tup, Relation rel, Oid newOwnerId)
|
||||
AclResult aclresult;
|
||||
|
||||
/* Otherwise, must be owner of the existing object */
|
||||
if (!pg_namespace_ownercheck(nspForm->oid, GetUserId()))
|
||||
if (!object_ownercheck(NamespaceRelationId, nspForm->oid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_SCHEMA,
|
||||
NameStr(nspForm->nspname));
|
||||
|
||||
|
Reference in New Issue
Block a user