git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 696cc3a)
GetPublicationByName: Don't repeat ourselves
2019年12月23日 15:47:36 +0000 (12:47 -0300)
2019年12月23日 15:47:36 +0000 (12:47 -0300)
Use get_publication_oid() instead of reimplementing it.

Discussion: https://postgr.es/m/20191220201017.GA17292@alvherre.pgsql


diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index d442c8e0bbcea93db81978af032a395457441a36..f6e9a68bf70770558dac49b7f2a173dfebda78b2 100644 (file)
--- 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;
}
/*
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /