aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/tsearchcmds.c
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2015-03-03 14:10:50 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2015-03-03 14:10:50 -0300
commita2e35b53c39b2a27d3e332dc7c506539c306fd44 (patch)
tree1f4cd33208d33f4a8b3159b0d3757109c67d4b14 /src/backend/commands/tsearchcmds.c
parent6f9d79904748c26a58991942dc6719db558f77b0 (diff)
downloadpostgresql-a2e35b53c39b2a27d3e332dc7c506539c306fd44.tar.gz
postgresql-a2e35b53c39b2a27d3e332dc7c506539c306fd44.zip
Change many routines to return ObjectAddress rather than OID
The changed routines are mostly those that can be directly called by ProcessUtilitySlow; the intention is to make the affected object information more precise, in support for future event trigger changes. Originally it was envisioned that the OID of the affected object would be enough, and in most cases that is correct, but upon actually implementing the event trigger changes it turned out that ObjectAddress is more widely useful. Additionally, some command execution routines grew an output argument that's an object address which provides further info about the executed command. To wit: * for ALTER DOMAIN / ADD CONSTRAINT, it corresponds to the address of the new constraint * for ALTER OBJECT / SET SCHEMA, it corresponds to the address of the schema that originally contained the object. * for ALTER EXTENSION {ADD, DROP} OBJECT, it corresponds to the address of the object added to or dropped from the extension. There's no user-visible change in this commit, and no functional change either. Discussion: 20150218213255.GC6717@tamriel.snowman.net Reviewed-By: Stephen Frost, Andres Freund
Diffstat (limited to 'src/backend/commands/tsearchcmds.c')
-rw-r--r--src/backend/commands/tsearchcmds.c62
1 files changed, 42 insertions, 20 deletions
diff --git a/src/backend/commands/tsearchcmds.c b/src/backend/commands/tsearchcmds.c
index c6f89941e82..45bafd31707 100644
--- a/src/backend/commands/tsearchcmds.c
+++ b/src/backend/commands/tsearchcmds.c
@@ -120,8 +120,10 @@ get_ts_parser_func(DefElem *defel, int attnum)
/*
* make pg_depend entries for a new pg_ts_parser entry
+ *
+ * Return value is the address of said new entry.
*/
-static void
+static ObjectAddress
makeParserDependencies(HeapTuple tuple)
{
Form_pg_ts_parser prs = (Form_pg_ts_parser) GETSTRUCT(tuple);
@@ -162,12 +164,14 @@ makeParserDependencies(HeapTuple tuple)
referenced.objectId = prs->prsheadline;
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
}
+
+ return myself;
}
/*
* CREATE TEXT SEARCH PARSER
*/
-Oid
+ObjectAddress
DefineTSParser(List *names, List *parameters)
{
char *prsname;
@@ -179,6 +183,7 @@ DefineTSParser(List *names, List *parameters)
NameData pname;
Oid prsOid;
Oid namespaceoid;
+ ObjectAddress address;
if (!superuser())
ereport(ERROR,
@@ -269,7 +274,7 @@ DefineTSParser(List *names, List *parameters)
CatalogUpdateIndexes(prsRel, tup);
- makeParserDependencies(tup);
+ address = makeParserDependencies(tup);
/* Post creation hook for new text search parser */
InvokeObjectPostCreateHook(TSParserRelationId, prsOid, 0);
@@ -278,7 +283,7 @@ DefineTSParser(List *names, List *parameters)
heap_close(prsRel, RowExclusiveLock);
- return prsOid;
+ return address;
}
/*
@@ -308,8 +313,10 @@ RemoveTSParserById(Oid prsId)
/*
* make pg_depend entries for a new pg_ts_dict entry
+ *
+ * Return value is address of the new entry
*/
-static void
+static ObjectAddress
makeDictionaryDependencies(HeapTuple tuple)
{
Form_pg_ts_dict dict = (Form_pg_ts_dict) GETSTRUCT(tuple);
@@ -337,6 +344,8 @@ makeDictionaryDependencies(HeapTuple tuple)
referenced.objectId = dict->dicttemplate;
referenced.objectSubId = 0;
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
+
+ return myself;
}
/*
@@ -397,7 +406,7 @@ verify_dictoptions(Oid tmplId, List *dictoptions)
/*
* CREATE TEXT SEARCH DICTIONARY
*/
-Oid
+ObjectAddress
DefineTSDictionary(List *names, List *parameters)
{
ListCell *pl;
@@ -412,6 +421,7 @@ DefineTSDictionary(List *names, List *parameters)
Oid namespaceoid;
AclResult aclresult;
char *dictname;
+ ObjectAddress address;
/* Convert list of names to a name and namespace */
namespaceoid = QualifiedNameGetCreationNamespace(names, &dictname);
@@ -475,7 +485,7 @@ DefineTSDictionary(List *names, List *parameters)
CatalogUpdateIndexes(dictRel, tup);
- makeDictionaryDependencies(tup);
+ address = makeDictionaryDependencies(tup);
/* Post creation hook for new text search dictionary */
InvokeObjectPostCreateHook(TSDictionaryRelationId, dictOid, 0);
@@ -484,7 +494,7 @@ DefineTSDictionary(List *names, List *parameters)
heap_close(dictRel, RowExclusiveLock);
- return dictOid;
+ return address;
}
/*
@@ -514,7 +524,7 @@ RemoveTSDictionaryById(Oid dictId)
/*
* ALTER TEXT SEARCH DICTIONARY
*/
-Oid
+ObjectAddress
AlterTSDictionary(AlterTSDictionaryStmt *stmt)
{
HeapTuple tup,
@@ -528,6 +538,7 @@ AlterTSDictionary(AlterTSDictionaryStmt *stmt)
Datum repl_val[Natts_pg_ts_dict];
bool repl_null[Natts_pg_ts_dict];
bool repl_repl[Natts_pg_ts_dict];
+ ObjectAddress address;
dictId = get_ts_dict_oid(stmt->dictname, false);
@@ -614,6 +625,8 @@ AlterTSDictionary(AlterTSDictionaryStmt *stmt)
InvokeObjectPostAlterHook(TSDictionaryRelationId, dictId, 0);
+ ObjectAddressSet(address, TSDictionaryRelationId, dictId);
+
/*
* NOTE: because we only support altering the options, not the template,
* there is no need to update dependencies. This might have to change if
@@ -625,7 +638,7 @@ AlterTSDictionary(AlterTSDictionaryStmt *stmt)
heap_close(rel, RowExclusiveLock);
- return dictId;
+ return address;
}
/* ---------------------- TS Template commands -----------------------*/
@@ -678,7 +691,7 @@ get_ts_template_func(DefElem *defel, int attnum)
/*
* make pg_depend entries for a new pg_ts_template entry
*/
-static void
+static ObjectAddress
makeTSTemplateDependencies(HeapTuple tuple)
{
Form_pg_ts_template tmpl = (Form_pg_ts_template) GETSTRUCT(tuple);
@@ -710,12 +723,14 @@ makeTSTemplateDependencies(HeapTuple tuple)
referenced.objectId = tmpl->tmplinit;
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
}
+
+ return myself;
}
/*
* CREATE TEXT SEARCH TEMPLATE
*/
-Oid
+ObjectAddress
DefineTSTemplate(List *names, List *parameters)
{
ListCell *pl;
@@ -728,6 +743,7 @@ DefineTSTemplate(List *names, List *parameters)
Oid tmplOid;
Oid namespaceoid;
char *tmplname;
+ ObjectAddress address;
if (!superuser())
ereport(ERROR,
@@ -793,7 +809,7 @@ DefineTSTemplate(List *names, List *parameters)
CatalogUpdateIndexes(tmplRel, tup);
- makeTSTemplateDependencies(tup);
+ address = makeTSTemplateDependencies(tup);
/* Post creation hook for new text search template */
InvokeObjectPostCreateHook(TSTemplateRelationId, tmplOid, 0);
@@ -802,7 +818,7 @@ DefineTSTemplate(List *names, List *parameters)
heap_close(tmplRel, RowExclusiveLock);
- return tmplOid;
+ return address;
}
/*
@@ -860,7 +876,7 @@ GetTSConfigTuple(List *names)
* Pass opened pg_ts_config_map relation if there might be any config map
* entries for the config.
*/
-static void
+static ObjectAddress
makeConfigurationDependencies(HeapTuple tuple, bool removeOld,
Relation mapRel)
{
@@ -940,12 +956,14 @@ makeConfigurationDependencies(HeapTuple tuple, bool removeOld,
record_object_address_dependencies(&myself, addrs, DEPENDENCY_NORMAL);
free_object_addresses(addrs);
+
+ return myself;
}
/*
* CREATE TEXT SEARCH CONFIGURATION
*/
-Oid
+ObjectAddress
DefineTSConfiguration(List *names, List *parameters)
{
Relation cfgRel;
@@ -961,6 +979,7 @@ DefineTSConfiguration(List *names, List *parameters)
Oid prsOid = InvalidOid;
Oid cfgOid;
ListCell *pl;
+ ObjectAddress address;
/* Convert list of names to a name and namespace */
namespaceoid = QualifiedNameGetCreationNamespace(names, &cfgname);
@@ -1088,7 +1107,7 @@ DefineTSConfiguration(List *names, List *parameters)
systable_endscan(scan);
}
- makeConfigurationDependencies(tup, false, mapRel);
+ address = makeConfigurationDependencies(tup, false, mapRel);
/* Post creation hook for new text search configuration */
InvokeObjectPostCreateHook(TSConfigRelationId, cfgOid, 0);
@@ -1099,7 +1118,7 @@ DefineTSConfiguration(List *names, List *parameters)
heap_close(mapRel, RowExclusiveLock);
heap_close(cfgRel, RowExclusiveLock);
- return cfgOid;
+ return address;
}
/*
@@ -1153,12 +1172,13 @@ RemoveTSConfigurationById(Oid cfgId)
/*
* ALTER TEXT SEARCH CONFIGURATION - main entry point
*/
-Oid
+ObjectAddress
AlterTSConfiguration(AlterTSConfigurationStmt *stmt)
{
HeapTuple tup;
Oid cfgId;
Relation relMap;
+ ObjectAddress address;
/* Find the configuration */
tup = GetTSConfigTuple(stmt->cfgname);
@@ -1189,11 +1209,13 @@ AlterTSConfiguration(AlterTSConfigurationStmt *stmt)
InvokeObjectPostAlterHook(TSConfigMapRelationId,
HeapTupleGetOid(tup), 0);
+ ObjectAddressSet(address, TSConfigMapRelationId, cfgId);
+
heap_close(relMap, RowExclusiveLock);
ReleaseSysCache(tup);
- return cfgId;
+ return address;
}
/*