From fc6d1006bda783cc002c61a5f072905849dbde4b Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Thu, 17 Nov 2011 21:31:29 -0500 Subject: 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 --- src/backend/commands/aggregatecmds.c | 53 ++---------------------------------- 1 file changed, 2 insertions(+), 51 deletions(-) (limited to 'src/backend/commands/aggregatecmds.c') 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,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) { -- cgit v1.2.3