mirror of
https://github.com/postgres/postgres.git
synced 2025-07-08 11:42: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:
@ -2727,7 +2727,7 @@ AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *o
|
||||
* Permission check: must own extension. Note that we don't bother to
|
||||
* check ownership of the individual member objects ...
|
||||
*/
|
||||
if (!pg_extension_ownercheck(extensionOid, GetUserId()))
|
||||
if (!object_ownercheck(ExtensionRelationId, extensionOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_EXTENSION,
|
||||
extensionName);
|
||||
|
||||
@ -2947,7 +2947,7 @@ ExecAlterExtensionStmt(ParseState *pstate, AlterExtensionStmt *stmt)
|
||||
table_close(extRel, AccessShareLock);
|
||||
|
||||
/* Permission check: must own extension */
|
||||
if (!pg_extension_ownercheck(extensionOid, GetUserId()))
|
||||
if (!object_ownercheck(ExtensionRelationId, extensionOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_EXTENSION,
|
||||
stmt->extname);
|
||||
|
||||
@ -3229,7 +3229,7 @@ ExecAlterExtensionContentsStmt(AlterExtensionContentsStmt *stmt,
|
||||
&relation, AccessShareLock, false);
|
||||
|
||||
/* Permission check: must own extension */
|
||||
if (!pg_extension_ownercheck(extension.objectId, GetUserId()))
|
||||
if (!object_ownercheck(ExtensionRelationId, extension.objectId, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_EXTENSION,
|
||||
stmt->extname);
|
||||
|
||||
|
Reference in New Issue
Block a user