Commit 83ab8e32 authored by Alvaro Herrera's avatar Alvaro Herrera

Fix object identities for text search objects

We were neglecting to schema-qualify them.

Backpatch to 9.3, where object identities were introduced as a concept
by commit f8348ea3.
parent 5b68d816
...@@ -2717,12 +2717,12 @@ getObjectIdentity(const ObjectAddress *object) ...@@ -2717,12 +2717,12 @@ getObjectIdentity(const ObjectAddress *object)
case OCLASS_PROC: case OCLASS_PROC:
appendStringInfoString(&buffer, appendStringInfoString(&buffer,
format_procedure_qualified(object->objectId)); format_procedure_qualified(object->objectId));
break; break;
case OCLASS_TYPE: case OCLASS_TYPE:
appendStringInfoString(&buffer, appendStringInfoString(&buffer,
format_type_be_qualified(object->objectId)); format_type_be_qualified(object->objectId));
break; break;
case OCLASS_CAST: case OCLASS_CAST:
...@@ -2816,7 +2816,7 @@ getObjectIdentity(const ObjectAddress *object) ...@@ -2816,7 +2816,7 @@ getObjectIdentity(const ObjectAddress *object)
object->objectId); object->objectId);
conForm = (Form_pg_conversion) GETSTRUCT(conTup); conForm = (Form_pg_conversion) GETSTRUCT(conTup);
appendStringInfoString(&buffer, appendStringInfoString(&buffer,
quote_identifier(NameStr(conForm->conname))); quote_identifier(NameStr(conForm->conname)));
ReleaseSysCache(conTup); ReleaseSysCache(conTup);
break; break;
} }
...@@ -2884,7 +2884,7 @@ getObjectIdentity(const ObjectAddress *object) ...@@ -2884,7 +2884,7 @@ getObjectIdentity(const ObjectAddress *object)
case OCLASS_OPERATOR: case OCLASS_OPERATOR:
appendStringInfoString(&buffer, appendStringInfoString(&buffer,
format_operator_qualified(object->objectId)); format_operator_qualified(object->objectId));
break; break;
case OCLASS_OPCLASS: case OCLASS_OPCLASS:
...@@ -2911,7 +2911,7 @@ getObjectIdentity(const ObjectAddress *object) ...@@ -2911,7 +2911,7 @@ getObjectIdentity(const ObjectAddress *object)
amForm = (Form_pg_am) GETSTRUCT(amTup); amForm = (Form_pg_am) GETSTRUCT(amTup);
appendStringInfoString(&buffer, appendStringInfoString(&buffer,
quote_qualified_identifier(schema, quote_qualified_identifier(schema,
NameStr(opcForm->opcname))); NameStr(opcForm->opcname)));
appendStringInfo(&buffer, " for %s", appendStringInfo(&buffer, " for %s",
quote_identifier(NameStr(amForm->amname))); quote_identifier(NameStr(amForm->amname)));
...@@ -3070,7 +3070,7 @@ getObjectIdentity(const ObjectAddress *object) ...@@ -3070,7 +3070,7 @@ getObjectIdentity(const ObjectAddress *object)
elog(ERROR, "cache lookup failed for namespace %u", elog(ERROR, "cache lookup failed for namespace %u",
object->objectId); object->objectId);
appendStringInfoString(&buffer, appendStringInfoString(&buffer,
quote_identifier(nspname)); quote_identifier(nspname));
break; break;
} }
...@@ -3078,6 +3078,7 @@ getObjectIdentity(const ObjectAddress *object) ...@@ -3078,6 +3078,7 @@ getObjectIdentity(const ObjectAddress *object)
{ {
HeapTuple tup; HeapTuple tup;
Form_pg_ts_parser formParser; Form_pg_ts_parser formParser;
char *schema;
tup = SearchSysCache1(TSPARSEROID, tup = SearchSysCache1(TSPARSEROID,
ObjectIdGetDatum(object->objectId)); ObjectIdGetDatum(object->objectId));
...@@ -3085,8 +3086,10 @@ getObjectIdentity(const ObjectAddress *object) ...@@ -3085,8 +3086,10 @@ getObjectIdentity(const ObjectAddress *object)
elog(ERROR, "cache lookup failed for text search parser %u", elog(ERROR, "cache lookup failed for text search parser %u",
object->objectId); object->objectId);
formParser = (Form_pg_ts_parser) GETSTRUCT(tup); formParser = (Form_pg_ts_parser) GETSTRUCT(tup);
schema = get_namespace_name(formParser->prsnamespace);
appendStringInfoString(&buffer, appendStringInfoString(&buffer,
quote_identifier(NameStr(formParser->prsname))); quote_qualified_identifier(schema,
NameStr(formParser->prsname)));
ReleaseSysCache(tup); ReleaseSysCache(tup);
break; break;
} }
...@@ -3095,6 +3098,7 @@ getObjectIdentity(const ObjectAddress *object) ...@@ -3095,6 +3098,7 @@ getObjectIdentity(const ObjectAddress *object)
{ {
HeapTuple tup; HeapTuple tup;
Form_pg_ts_dict formDict; Form_pg_ts_dict formDict;
char *schema;
tup = SearchSysCache1(TSDICTOID, tup = SearchSysCache1(TSDICTOID,
ObjectIdGetDatum(object->objectId)); ObjectIdGetDatum(object->objectId));
...@@ -3102,8 +3106,10 @@ getObjectIdentity(const ObjectAddress *object) ...@@ -3102,8 +3106,10 @@ getObjectIdentity(const ObjectAddress *object)
elog(ERROR, "cache lookup failed for text search dictionary %u", elog(ERROR, "cache lookup failed for text search dictionary %u",
object->objectId); object->objectId);
formDict = (Form_pg_ts_dict) GETSTRUCT(tup); formDict = (Form_pg_ts_dict) GETSTRUCT(tup);
schema = get_namespace_name(formDict->dictnamespace);
appendStringInfoString(&buffer, appendStringInfoString(&buffer,
quote_identifier(NameStr(formDict->dictname))); quote_qualified_identifier(schema,
NameStr(formDict->dictname)));
ReleaseSysCache(tup); ReleaseSysCache(tup);
break; break;
} }
...@@ -3112,6 +3118,7 @@ getObjectIdentity(const ObjectAddress *object) ...@@ -3112,6 +3118,7 @@ getObjectIdentity(const ObjectAddress *object)
{ {
HeapTuple tup; HeapTuple tup;
Form_pg_ts_template formTmpl; Form_pg_ts_template formTmpl;
char *schema;
tup = SearchSysCache1(TSTEMPLATEOID, tup = SearchSysCache1(TSTEMPLATEOID,
ObjectIdGetDatum(object->objectId)); ObjectIdGetDatum(object->objectId));
...@@ -3119,8 +3126,11 @@ getObjectIdentity(const ObjectAddress *object) ...@@ -3119,8 +3126,11 @@ getObjectIdentity(const ObjectAddress *object)
elog(ERROR, "cache lookup failed for text search template %u", elog(ERROR, "cache lookup failed for text search template %u",
object->objectId); object->objectId);
formTmpl = (Form_pg_ts_template) GETSTRUCT(tup); formTmpl = (Form_pg_ts_template) GETSTRUCT(tup);
schema = get_namespace_name(formTmpl->tmplnamespace);
appendStringInfoString(&buffer, appendStringInfoString(&buffer,
quote_identifier(NameStr(formTmpl->tmplname))); quote_qualified_identifier(schema,
NameStr(formTmpl->tmplname)));
pfree(schema);
ReleaseSysCache(tup); ReleaseSysCache(tup);
break; break;
} }
...@@ -3129,6 +3139,7 @@ getObjectIdentity(const ObjectAddress *object) ...@@ -3129,6 +3139,7 @@ getObjectIdentity(const ObjectAddress *object)
{ {
HeapTuple tup; HeapTuple tup;
Form_pg_ts_config formCfg; Form_pg_ts_config formCfg;
char *schema;
tup = SearchSysCache1(TSCONFIGOID, tup = SearchSysCache1(TSCONFIGOID,
ObjectIdGetDatum(object->objectId)); ObjectIdGetDatum(object->objectId));
...@@ -3136,8 +3147,10 @@ getObjectIdentity(const ObjectAddress *object) ...@@ -3136,8 +3147,10 @@ getObjectIdentity(const ObjectAddress *object)
elog(ERROR, "cache lookup failed for text search configuration %u", elog(ERROR, "cache lookup failed for text search configuration %u",
object->objectId); object->objectId);
formCfg = (Form_pg_ts_config) GETSTRUCT(tup); formCfg = (Form_pg_ts_config) GETSTRUCT(tup);
schema = get_namespace_name(formCfg->cfgnamespace);
appendStringInfoString(&buffer, appendStringInfoString(&buffer,
quote_identifier(NameStr(formCfg->cfgname))); quote_qualified_identifier(schema,
NameStr(formCfg->cfgname)));
ReleaseSysCache(tup); ReleaseSysCache(tup);
break; break;
} }
...@@ -3148,7 +3161,7 @@ getObjectIdentity(const ObjectAddress *object) ...@@ -3148,7 +3161,7 @@ getObjectIdentity(const ObjectAddress *object)
username = GetUserNameFromId(object->objectId); username = GetUserNameFromId(object->objectId);
appendStringInfoString(&buffer, appendStringInfoString(&buffer,
quote_identifier(username)); quote_identifier(username));
break; break;
} }
...@@ -3161,7 +3174,7 @@ getObjectIdentity(const ObjectAddress *object) ...@@ -3161,7 +3174,7 @@ getObjectIdentity(const ObjectAddress *object)
elog(ERROR, "cache lookup failed for database %u", elog(ERROR, "cache lookup failed for database %u",
object->objectId); object->objectId);
appendStringInfoString(&buffer, appendStringInfoString(&buffer,
quote_identifier(datname)); quote_identifier(datname));
break; break;
} }
...@@ -3174,7 +3187,7 @@ getObjectIdentity(const ObjectAddress *object) ...@@ -3174,7 +3187,7 @@ getObjectIdentity(const ObjectAddress *object)
elog(ERROR, "cache lookup failed for tablespace %u", elog(ERROR, "cache lookup failed for tablespace %u",
object->objectId); object->objectId);
appendStringInfoString(&buffer, appendStringInfoString(&buffer,
quote_identifier(tblspace)); quote_identifier(tblspace));
break; break;
} }
...@@ -3193,7 +3206,7 @@ getObjectIdentity(const ObjectAddress *object) ...@@ -3193,7 +3206,7 @@ getObjectIdentity(const ObjectAddress *object)
srv = GetForeignServer(object->objectId); srv = GetForeignServer(object->objectId);
appendStringInfoString(&buffer, appendStringInfoString(&buffer,
quote_identifier(srv->servername)); quote_identifier(srv->servername));
break; break;
} }
...@@ -3377,8 +3390,8 @@ getRelationIdentity(StringInfo buffer, Oid relid) ...@@ -3377,8 +3390,8 @@ getRelationIdentity(StringInfo buffer, Oid relid)
schema = get_namespace_name(relForm->relnamespace); schema = get_namespace_name(relForm->relnamespace);
appendStringInfoString(buffer, appendStringInfoString(buffer,
quote_qualified_identifier(schema, quote_qualified_identifier(schema,
NameStr(relForm->relname))); NameStr(relForm->relname)));
ReleaseSysCache(relTup); ReleaseSysCache(relTup);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment