1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-08 11:42:09 +03:00

Unify drop-by-OID functions

There are a number of Remove${Something}ById() functions that are
essentially identical in structure and only different in which catalog
they are working on.  Refactor this to be one generic function.  The
information about which oid column, index, etc. to use was already
available in ObjectProperty for most catalogs, in a few cases it was
easily added.

Reviewed-by: Pavel Stehule <pavel.stehule@gmail.com>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/331d9661-1743-857f-1cbb-d5728bcd62cb%402ndquadrant.com
This commit is contained in:
Peter Eisentraut
2020-06-09 09:10:14 +02:00
parent b27c90bbe4
commit b1d32d3e32
23 changed files with 175 additions and 619 deletions

View File

@ -218,28 +218,6 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
return myself;
}
/*
* Guts of language dropping.
*/
void
DropProceduralLanguageById(Oid langOid)
{
Relation rel;
HeapTuple langTup;
rel = table_open(LanguageRelationId, RowExclusiveLock);
langTup = SearchSysCache1(LANGOID, ObjectIdGetDatum(langOid));
if (!HeapTupleIsValid(langTup)) /* should not happen */
elog(ERROR, "cache lookup failed for language %u", langOid);
CatalogTupleDelete(rel, &langTup->t_self);
ReleaseSysCache(langTup);
table_close(rel, RowExclusiveLock);
}
/*
* get_language_oid - given a language name, look up the OID
*