mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
Further consolidation of DROP statement handling.
This gets rid of an impressive amount of duplicative code, with only minimal behavior changes. DROP FOREIGN DATA WRAPPER now requires object ownership rather than superuser privileges, matching the documentation we already have. We also eliminate the historical warning about dropping a built-in function as unuseful. All operations are now performed in the same order for all object types handled by dropcmds.c. KaiGai Kohei, with minor revisions by me
This commit is contained in:
@ -1026,42 +1026,6 @@ ConvertTriggerToFK(CreateTrigStmt *stmt, Oid funcoid)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* DropTrigger - drop an individual trigger by name
|
||||
*/
|
||||
void
|
||||
DropTrigger(RangeVar *relation, const char *trigname, DropBehavior behavior,
|
||||
bool missing_ok)
|
||||
{
|
||||
Oid relid;
|
||||
ObjectAddress object;
|
||||
|
||||
/* lock level should match RemoveTriggerById */
|
||||
relid = RangeVarGetRelid(relation, AccessExclusiveLock, false, false);
|
||||
|
||||
object.classId = TriggerRelationId;
|
||||
object.objectId = get_trigger_oid(relid, trigname, missing_ok);
|
||||
object.objectSubId = 0;
|
||||
|
||||
if (!OidIsValid(object.objectId))
|
||||
{
|
||||
ereport(NOTICE,
|
||||
(errmsg("trigger \"%s\" for table \"%s\" does not exist, skipping",
|
||||
trigname, get_rel_name(relid))));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pg_class_ownercheck(relid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_CLASS,
|
||||
get_rel_name(relid));
|
||||
|
||||
/*
|
||||
* Do the deletion
|
||||
*/
|
||||
performDeletion(&object, behavior);
|
||||
}
|
||||
|
||||
/*
|
||||
* Guts of trigger deletion.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user