aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2019-12-23 12:47:36 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2019-12-23 12:47:36 -0300
commit0fd8cfb20d2d41d4c2df021a5f355965fd8d21bc (patch)
treec5c0a87441995968268feb6b8934a71b54de9acb /src
parent696cc3a0cabd5f11d0c8a187b7561f6d0d39c5e0 (diff)
downloadpostgresql-0fd8cfb20d2d41d4c2df021a5f355965fd8d21bc.tar.gz
postgresql-0fd8cfb20d2d41d4c2df021a5f355965fd8d21bc.zip
GetPublicationByName: Don't repeat ourselves
Use get_publication_oid() instead of reimplementing it. Discussion: https://postgr.es/m/20191220201017.GA17292@alvherre.pgsql
Diffstat (limited to 'src')
-rw-r--r--src/backend/catalog/pg_publication.c15
1 files changed, 2 insertions, 13 deletions
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index d442c8e0bbc..f6e9a68bf70 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;
}
/*