Skip to content

Commit 0fd8cfb

Browse files
committed
GetPublicationByName: Don't repeat ourselves
Use get_publication_oid() instead of reimplementing it. Discussion: https://postgr.es/m/20191220201017.GA17292@alvherre.pgsql
1 parent 696cc3a commit 0fd8cfb

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

src/backend/catalog/pg_publication.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,6 @@ GetPublication(Oid pubid)
374374
Form_pg_publication pubform;
375375

376376
tup = SearchSysCache1(PUBLICATIONOID, ObjectIdGetDatum(pubid));
377-
378377
if (!HeapTupleIsValid(tup))
379378
elog(ERROR, "cache lookup failed for publication %u", pubid);
380379

@@ -403,19 +402,9 @@ GetPublicationByName(const char *pubname, bool missing_ok)
403402
{
404403
Oid oid;
405404

406-
oid = GetSysCacheOid1(PUBLICATIONNAME, Anum_pg_publication_oid,
407-
CStringGetDatum(pubname));
408-
if (!OidIsValid(oid))
409-
{
410-
if (missing_ok)
411-
return NULL;
412-
413-
ereport(ERROR,
414-
(errcode(ERRCODE_UNDEFINED_OBJECT),
415-
errmsg("publication \"%s\" does not exist", pubname)));
416-
}
405+
oid = get_publication_oid(pubname, missing_ok);
417406

418-
return GetPublication(oid);
407+
return OidIsValid(oid) ? GetPublication(oid) : NULL;
419408
}
420409

421410
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy