diff options
author | Robert Haas <rhaas@postgresql.org> | 2011-11-17 21:31:29 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2011-11-17 21:32:34 -0500 |
commit | fc6d1006bda783cc002c61a5f072905849dbde4b (patch) | |
tree | 555ab6461e7780c0f5a5f21cc80b8f7f17eb844d /src/backend/commands/functioncmds.c | |
parent | 709aca59608395eef9ceb7dcb79fd9d03a0709ef (diff) |
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/functioncmds.c')
-rw-r--r-- | src/backend/commands/functioncmds.c | 111 |
1 files changed, 0 insertions, 111 deletions
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c index c4746618ae5..45fdfee2175 100644 --- a/src/backend/commands/functioncmds.c +++ b/src/backend/commands/functioncmds.c @@ -961,72 +961,6 @@ CreateFunction(CreateFunctionStmt *stmt, const char *queryString) /* - * RemoveFunction - * Deletes a function. - */ -void -RemoveFunction(RemoveFuncStmt *stmt) -{ - List *functionName = stmt->name; - List *argTypes = stmt->args; /* list of TypeName nodes */ - Oid funcOid; - HeapTuple tup; - ObjectAddress object; - - /* - * Find the function, do permissions and validity checks - */ - funcOid = LookupFuncNameTypeNames(functionName, argTypes, stmt->missing_ok); - if (!OidIsValid(funcOid)) - { - /* can only get here if stmt->missing_ok */ - ereport(NOTICE, - (errmsg("function %s(%s) does not exist, skipping", - NameListToString(functionName), - TypeNameListToString(argTypes)))); - return; - } - - tup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcOid)); - if (!HeapTupleIsValid(tup)) /* should not happen */ - elog(ERROR, "cache lookup failed for function %u", funcOid); - - /* Permission check: must own func or its namespace */ - if (!pg_proc_ownercheck(funcOid, GetUserId()) && - !pg_namespace_ownercheck(((Form_pg_proc) GETSTRUCT(tup))->pronamespace, - GetUserId())) - aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC, - NameListToString(functionName)); - - if (((Form_pg_proc) GETSTRUCT(tup))->proisagg) - ereport(ERROR, - (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("\"%s\" is an aggregate function", - NameListToString(functionName)), - errhint("Use DROP AGGREGATE to drop aggregate functions."))); - - if (((Form_pg_proc) GETSTRUCT(tup))->prolang == INTERNALlanguageId) - { - /* "Helpful" NOTICE when removing a builtin function ... */ - ereport(NOTICE, - (errcode(ERRCODE_WARNING), - errmsg("removing built-in function \"%s\"", - NameListToString(functionName)))); - } - - ReleaseSysCache(tup); - - /* - * Do the deletion - */ - object.classId = ProcedureRelationId; - object.objectId = funcOid; - object.objectSubId = 0; - - performDeletion(&object, stmt->behavior); -} - -/* * Guts of function deletion. * * Note: this is also used for aggregate deletion, since the OIDs of @@ -1772,51 +1706,6 @@ CreateCast(CreateCastStmt *stmt) heap_close(relation, RowExclusiveLock); } - - -/* - * DROP CAST - */ -void -DropCast(DropCastStmt *stmt) -{ - Oid sourcetypeid; - Oid targettypeid; - ObjectAddress object; - - /* when dropping a cast, the types must exist even if you use IF EXISTS */ - sourcetypeid = typenameTypeId(NULL, stmt->sourcetype); - targettypeid = typenameTypeId(NULL, stmt->targettype); - - object.classId = CastRelationId; - object.objectId = get_cast_oid(sourcetypeid, targettypeid, - stmt->missing_ok); - object.objectSubId = 0; - - if (!OidIsValid(object.objectId)) - { - ereport(NOTICE, - (errmsg("cast from type %s to type %s does not exist, skipping", - format_type_be(sourcetypeid), - format_type_be(targettypeid)))); - return; - } - - /* Permission check */ - if (!pg_type_ownercheck(sourcetypeid, GetUserId()) - && !pg_type_ownercheck(targettypeid, GetUserId())) - ereport(ERROR, - (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("must be owner of type %s or type %s", - format_type_be(sourcetypeid), - format_type_be(targettypeid)))); - - /* - * Do the deletion - */ - performDeletion(&object, stmt->behavior); -} - /* * get_cast_oid - given two type OIDs, look up a cast OID * |