GetRelationPublicationActions. - Remove unreachable code

From: Peter Smith <smithpb2250(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: GetRelationPublicationActions. - Remove unreachable code
Date: 2022-02-10 00:23:26
Message-ID: CAHut+Pv8t3-pXg4L48=5cdy=FMK3EubdpSq6ESgLGVNp8hLx4A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers.

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.

if (relation->rd_pubactions)
{
pfree(relation->rd_pubactions);
relation->rd_pubactions = NULL;
}

The latest Code Coverage report [1] also shows that this code is never executed.

5601 3556 : if (relation->rd_pubactions)
5602 : {
5603 0 : pfree(relation->rd_pubactions);
5604 0 : relation->rd_pubactions = NULL;
5605 : }

~~

PSA a patch to remove this unreachable code.

------
[1] https://coverage.postgresql.org/src/backend/utils/cache/relcache.c.gcov.html

Kind Regards,
Peter Smith.
Fujitsu Australia

Attachment Content-Type Size
v1-0001-Remove-unreachable-code-in-GetRelationPublication.patch application/octet-stream 1.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2022-02-10 00:33:36 Re: catalog access with reset GUCs during parallel worker startup
Previous Message Tom Lane 2022-02-09 23:56:41 Re: catalog access with reset GUCs during parallel worker startup