pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Pg Hackers <pgsql-hackers@lists.postgresql.org>
Subject: pg_publication repetitious code
Date: Fri, 20 Dec 2019 17:10:17 -0300
Message-ID: <20191220201017.GA17292@alvherre.pgsql> (raw)

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);
 }

view thread (2+ messages)  latest in thread

Message-ID: <20191220201017.GA17292@alvherre.pgsql>
Permalink:  ../20191220201017.GA17292@alvherre.pgsql/
Also on:    postgresql.org/message-id/20191220201017.GA17292@alvherre.pgsql

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: alvherre@2ndquadrant.com, pgsql-hackers@lists.postgresql.org
  Subject: Re: pg_publication repetitious code
  In-Reply-To: <20191220201017.GA17292@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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