diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2013-01-21 12:06:41 -0300 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2013-01-21 12:06:41 -0300 |
commit | 765cbfdc9263bf7c90b9d1f1044c6950b8b7088c (patch) | |
tree | b7fc0ebfb2be1d051c2c223f5215239aeb3c1558 /src/backend/commands/proclang.c | |
parent | 8f0d8f481e86514bb35538827df7e1e35baee368 (diff) | |
download | postgresql-765cbfdc9263bf7c90b9d1f1044c6950b8b7088c.tar.gz postgresql-765cbfdc9263bf7c90b9d1f1044c6950b8b7088c.zip |
Refactor ALTER some-obj RENAME implementation
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
Diffstat (limited to 'src/backend/commands/proclang.c')
-rw-r--r-- | src/backend/commands/proclang.c | 42 |
1 files changed, 0 insertions, 42 deletions
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 @@ -537,48 +537,6 @@ DropProceduralLanguageById(Oid langOid) } /* - * 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 * * If missing_ok is false, throw an error if language name not found. If |