Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iiObX-0008PP-GL for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Dec 2019 20:10:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iiObW-0004uu-C3 for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Dec 2019 20:10:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iiObW-0004rp-38 for pgsql-hackers@lists.postgresql.org; Fri, 20 Dec 2019 20:10:30 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iiObR-000466-PH for pgsql-hackers@lists.postgresql.org; Fri, 20 Dec 2019 20:10:28 +0000 Received: by mail-pl1-x62c.google.com with SMTP id y8so4547968pll.13 for ; Fri, 20 Dec 2019 12:10:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:mime-version:content-disposition :content-transfer-encoding:user-agent; bh=/h35EXI1BMzWzYOmeD4Fx+Sa56l/54xWMEXW42TtP3I=; b=py0uu4EVC4tLVk2JezeuvagrIdKxv5mvx6AlOfYWzOATY+YAz7YBGyuMtzFTiFVXPu tsYEuTMftfzo+bWvNQpKKUTecRQthyc6D6+c90LqoUhI4OaXvyPw/ZjH9uNLWLw5g/8i iOw056bP4SlAOpXUbsmcvnUH+q8lafn3gtsrKlpLDpwfcoazU2mr0MJAgVtWLAkIMZO7 92MZ1w/wtnJFI7BHmUFHwRu39VkX/GLdhlNuPZCFhCkWFug9TCxzNqC/fOMwr8IepLW3 h3jxnMh3oR1tYPR3V0S5bGXlKCBiq2VKr/AK7HTDCEG0tJrFj3W0thF9klBteg8I20IZ yKkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:content-transfer-encoding:user-agent; bh=/h35EXI1BMzWzYOmeD4Fx+Sa56l/54xWMEXW42TtP3I=; b=b/IYHpugH/FU7hQFk00JyGnerdTybFP07vkOuPhMBlUmflf0EUNlOXo3sODUMxbimt Ll0UMbcbyhU+321Wkskk4mHalAFDKX49qEb/res6LuS7Ckrm34abKhwZuFNHn9q+6opY j7pWIBtbv9t/EJqnAx0NZ8b9BasULRVUe6OOQD8/FNcFUAcVPKeeITh4fhPNtlbmpocq R/d8JQxYnrXt58awll2kKoTj+A6iPAyqQscYJib9qv21RAprpAQ/hAPa+JzkkO2VAoec gqKBhKTG1i+gcorcKJita0R2a+aMOSZE/t1HWDEBubb00k097c0o4nAdmM+EHYxsFwMt oENQ== X-Gm-Message-State: APjAAAV9WSZSyHijNfSGYcQxIJADjff1wAULOwDO4596fp4pKo7qJ2eY kpexyB5lddKADg3YJpKiKOlTkJ74fUpqcPtE0eamcfFwmt+6KNRywxo1F3E4xwBibSycC6b+GSX dfI6bRr193gj8HYJlBJALD8bnvZc8ywaP5yTIj3V2rRtOq0KzXAMM4mthKYBR1jz7Id8l+NkFCM GDJn3v3R6o2DqIQS3P X-Google-Smtp-Source: APXvYqxoS7lqlxKo31sxoXzYnpKOlDrTtxUPloWcEO/KjH2deE1z9dpWv7rjtFs0c0fwl4uvO+k/TA== X-Received: by 2002:a17:90a:be06:: with SMTP id a6mr9421009pjs.62.1576872622750; Fri, 20 Dec 2019 12:10:22 -0800 (PST) Received: from nimloth.alvh.no-ip.org ([191.125.99.68]) by smtp.gmail.com with ESMTPSA id p24sm14151020pff.69.2019.12.20.12.10.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2019 12:10:21 -0800 (PST) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id A417F300A86; Fri, 20 Dec 2019 17:10:17 -0300 (-03) Date: Fri, 20 Dec 2019 17:10:17 -0300 From: Alvaro Herrera To: Pg Hackers Subject: pg_publication repetitious code Message-ID: <20191220201017.GA17292@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="J2SCkAp4GZ/dPZZf" Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --J2SCkAp4GZ/dPZZf Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit This very small patch removes some duplicated code in pg_publication. -- Álvaro Herrera http://www.linkedin.com/in/alvherre --J2SCkAp4GZ/dPZZf Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="pub-dry.patch" 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); } --J2SCkAp4GZ/dPZZf--