Commit 0fd8cfb2 authored by Alvaro Herrera's avatar Alvaro Herrera

GetPublicationByName: Don't repeat ourselves

Use get_publication_oid() instead of reimplementing it.

Discussion: https://postgr.es/m/20191220201017.GA17292@alvherre.pgsql
parent 696cc3a0
......@@ -374,7 +374,6 @@ GetPublication(Oid pubid)
Form_pg_publication pubform;
tup = SearchSysCache1(PUBLICATIONOID, ObjectIdGetDatum(pubid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for publication %u", pubid);
......@@ -403,19 +402,9 @@ GetPublicationByName(const char *pubname, bool missing_ok)
{
Oid oid;
oid = GetSysCacheOid1(PUBLICATIONNAME, Anum_pg_publication_oid,
CStringGetDatum(pubname));
if (!OidIsValid(oid))
{
if (missing_ok)
return NULL;
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("publication \"%s\" does not exist", pubname)));
}
oid = get_publication_oid(pubname, missing_ok);
return GetPublication(oid);
return OidIsValid(oid) ? GetPublication(oid) : NULL;
}
/*
......
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