mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +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:
@ -379,7 +379,7 @@ AlterEventTrigger(AlterEventTrigStmt *stmt)
|
||||
evtForm = (Form_pg_event_trigger) GETSTRUCT(tup);
|
||||
trigoid = evtForm->oid;
|
||||
|
||||
if (!pg_event_trigger_ownercheck(trigoid, GetUserId()))
|
||||
if (!object_ownercheck(EventTriggerRelationId, trigoid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_EVENT_TRIGGER,
|
||||
stmt->trigname);
|
||||
|
||||
@ -471,7 +471,7 @@ AlterEventTriggerOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
|
||||
if (form->evtowner == newOwnerId)
|
||||
return;
|
||||
|
||||
if (!pg_event_trigger_ownercheck(form->oid, GetUserId()))
|
||||
if (!object_ownercheck(EventTriggerRelationId, form->oid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_EVENT_TRIGGER,
|
||||
NameStr(form->evtname));
|
||||
|
||||
|
Reference in New Issue
Block a user