check_publication_add_relation(PublicationRelInfo *pri)
{
Relation targetrel = pri->relation;
+ const char *relname;
const char *errormsg;
if (pri->except)
+ {
+ relname = RelationGetQualifiedRelationName(targetrel);
errormsg = gettext_noop("cannot specify relation \"%s\" in the publication EXCEPT clause");
+ }
else
+ {
+ relname = RelationGetRelationName(targetrel);
errormsg = gettext_noop("cannot add relation \"%s\" to publication");
+ }
/* If in EXCEPT clause, must be root partitioned table */
if (pri->except && targetrel->rd_rel->relispartition)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg(errormsg, RelationGetRelationName(targetrel)),
+ errmsg(errormsg, relname),
errdetail("This operation is not supported for individual partitions.")));
/* Must be a regular or partitioned table */
RelationGetForm(targetrel)->relkind != RELKIND_PARTITIONED_TABLE)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg(errormsg, RelationGetRelationName(targetrel)),
+ errmsg(errormsg, relname),
errdetail_relkind_not_supported(RelationGetForm(targetrel)->relkind)));
/* Can't be system table */
if (IsCatalogRelation(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg(errormsg, RelationGetRelationName(targetrel)),
+ errmsg(errormsg, relname),
errdetail("This operation is not supported for system tables.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
if (targetrel->rd_rel->relpersistence == RELPERSISTENCE_TEMP)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg(errormsg, RelationGetRelationName(targetrel)),
+ errmsg(errormsg, relname),
errdetail("This operation is not supported for temporary tables.")));
else if (targetrel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg(errormsg, RelationGetRelationName(targetrel)),
+ errmsg(errormsg, relname),
errdetail("This operation is not supported for unlogged tables.")));
}
{
HeapTuple tp;
Form_pg_class reltup;
- char *relname;
- char *nspname;
char *result;
tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for relation %u", relid);
reltup = (Form_pg_class) GETSTRUCT(tp);
- relname = NameStr(reltup->relname);
-
- nspname = get_namespace_name_or_temp(reltup->relnamespace);
- if (!nspname)
- elog(ERROR, "cache lookup failed for namespace %u",
- reltup->relnamespace);
-
- result = quote_qualified_identifier(nspname, relname);
+ result = get_qualified_objname(reltup->relnamespace,
+ NameStr(reltup->relname));
ReleaseSysCache(tp);
return result;
return get_namespace_name(nspid);
}
+/*
+ * get_qualified_objname
+ * Returns a palloc'd string containing the schema-qualified name of the
+ * object for the given namespace ID and object name.
+ */
+char *
+get_qualified_objname(Oid nspid, char *objname)
+{
+ char *nspname;
+ char *result;
+
+ nspname = get_namespace_name_or_temp(nspid);
+ if (!nspname)
+ elog(ERROR, "cache lookup failed for namespace %u", nspid);
+
+ result = quote_qualified_identifier(nspname, objname);
+
+ return result;
+}
+
/* ---------- PG_RANGE CACHES ---------- */
/*