summaryrefslogtreecommitdiff
path: root/src/backend/commands/tsearchcmds.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2011-10-19 23:25:20 -0400
committerRobert Haas <rhaas@postgresql.org>2011-10-19 23:27:19 -0400
commit82a4a777d94bec965ab2f1d04b6e6a3f0447b377 (patch)
treeb3560173b695b8391ca81edf47c4b364005a608b /src/backend/commands/tsearchcmds.c
parent3301c83536e9da1e573e24ded2e610062dbf9cdc (diff)
Consolidate DROP handling for some object types.
This gets rid of a significant amount of duplicative code. KaiGai Kohei, reviewed in earlier versions by Dimitri Fontaine, with further review and cleanup by me.
Diffstat (limited to 'src/backend/commands/tsearchcmds.c')
-rw-r--r--src/backend/commands/tsearchcmds.c254
1 files changed, 0 insertions, 254 deletions
diff --git a/src/backend/commands/tsearchcmds.c b/src/backend/commands/tsearchcmds.c
index 16e6940d131..5f206d8440a 100644
--- a/src/backend/commands/tsearchcmds.c
+++ b/src/backend/commands/tsearchcmds.c
@@ -279,65 +279,6 @@ DefineTSParser(List *names, List *parameters)
}
/*
- * DROP TEXT SEARCH PARSER
- */
-void
-RemoveTSParsers(DropStmt *drop)
-{
- ObjectAddresses *objects;
- ListCell *cell;
-
- if (!superuser())
- ereport(ERROR,
- (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("must be superuser to drop text search parsers")));
-
- /*
- * First we identify all the objects, then we delete them in a single
- * performMultipleDeletions() call. This is to avoid unwanted DROP
- * RESTRICT errors if one of the objects depends on another.
- */
- objects = new_object_addresses();
-
- foreach(cell, drop->objects)
- {
- List *names = (List *) lfirst(cell);
- Oid prsOid;
- ObjectAddress object;
-
- prsOid = get_ts_parser_oid(names, true);
-
- if (!OidIsValid(prsOid))
- {
- if (!drop->missing_ok)
- {
- ereport(ERROR,
- (errcode(ERRCODE_UNDEFINED_OBJECT),
- errmsg("text search parser \"%s\" does not exist",
- NameListToString(names))));
- }
- else
- {
- ereport(NOTICE,
- (errmsg("text search parser \"%s\" does not exist, skipping",
- NameListToString(names))));
- }
- continue;
- }
-
- object.classId = TSParserRelationId;
- object.objectId = prsOid;
- object.objectSubId = 0;
-
- add_exact_object_address(&object, objects);
- }
-
- performMultipleDeletions(objects, drop->behavior);
-
- free_object_addresses(objects);
-}
-
-/*
* Guts of TS parser deletion.
*/
void
@@ -731,76 +672,6 @@ AlterTSDictionaryNamespace_oid(Oid dictId, Oid newNspOid)
}
/*
- * DROP TEXT SEARCH DICTIONARY
- */
-void
-RemoveTSDictionaries(DropStmt *drop)
-{
- ObjectAddresses *objects;
- ListCell *cell;
-
- /*
- * First we identify all the objects, then we delete them in a single
- * performMultipleDeletions() call. This is to avoid unwanted DROP
- * RESTRICT errors if one of the objects depends on another.
- */
- objects = new_object_addresses();
-
- foreach(cell, drop->objects)
- {
- List *names = (List *) lfirst(cell);
- Oid dictOid;
- ObjectAddress object;
- HeapTuple tup;
- Oid namespaceId;
-
- dictOid = get_ts_dict_oid(names, true);
-
- if (!OidIsValid(dictOid))
- {
- if (!drop->missing_ok)
- {
- ereport(ERROR,
- (errcode(ERRCODE_UNDEFINED_OBJECT),
- errmsg("text search dictionary \"%s\" does not exist",
- NameListToString(names))));
- }
- else
- {
- ereport(NOTICE,
- (errmsg("text search dictionary \"%s\" does not exist, skipping",
- NameListToString(names))));
- }
- continue;
- }
-
- tup = SearchSysCache1(TSDICTOID, ObjectIdGetDatum(dictOid));
- if (!HeapTupleIsValid(tup)) /* should not happen */
- elog(ERROR, "cache lookup failed for text search dictionary %u",
- dictOid);
-
- /* Permission check: must own dictionary or its namespace */
- namespaceId = ((Form_pg_ts_dict) GETSTRUCT(tup))->dictnamespace;
- if (!pg_ts_dict_ownercheck(dictOid, GetUserId()) &&
- !pg_namespace_ownercheck(namespaceId, GetUserId()))
- aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_TSDICTIONARY,
- NameListToString(names));
-
- object.classId = TSDictionaryRelationId;
- object.objectId = dictOid;
- object.objectSubId = 0;
-
- add_exact_object_address(&object, objects);
-
- ReleaseSysCache(tup);
- }
-
- performMultipleDeletions(objects, drop->behavior);
-
- free_object_addresses(objects);
-}
-
-/*
* Guts of TS dictionary deletion.
*/
void
@@ -1263,65 +1134,6 @@ AlterTSTemplateNamespace_oid(Oid tmplId, Oid newNspOid)
}
/*
- * DROP TEXT SEARCH TEMPLATE
- */
-void
-RemoveTSTemplates(DropStmt *drop)
-{
- ObjectAddresses *objects;
- ListCell *cell;
-
- if (!superuser())
- ereport(ERROR,
- (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("must be superuser to drop text search templates")));
-
- /*
- * First we identify all the objects, then we delete them in a single
- * performMultipleDeletions() call. This is to avoid unwanted DROP
- * RESTRICT errors if one of the objects depends on another.
- */
- objects = new_object_addresses();
-
- foreach(cell, drop->objects)
- {
- List *names = (List *) lfirst(cell);
- Oid tmplOid;
- ObjectAddress object;
-
- tmplOid = get_ts_template_oid(names, true);
-
- if (!OidIsValid(tmplOid))
- {
- if (!drop->missing_ok)
- {
- ereport(ERROR,
- (errcode(ERRCODE_UNDEFINED_OBJECT),
- errmsg("text search template \"%s\" does not exist",
- NameListToString(names))));
- }
- else
- {
- ereport(NOTICE,
- (errmsg("text search template \"%s\" does not exist, skipping",
- NameListToString(names))));
- }
- continue;
- }
-
- object.classId = TSTemplateRelationId;
- object.objectId = tmplOid;
- object.objectSubId = 0;
-
- add_exact_object_address(&object, objects);
- }
-
- performMultipleDeletions(objects, drop->behavior);
-
- free_object_addresses(objects);
-}
-
-/*
* Guts of TS template deletion.
*/
void
@@ -1715,72 +1527,6 @@ AlterTSConfigurationNamespace_oid(Oid cfgId, Oid newNspOid)
}
/*
- * DROP TEXT SEARCH CONFIGURATION
- */
-void
-RemoveTSConfigurations(DropStmt *drop)
-{
- ObjectAddresses *objects;
- ListCell *cell;
-
- /*
- * First we identify all the objects, then we delete them in a single
- * performMultipleDeletions() call. This is to avoid unwanted DROP
- * RESTRICT errors if one of the objects depends on another.
- */
- objects = new_object_addresses();
-
- foreach(cell, drop->objects)
- {
- List *names = (List *) lfirst(cell);
- Oid cfgOid;
- Oid namespaceId;
- ObjectAddress object;
- HeapTuple tup;
-
- tup = GetTSConfigTuple(names);
-
- if (!HeapTupleIsValid(tup))
- {
- if (!drop->missing_ok)
- {
- ereport(ERROR,
- (errcode(ERRCODE_UNDEFINED_OBJECT),
- errmsg("text search configuration \"%s\" does not exist",
- NameListToString(names))));
- }
- else
- {
- ereport(NOTICE,
- (errmsg("text search configuration \"%s\" does not exist, skipping",
- NameListToString(names))));
- }
- continue;
- }
-
- /* Permission check: must own configuration or its namespace */
- cfgOid = HeapTupleGetOid(tup);
- namespaceId = ((Form_pg_ts_config) GETSTRUCT(tup))->cfgnamespace;
- if (!pg_ts_config_ownercheck(cfgOid, GetUserId()) &&
- !pg_namespace_ownercheck(namespaceId, GetUserId()))
- aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_TSCONFIGURATION,
- NameListToString(names));
-
- object.classId = TSConfigRelationId;
- object.objectId = cfgOid;
- object.objectSubId = 0;
-
- add_exact_object_address(&object, objects);
-
- ReleaseSysCache(tup);
- }
-
- performMultipleDeletions(objects, drop->behavior);
-
- free_object_addresses(objects);
-}
-
-/*
* Guts of TS configuration deletion.
*/
void