mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
GetPublicationByName: Don't repeat ourselves
Use get_publication_oid() instead of reimplementing it. Discussion: https://postgr.es/m/20191220201017.GA17292@alvherre.pgsql
This commit is contained in:
@ -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)
|
|||||||
{
|
{
|
||||||
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,
|
return OidIsValid(oid) ? GetPublication(oid) : NULL;
|
||||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
|
||||||
errmsg("publication \"%s\" does not exist", pubname)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return GetPublication(oid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user