From b1d32d3e3230f00b5baba08f75b4f665c7d6dac6 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 9 Jun 2020 09:10:14 +0200 Subject: 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 Reviewed-by: Robert Haas Discussion: https://www.postgresql.org/message-id/flat/331d9661-1743-857f-1cbb-d5728bcd62cb%402ndquadrant.com --- src/backend/commands/tsearchcmds.c | 71 -------------------------------------- 1 file changed, 71 deletions(-) (limited to 'src/backend/commands/tsearchcmds.c') diff --git a/src/backend/commands/tsearchcmds.c b/src/backend/commands/tsearchcmds.c index 9da8f7fd579..319a62012ed 100644 --- a/src/backend/commands/tsearchcmds.c +++ b/src/backend/commands/tsearchcmds.c @@ -291,29 +291,6 @@ DefineTSParser(List *names, List *parameters) return address; } -/* - * Guts of TS parser deletion. - */ -void -RemoveTSParserById(Oid prsId) -{ - Relation relation; - HeapTuple tup; - - relation = table_open(TSParserRelationId, RowExclusiveLock); - - tup = SearchSysCache1(TSPARSEROID, ObjectIdGetDatum(prsId)); - - if (!HeapTupleIsValid(tup)) - elog(ERROR, "cache lookup failed for text search parser %u", prsId); - - CatalogTupleDelete(relation, &tup->t_self); - - ReleaseSysCache(tup); - - table_close(relation, RowExclusiveLock); -} - /* ---------------------- TS Dictionary commands -----------------------*/ /* @@ -504,30 +481,6 @@ DefineTSDictionary(List *names, List *parameters) return address; } -/* - * Guts of TS dictionary deletion. - */ -void -RemoveTSDictionaryById(Oid dictId) -{ - Relation relation; - HeapTuple tup; - - relation = table_open(TSDictionaryRelationId, RowExclusiveLock); - - tup = SearchSysCache1(TSDICTOID, ObjectIdGetDatum(dictId)); - - if (!HeapTupleIsValid(tup)) - elog(ERROR, "cache lookup failed for text search dictionary %u", - dictId); - - CatalogTupleDelete(relation, &tup->t_self); - - ReleaseSysCache(tup); - - table_close(relation, RowExclusiveLock); -} - /* * ALTER TEXT SEARCH DICTIONARY */ @@ -820,30 +773,6 @@ DefineTSTemplate(List *names, List *parameters) return address; } -/* - * Guts of TS template deletion. - */ -void -RemoveTSTemplateById(Oid tmplId) -{ - Relation relation; - HeapTuple tup; - - relation = table_open(TSTemplateRelationId, RowExclusiveLock); - - tup = SearchSysCache1(TSTEMPLATEOID, ObjectIdGetDatum(tmplId)); - - if (!HeapTupleIsValid(tup)) - elog(ERROR, "cache lookup failed for text search template %u", - tmplId); - - CatalogTupleDelete(relation, &tup->t_self); - - ReleaseSysCache(tup); - - table_close(relation, RowExclusiveLock); -} - /* ---------------------- TS Configuration commands -----------------------*/ /* -- cgit v1.2.3