pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pg_publication repetitious code
2+ messages / 2 participants
[nested] [flat]

* pg_publication repetitious code
@ 2019-12-20 20:10 Alvaro Herrera <alvherre@2ndquadrant.com>
  2019-12-20 20:54 ` Re: pg_publication repetitious code Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: Alvaro Herrera @ 2019-12-20 20:10 UTC (permalink / raw)
  To: Pg Hackers <pgsql-hackers@lists.postgresql.org>

This very small patch removes some duplicated code in pg_publication.

-- 
Álvaro Herrera                            http://www.linkedin.com/in/alvherre

Attachments:

  [text/x-diff] pub-dry.patch (740B, ../../20191220201017.GA17292@alvherre.pgsql/2-pub-dry.patch)
  download | inline diff:
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index d442c8e0bb..347324f320 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -403,17 +403,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);
+	if (!OidIsValid(oid) && missing_ok)
+		return NULL;
 
 	return GetPublication(oid);
 }

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: pg_publication repetitious code
  2019-12-20 20:10 pg_publication repetitious code Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2019-12-20 20:54 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2019-12-20 20:54 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Pg Hackers <pgsql-hackers@lists.postgresql.org>

Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> This very small patch removes some duplicated code in pg_publication.

Seems like the extra test on missing_oid is unnecessary:

+	oid = get_publication_oid(pubname, missing_ok);
+	if (!OidIsValid(oid) && missing_ok)
+		return NULL;

As coded, it's get_publication_oid's job to deal with that.

Otherwise +1

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2019-12-20 20:54 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-12-20 20:10 pg_publication repetitious code Alvaro Herrera <alvherre@2ndquadrant.com>
2019-12-20 20:54 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox