From 765cbfdc9263bf7c90b9d1f1044c6950b8b7088c Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Mon, 21 Jan 2013 12:06:41 -0300 Subject: Refactor ALTER some-obj RENAME implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove duplicate implementations of catalog munging and miscellaneous privilege checks. Instead rely on already existing data in objectaddress.c to do the work. Author: KaiGai Kohei, changes by me Reviewed by: Robert Haas, Álvaro Herrera, Dimitri Fontaine --- src/backend/commands/proclang.c | 42 ----------------------------------------- 1 file changed, 42 deletions(-) (limited to 'src/backend/commands/proclang.c') diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c index 718b71185f8..e6c6d4e5e92 100644 --- a/src/backend/commands/proclang.c +++ b/src/backend/commands/proclang.c @@ -536,48 +536,6 @@ DropProceduralLanguageById(Oid langOid) heap_close(rel, RowExclusiveLock); } -/* - * Rename language - */ -Oid -RenameLanguage(const char *oldname, const char *newname) -{ - Oid lanId; - HeapTuple tup; - Relation rel; - - rel = heap_open(LanguageRelationId, RowExclusiveLock); - - tup = SearchSysCacheCopy1(LANGNAME, CStringGetDatum(oldname)); - if (!HeapTupleIsValid(tup)) - ereport(ERROR, - (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("language \"%s\" does not exist", oldname))); - - lanId = HeapTupleGetOid(tup); - - /* make sure the new name doesn't exist */ - if (SearchSysCacheExists1(LANGNAME, CStringGetDatum(newname))) - ereport(ERROR, - (errcode(ERRCODE_DUPLICATE_OBJECT), - errmsg("language \"%s\" already exists", newname))); - - /* must be owner of PL */ - if (!pg_language_ownercheck(HeapTupleGetOid(tup), GetUserId())) - aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_LANGUAGE, - oldname); - - /* rename */ - namestrcpy(&(((Form_pg_language) GETSTRUCT(tup))->lanname), newname); - simple_heap_update(rel, &tup->t_self, tup); - CatalogUpdateIndexes(rel, tup); - - heap_close(rel, NoLock); - heap_freetuple(tup); - - return lanId; -} - /* * get_language_oid - given a language name, look up the OID * -- cgit v1.2.3