From 0fd8cfb20d2d41d4c2df021a5f355965fd8d21bc Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Mon, 23 Dec 2019 12:47:36 -0300 Subject: [PATCH] GetPublicationByName: Don't repeat ourselves Use get_publication_oid() instead of reimplementing it. Discussion: https://postgr.es/m/20191220201017.GA17292@alvherre.pgsql --- src/backend/catalog/pg_publication.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c index d442c8e0bb..f6e9a68bf7 100644 --- a/src/backend/catalog/pg_publication.c +++ b/src/backend/catalog/pg_publication.c @@ -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; } /* -- 2.39.5