public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tom Lane <[email protected]>
To: Peter Smith <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: GetRelationPublicationActions. - Remove unreachable code
Date: Wed, 09 Feb 2022 19:34:27 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAHut+Pv8t3-pXg4L48=5cdy=FMK3EubdpSq6ESgLGVNp8hLx4A@mail.gmail.com>
References: <CAHut+Pv8t3-pXg4L48=5cdy=FMK3EubdpSq6ESgLGVNp8hLx4A@mail.gmail.com>

Peter Smith <[email protected]> writes:
> There appears to be some unreachable code in the relcache function
> GetRelationPublicationActions.
> When the 'relation->rd_pubactions' is not NULL then the function
> unconditionally returns early (near the top).
> Therefore, the following code (near the bottom) seems to have no
> purpose because IIUC the 'rd_pubactions' can never be not NULL here.

I'm not sure it's as unreachable as all that.  What you're not
accounting for is the possibility of recursive cache loading,
ie something down inside the catalog fetches we have to do here
could already have made the field valid.

Admittedly, that's probably not very likely given expected usage
patterns (to wit, that system catalogs shouldn't really have
publication actions).  But there are other places in relcache.c where
a coding pattern similar to this is demonstrably necessary to avoid
memory leakage.  I'd rather leave the code as-is, maybe add a comment
along the lines of "rd_pubactions is probably still NULL, but just in
case something already made it valid, avoid leaking memory".

			regards, tom lane






view thread (3+ messages)  latest in thread

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: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: GetRelationPublicationActions. - Remove unreachable code
  In-Reply-To: <[email protected]>

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

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