1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-13 07:41:39 +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:
Robert Haas
2011-11-17 21:31:29 -05:00
parent 709aca5960
commit fc6d1006bd
21 changed files with 241 additions and 1148 deletions

View File

@ -208,58 +208,9 @@ DefineAggregate(List *name, List *args, bool oldstyle, List *parameters)
/*
* RemoveAggregate
* Deletes an aggregate.
* RenameAggregate
* Rename an aggregate.
*/
void
RemoveAggregate(RemoveFuncStmt *stmt)
{
List *aggName = stmt->name;
List *aggArgs = stmt->args;
Oid procOid;
HeapTuple tup;
ObjectAddress object;
/* Look up function and make sure it's an aggregate */
procOid = LookupAggNameTypeNames(aggName, aggArgs, stmt->missing_ok);
if (!OidIsValid(procOid))
{
/* we only get here if stmt->missing_ok is true */
ereport(NOTICE,
(errmsg("aggregate %s(%s) does not exist, skipping",
NameListToString(aggName),
TypeNameListToString(aggArgs))));
return;
}
/*
* Find the function tuple, do permissions and validity checks
*/
tup = SearchSysCache1(PROCOID, ObjectIdGetDatum(procOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for function %u", procOid);
/* Permission check: must own agg or its namespace */
if (!pg_proc_ownercheck(procOid, GetUserId()) &&
!pg_namespace_ownercheck(((Form_pg_proc) GETSTRUCT(tup))->pronamespace,
GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC,
NameListToString(aggName));
ReleaseSysCache(tup);
/*
* Do the deletion
*/
object.classId = ProcedureRelationId;
object.objectId = procOid;
object.objectSubId = 0;
performDeletion(&object, stmt->behavior);
}
void
RenameAggregate(List *name, List *args, const char *newname)
{