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