aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/aggregatecmds.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2011-11-17 21:31:29 -0500
committerRobert Haas <rhaas@postgresql.org>2011-11-17 21:32:34 -0500
commitfc6d1006bda783cc002c61a5f072905849dbde4b (patch)
tree555ab6461e7780c0f5a5f21cc80b8f7f17eb844d /src/backend/commands/aggregatecmds.c
parent709aca59608395eef9ceb7dcb79fd9d03a0709ef (diff)
downloadpostgresql-fc6d1006bda783cc002c61a5f072905849dbde4b.tar.gz
postgresql-fc6d1006bda783cc002c61a5f072905849dbde4b.zip
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
Diffstat (limited to 'src/backend/commands/aggregatecmds.c')
-rw-r--r--src/backend/commands/aggregatecmds.c53
1 files changed, 2 insertions, 51 deletions
diff --git a/src/backend/commands/aggregatecmds.c b/src/backend/commands/aggregatecmds.c
index a2122c1d8b6..085a2059199 100644
--- a/src/backend/commands/aggregatecmds.c
+++ b/src/backend/commands/aggregatecmds.c
@@ -208,59 +208,10 @@ 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)
{
Oid procOid;