src/backend/catalog/pg_subscription.c
Subscription *
GetSubscription(Oid subid, bool missing_ok)
{
	HeapTuple		tup;
	Subscription   *sub;
	Form_pg_subscription	subform;
	Datum			datum;
	bool			isnull;

	tup = SearchSysCache1(SUBSCRIPTIONOID, ObjectIdGetDatum(subid));

	if (!HeapTupleIsValid(tup))
	{
		if (missing_ok)
			return NULL;

		elog(ERROR, "cache lookup failed for subscription %u", subid);
	}

	subform = (Form_pg_subscription) GETSTRUCT(tup);

	sub = (Subscription *) palloc(sizeof(Subscription));
	sub->oid = subid;
	sub->dbid = subform->subdbid;
	sub->name = pstrdup(NameStr(subform->subname));
	sub->owner = subform->subowner;
	sub->enabled = subform->subenabled;

	/* Get conninfo */
	datum = SysCacheGetAttr(SUBSCRIPTIONOID,
							tup,
							Anum_pg_subscription_subconninfo,
							&isnull);
	Assert(!isnull);
	sub->conninfo = pstrdup(TextDatumGetCString(datum));

	/* Get slotname */
	datum = SysCacheGetAttr(SUBSCRIPTIONOID,
							tup,
							Anum_pg_subscription_subslotname,
							&isnull);
	Assert(!isnull);
	sub->slotname = pstrdup(NameStr(*DatumGetName(datum)));

	/* Get publications */
	datum = SysCacheGetAttr(SUBSCRIPTIONOID,
							tup,
							Anum_pg_subscription_subpublications,
							&isnull);
	Assert(!isnull);
	sub->publications = textarray_to_stringlist(DatumGetArrayTypeP(datum));

	ReleaseSysCache(tup);

	return sub;
}
/*
 * Fetch the subscription from the syscache.
 */
Fetch the subscription from the syscache.
Fetch the subscription from the syscache .
Subscription *
GetSubscription(Oid subid, bool missing_ok)
{
	HeapTuple		tup;
	Subscription   *sub;
	Form_pg_subscription	subform;
	Datum			datum;
	bool			isnull;
	tup = SearchSysCache1(SUBSCRIPTIONOID, ObjectIdGetDatum(subid));
	if (!HeapTupleIsValid(tup))
	{
		if (missing_ok)
			return NULL;
		elog(ERROR, "cache lookup failed for subscription %u", subid);
	}
	subform = (Form_pg_subscription) GETSTRUCT(tup);
	sub = (Subscription *) palloc(sizeof(Subscription));
	sub->oid = subid;
	sub->dbid = subform->subdbid;
	sub->name = pstrdup(NameStr(subform->subname));
	sub->owner = subform->subowner;
	sub->enabled = subform->subenabled;
	datum = SysCacheGetAttr(SUBSCRIPTIONOID,
							tup,
							Anum_pg_subscription_subconninfo,
							&isnull);
	Assert(!isnull);
	sub->conninfo = pstrdup(TextDatumGetCString(datum));
	datum = SysCacheGetAttr(SUBSCRIPTIONOID,
							tup,
							Anum_pg_subscription_subslotname,
							&isnull);
	Assert(!isnull);
	sub->slotname = pstrdup(NameStr(*DatumGetName(datum)));
	datum = SysCacheGetAttr(SUBSCRIPTIONOID,
							tup,
							Anum_pg_subscription_subpublications,
							&isnull);
	Assert(!isnull);
	sub->publications = textarray_to_stringlist(DatumGetArrayTypeP(datum));
	ReleaseSysCache(tup);
	return sub;
}
Subscription * GetSubscription ( Oid subid , bool missing_ok ) { HeapTuple tup ; Subscription * sub ; Form_pg_subscription subform ; Datum datum ; bool isnull ; tup = SearchSysCache1 ( SUBSCRIPTIONOID , ObjectIdGetDatum ( subid ) ) ; if ( ! HeapTupleIsValid ( tup ) ) { if ( missing_ok ) return NULL ; elog ( ERROR , " " , subid ) ; } subform = ( Form_pg_subscription ) GETSTRUCT ( tup ) ; sub = ( Subscription * ) palloc ( sizeof ( Subscription ) ) ; sub -> oid = subid ; sub -> dbid = subform -> subdbid ; sub -> name = pstrdup ( NameStr ( subform -> subname ) ) ; sub -> owner = subform -> subowner ; sub -> enabled = subform -> subenabled ; datum = SysCacheGetAttr ( SUBSCRIPTIONOID , tup , Anum_pg_subscription_subconninfo , & isnull ) ; Assert ( ! isnull ) ; sub -> conninfo = pstrdup ( TextDatumGetCString ( datum ) ) ; datum = SysCacheGetAttr ( SUBSCRIPTIONOID , tup , Anum_pg_subscription_subslotname , & isnull ) ; Assert ( ! isnull ) ; sub -> slotname = pstrdup ( NameStr ( * DatumGetName ( datum ) ) ) ; datum = SysCacheGetAttr ( SUBSCRIPTIONOID , tup , Anum_pg_subscription_subpublications , & isnull ) ; Assert ( ! isnull ) ; sub -> publications = textarray_to_stringlist ( DatumGetArrayTypeP ( datum ) ) ; ReleaseSysCache ( tup ) ; return sub ; }
Fetch the subscription from the syscache.
Fetch the subscription from the syscache .
/* Get conninfo */ /* Get slotname */ /* Get publications */