case OCLASS_PUBLICATION:
{
appendStringInfo(&buffer, _("publication %s"),
- get_publication_name(object->objectId));
+ get_publication_name(object->objectId,
+ false));
break;
}
object->objectId);
prform = (Form_pg_publication_rel) GETSTRUCT(tup);
- pubname = get_publication_name(prform->prpubid);
+ pubname = get_publication_name(prform->prpubid, false);
initStringInfo(&rel);
getRelationDescription(&rel, prform->prrelid);
case OCLASS_SUBSCRIPTION:
{
appendStringInfo(&buffer, _("subscription %s"),
- get_subscription_name(object->objectId));
+ get_subscription_name(object->objectId,
+ false));
break;
}
{
char *pubname;
- pubname = get_publication_name(object->objectId);
+ pubname = get_publication_name(object->objectId, false);
appendStringInfoString(&buffer,
quote_identifier(pubname));
if (objname)
object->objectId);
prform = (Form_pg_publication_rel) GETSTRUCT(tup);
- pubname = get_publication_name(prform->prpubid);
+ pubname = get_publication_name(prform->prpubid, false);
getRelationIdentity(&buffer, prform->prrelid, objname);
appendStringInfo(&buffer, " in publication %s", pubname);
{
char *subname;
- subname = get_subscription_name(object->objectId);
+ subname = get_subscription_name(object->objectId, false);
appendStringInfoString(&buffer,
quote_identifier(subname));
if (objname)
/*
* get_publication_name - given a publication Oid, look up the name
+ *
+ * If missing_ok is false, throw an error if name not found. If true, just
+ * return NULL.
*/
char *
-get_publication_name(Oid pubid)
+get_publication_name(Oid pubid, bool missing_ok)
{
HeapTuple tup;
char *pubname;
tup = SearchSysCache1(PUBLICATIONOID, ObjectIdGetDatum(pubid));
if (!HeapTupleIsValid(tup))
- elog(ERROR, "cache lookup failed for publication %u", pubid);
+ {
+ if (!missing_ok)
+ elog(ERROR, "cache lookup failed for publication %u", pubid);
+ return NULL;
+ }
pubform = (Form_pg_publication) GETSTRUCT(tup);
pubname = pstrdup(NameStr(pubform->pubname));
/*
* get_subscription_name - given a subscription OID, look up the name
+ *
+ * If missing_ok is false, throw an error if name not found. If true, just
+ * return NULL.
*/
char *
-get_subscription_name(Oid subid)
+get_subscription_name(Oid subid, bool missing_ok)
{
HeapTuple tup;
char *subname;
tup = SearchSysCache1(SUBSCRIPTIONOID, ObjectIdGetDatum(subid));
if (!HeapTupleIsValid(tup))
- elog(ERROR, "cache lookup failed for subscription %u", subid);
+ {
+ if (!missing_ok)
+ elog(ERROR, "cache lookup failed for subscription %u", subid);
+ return NULL;
+ }
subform = (Form_pg_subscription) GETSTRUCT(tup);
subname = pstrdup(NameStr(subform->subname));
bool if_not_exists);
extern Oid get_publication_oid(const char *pubname, bool missing_ok);
-extern char *get_publication_name(Oid pubid);
+extern char *get_publication_name(Oid pubid, bool missing_ok);
extern Datum pg_get_publication_tables(PG_FUNCTION_ARGS);
extern Subscription *GetSubscription(Oid subid, bool missing_ok);
extern void FreeSubscription(Subscription *sub);
extern Oid get_subscription_oid(const char *subname, bool missing_ok);
-extern char *get_subscription_name(Oid subid);
+extern char *get_subscription_name(Oid subid, bool missing_ok);
extern int CountDBSubscriptions(Oid dbid);